|
From: <de...@us...> - 2003-03-18 14:05:31
|
Update of /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/test/telemac In directory sc8-pr-cvs1:/tmp/cvs-serv8811/dodico/src/org/fudaa/dodico/test/telemac Modified Files: TestSerafin.java TestSinusx.java Log Message: ajout des tests pour la lecture et ecriture des fichiers telemac/reflux Index: TestSerafin.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/test/telemac/TestSerafin.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestSerafin.java 21 Feb 2003 16:30:07 -0000 1.2 --- TestSerafin.java 18 Mar 2003 14:05:25 -0000 1.3 *************** *** 16,20 **** import org.fudaa.dodico.fortran.*; import org.fudaa.dodico.tr.*; ! import org.fudaa.dodico.tr.telemac.*; import org.fudaa.dodico.mnt.*; /** --- 16,20 ---- import org.fudaa.dodico.fortran.*; import org.fudaa.dodico.tr.*; ! import org.fudaa.dodico.telemac.io.*; import org.fudaa.dodico.mnt.*; /** *************** *** 34,38 **** { eps_ = 1E-15; ! t_ = lecture(getFile("exemple.res")); } --- 34,39 ---- { eps_ = 1E-15; ! t_ = lecture(getFile("exemple.res"),NativeBinaryInputStream.SPARC); ! assertNotNull(t_); } *************** *** 60,69 **** File fic = new File(args[args.length - 1]); InputStream in = new FileInputStream(fic); ! SerafinReader t = new SerafinReader(in); System.out.println(""); System.out.println("les champs"); System.out.println(""); ! SerafinInterface si = t.read(); ! DodicoLib.printStringArray(t.getMessages()); in.close(); DodicoLib.printFields(si, false); --- 61,75 ---- File fic = new File(args[args.length - 1]); InputStream in = new FileInputStream(fic); ! SerafinReader t = new SerafinReader(); ! t.setIn(in); System.out.println(""); System.out.println("les champs"); System.out.println(""); ! t.read(); ! SerafinInterface si = t.getSerafinInterface(); ! if(t.getAnalyze()!=null) ! { ! t.getAnalyze().printResume(); ! } in.close(); DodicoLib.printFields(si, false); *************** *** 77,81 **** } ! private final static synchronized SerafinInterface lecture(File _f) { SerafinInterface t = null; --- 83,87 ---- } ! private final static synchronized SerafinInterface lecture(File _f,String _type) { SerafinInterface t = null; *************** *** 84,88 **** assertNotNull(_f); InputStream in = new FileInputStream(_f); ! t = new SerafinReader(in).read(); in.close(); } --- 90,99 ---- assertNotNull(_f); InputStream in = new FileInputStream(_f); ! SerafinReader re=new SerafinReader(); ! re.setMachineId(_type); ! re.setIn(in); ! re.read(); ! assertNull(re.getAnalyze()); ! t = re.getSerafinInterface(); in.close(); } *************** *** 160,171 **** assertNotNull(f); OutputStream out = new FileOutputStream(f); ! SerafinWriter w = new SerafinWriter(t_, out); ! String[] r = w.write(); ! assertNull(r); ! t_ = lecture(f); testLecture(); } catch (Exception _e) { fail(_e.toString()); } --- 171,186 ---- assertNotNull(f); OutputStream out = new FileOutputStream(f); ! SerafinWriter w = new SerafinWriter(); ! w.setMachineID(NativeBinaryInputStream.X86); ! w.setSerafinInterface(t_); ! w.setOut(out); ! w.write(); ! assertNull(w.getAnalyze()); ! t_ = lecture(f,NativeBinaryInputStream.X86); testLecture(); } catch (Exception _e) { + _e.printStackTrace(); fail(_e.toString()); } Index: TestSinusx.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/test/telemac/TestSinusx.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestSinusx.java 21 Feb 2003 16:30:07 -0000 1.2 --- TestSinusx.java 18 Mar 2003 14:05:26 -0000 1.3 *************** *** 19,23 **** import org.fudaa.dodico.mnt.*; import org.fudaa.dodico.tr.*; ! import org.fudaa.dodico.tr.telemac.*; /** --- 19,23 ---- import org.fudaa.dodico.mnt.*; import org.fudaa.dodico.tr.*; ! import org.fudaa.dodico.telemac.io.*; /** *************** *** 26,31 **** */ ! public class TestSinusx ! extends TestCase { /** */ --- 26,30 ---- */ ! public class TestSinusx extends TestCase { /** */ *************** *** 34,50 **** double delta; - /** */ public TestSinusx() { ! } ! public void setUp() { ! testLectureFic_="simple.sx"; ! delta=1E-15; } - /** --- 33,47 ---- double delta; /** */ public TestSinusx() { ! } ! public void setUp() { ! testLectureFic_ = "simple.sx"; ! delta = 1E-15; } /** *************** *** 52,76 **** * @return */ ! private MNTZone[] lecture(File _f) ! throws IOException, NumberFormatException { assertNotNull(_f); assertTrue(_f.exists()); ! String nom = _f.getName(); ! SinusxReader r = new SinusxReader(new FileReader(_f), new ProgressionBuAdapter(new BuTask()), nom, (int)_f.length()); r.read(); ! MNTZone[] zones = r.getMNTZones(); assertEquals(zones.length, 1); ! MNTZone zone = zones[0]; assertEquals(zone.getNom(), _f.getName()); assertEquals(zone.getNbPointsSemis(), 5); ! MNTPoint p = new MNTPoint(); double t; ! MNTSemis semis = zone.getSemis(); assertNotNull(semis); ! for(int i = 0; i < 5; i++) { semis.getPoint(p, i); ! t = (double)i; assertEquals(p.getX(), t, delta); assertEquals(p.getY(), t, delta); --- 49,77 ---- * @return */ ! private MNTZone[] lecture(File _f) throws IOException, NumberFormatException { assertNotNull(_f); assertTrue(_f.exists()); ! String nom = _f.getName(); ! SinusxReader r = ! new SinusxReader( ! new FileReader(_f), ! new ProgressionBuAdapter(new BuTask()), ! nom, ! (int) _f.length()); r.read(); ! MNTZone[] zones = r.getMNTZones(); assertEquals(zones.length, 1); ! MNTZone zone = zones[0]; assertEquals(zone.getNom(), _f.getName()); assertEquals(zone.getNbPointsSemis(), 5); ! MNTPoint p = new MNTPoint(); double t; ! MNTSemis semis = zone.getSemis(); assertNotNull(semis); ! for (int i = 0; i < 5; i++) { semis.getPoint(p, i); ! t = (double) i; assertEquals(p.getX(), t, delta); assertEquals(p.getY(), t, delta); *************** *** 78,89 **** } assertEquals(zone.getNbPolylignes(), 2); ! MNTPolyligne poly = zone.getPolyligne(0); assertEquals(poly.getNbPoints(), 4); assertEquals(poly.getNom(), "courbe"); p = new MNTPoint(-1, -1, -1); ! for(int i = 0; i < 4; i++) { poly.getPoint(p, i); ! t = (double)i * 5; assertEquals(p.getX(), t, delta); assertEquals(p.getY(), t, delta); --- 79,90 ---- } assertEquals(zone.getNbPolylignes(), 2); ! MNTPolyligne poly = zone.getPolyligne(0); assertEquals(poly.getNbPoints(), 4); assertEquals(poly.getNom(), "courbe"); p = new MNTPoint(-1, -1, -1); ! for (int i = 0; i < 4; i++) { poly.getPoint(p, i); ! t = (double) i * 5; assertEquals(p.getX(), t, delta); assertEquals(p.getY(), t, delta); *************** *** 94,101 **** assertEquals(poly.getNom(), "niveau"); p = new MNTPoint(-1, -1, -1); ! for(int i = 0; i < 2; i++) { poly.getPoint(p, i); ! t = (double)i * 100 + 100; assertEquals(p.getX(), t, delta); assertEquals(p.getY(), t, delta); --- 95,102 ---- assertEquals(poly.getNom(), "niveau"); p = new MNTPoint(-1, -1, -1); ! for (int i = 0; i < 2; i++) { poly.getPoint(p, i); ! t = (double) i * 100 + 100; assertEquals(p.getX(), t, delta); assertEquals(p.getY(), t, delta); *************** *** 106,130 **** } - - /**A unit test for JUnit */ public void testLectureEcriture() { ! File f = null; try { ! File initFile = getFile(testLectureFic_); assertNotNull(initFile); ! MNTZone[] zones = lecture(initFile); assertNotNull(zones); f = File.createTempFile("testSinux", ".sx"); assertNotNull(f); ! SinusxWriter o = new SinusxWriter(new PrintWriter(new FileWriter(f)), zones); o.write(); lecture(f); ! } ! catch(Exception _e) { fail(_e.toString()); --- 107,130 ---- } /**A unit test for JUnit */ public void testLectureEcriture() { ! File f = null; try { ! File initFile = getFile(testLectureFic_); assertNotNull(initFile); ! MNTZone[] zones = lecture(initFile); assertNotNull(zones); f = File.createTempFile("testSinux", ".sx"); assertNotNull(f); ! SinusxWriter o = ! new SinusxWriter(new PrintWriter(new FileWriter(f)), zones); o.write(); lecture(f); ! } ! catch (Exception _e) { fail(_e.toString()); *************** *** 132,142 **** finally { ! if(f != null) f.delete(); } } - /** * @param _f --- 132,143 ---- finally { ! if (f != null) ! { f.delete(); + } } } /** * @param _f *************** *** 145,156 **** public File getFile(String _f) { ! URL url = getClass().getResource(_f); ! if(url == null) return null; return new File(url.getPath()); } - } - - --- 146,154 ---- public File getFile(String _f) { ! URL url = getClass().getResource(_f); ! if (url == null) return null; return new File(url.getPath()); } } |