Package freegressi.main

Source Code of freegressi.main.RW3HandlerTest

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    Copyright (C) 2013  Marchand Eric <ricoh51@free.fr>
   
    This file is part of Freegressi.

    Freegressi is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Freegressi is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Freegressi.  If not, see <http://www.gnu.org/licenses/>.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package freegressi.main;

import freegressi.tableur.Tableur;
import freegressi.tableur.Tableur.Angle;
import freegressi.utils.Utils;
import java.util.List;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

/**
* Classe de test de fichier rw3.
* Les fichiers de test se trouvent dans le dossier test/rw3/
*
* @author marchand, 12 mai 2013, 22:01:24
*/
public class RW3HandlerTest {
  private static int goods = 0, all = 0;
  private RW3Handler rw3 = new RW3Handler();
  private List<Tableur> sheets;
  private static double eps = 1e-15; // précision demandée lors des comparaisons de double
 
  public RW3HandlerTest() {
  }

  @BeforeClass
  public static void setUpClass() throws Exception {
  }

  @AfterClass
  public static void tearDownClass() throws Exception {
  }


  @Test
  public void test(){
    System.out.println("******* CSVHandler *******");
   
    test2();
   
    System.out.println("CSVHandler : " + goods + "/"+all+" tests passés avec succès!");
  }
 
  private void test2(){
    all++;
    String str = Utils.fileToString("test/rw3/test2.rw3");
    rw3.parse(str);
    sheets = rw3.getSheets();
    Tableur sheet1 = sheets.get(0);
    Tableur sheet2 = sheets.get(1);
    if (sheets.size() == 2
        && sheet1.getAngle() == Angle.DEGRE
        && sheet1.getDescription().equals("ma page 1")
        && sheet1.donneNombreColonne() == 2
        && sheet1.getRowCount() == 3
        && okDouble(sheet1.donneColonne(0).getMin(), 1.0)
        && okDouble(sheet1.donneColonne(0).getMax(), 3.0)
        && sheet2.getDescription().equals("ma page 2")
        && sheet2.donneNombreColonne() == 2
        && sheet2.getRowCount() == 2
        && okDouble(sheet2.donneColonne(0).getMin(), 0.0)
        && okDouble(sheet2.donneColonne(0).getMax(), 5.0)    ){
      goods++;
    }   
  }
 
  private boolean okDouble(double d1, double d2){
    return (Math.abs(d1 - d2) < eps);
  }
 

 
}
TOP

Related Classes of freegressi.main.RW3HandlerTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.