/// /// @file TestXMLInputStream.cs /// @brief XMLInputStream unit tests /// @author Frank Bergmann (Csharp conversion) /// @author Akiya Jouraku (Csharp conversion) /// @author Sarah Keating /// /// $Id: TestXMLInputStream.cs 8704 2009-01-04 02:26:05Z mhucka $ /// $HeadURL: https://sbml.svn.sourceforge.net/svnroot/sbml/trunk/libsbml/src/bindings/csharp/test/xml/TestXMLInputStream.cs $ /// /// This test file was converted from src/sbml/test/TestXMLInputStream.c /// with the help of conversion sciprt (ctest_converter.pl). /// /// */ namespace LibSBMLCSTest { using libsbml; using System.IO; public class TestXMLInputStream { public class AssertionError : System.Exception { public AssertionError() : base() { } } static void assertTrue(bool condition) { if (condition == true) { return; } throw new AssertionError(); } static void assertEquals(object a, object b) { if ( (a == null) && (b == null) ) { return; } else if (a.Equals(b)) { return; } throw new AssertionError(); } static void assertNotEquals(object a, object b) { if ( (a == null) && (b == null) ) { throw new AssertionError(); } else if (a.Equals(b)) { throw new AssertionError(); } } static void assertEquals(bool a, bool b) { if ( a == b ) { return; } throw new AssertionError(); } static void assertNotEquals(bool a, bool b) { if ( a != b ) { return; } throw new AssertionError(); } static void assertEquals(int a, int b) { if ( a == b ) { return; } throw new AssertionError(); } static void assertNotEquals(int a, int b) { if ( a != b ) { return; } throw new AssertionError(); } public string LV_L1v1() { return "level=\"1\" version=\"1\">\n"; } public string LV_L1v2() { return "level=\"1\" version=\"2\">\n"; } public string LV_L2v1() { return "level=\"2\" version=\"1\">\n"; } public string LV_L2v2() { return "level=\"2\" version=\"2\">\n"; } public string NS_L1() { return "xmlns=\"http://www.sbml.org/sbml/level1\" "; } public string NS_L2v1() { return "xmlns=\"http://www.sbml.org/sbml/level2\" "; } public string NS_L2v2() { return "xmlns=\"http://www.sbml.org/sbml/level2/version2\" "; } public string SBML_END() { return "\n"; } public string SBML_START() { return "\n"; } public string wrapSBML_L1v1(string s) { string r = XML_START(); r += SBML_START(); r += NS_L1(); r += LV_L1v1(); r += s; r += SBML_END(); return r; } public string wrapSBML_L1v2(string s) { string r = XML_START(); r += SBML_START(); r += NS_L1(); r += LV_L1v2(); r += s; r += SBML_END(); return r; } public string wrapSBML_L2v1(string s) { string r = XML_START(); r += SBML_START(); r += NS_L2v1(); r += LV_L2v1(); r += s; r += SBML_END(); return r; } public string wrapSBML_L2v2(string s) { string r = XML_START(); r += SBML_START(); r += NS_L2v2(); r += LV_L2v2(); r += s; r += SBML_END(); return r; } public string wrapXML(string s) { string r = XML_START(); r += s; return r; } public void test_XMLInputStream_create() { string text = wrapSBML_L2v1(" \n"); XMLInputStream stream = new XMLInputStream(text,false, ""); assertTrue( stream != null ); assertTrue( stream.isEOF() == false ); assertTrue( stream.isGood() == true ); assertTrue( stream.isError() == false ); stream.next(); assertTrue( ( "UTF-8" != stream.getEncoding() ) == false ); stream = null; } public void test_XMLInputStream_next_peek() { string text = "\n" + "\n" + " \n" + ""; XMLInputStream stream = new XMLInputStream(text,false, ""); XMLToken next = stream.peek(); assertTrue( stream != null ); assertTrue( ( "sbml" != next.getName() ) == false ); XMLToken next1 = stream.next(); assertTrue( ( "sbml" != next1.getName() ) == false ); stream = null; } public void test_XMLInputStream_setErrorLog() { string text = "\n" + "\n" + "\n" + "My Functions\n" + "\n" + "\n" + "\n" + "My Units\n" + "\n" + "\n" + ""; XMLInputStream stream = new XMLInputStream(text,false, ""); assertTrue( stream != null ); XMLErrorLog log = new XMLErrorLog(); stream.setErrorLog(log); assertTrue( stream.getErrorLog() == log ); } public void test_XMLInputStream_skip() { string text = "\n" + "\n" + "\n" + "My Functions\n" + "\n" + "\n" + "\n" + "My Units\n" + "\n" + "\n" + ""; XMLInputStream stream = new XMLInputStream(text,false, ""); assertTrue( stream != null ); XMLToken next = stream.next(); stream.skipText(); stream.skipPastEnd(stream.next()); stream.skipText(); next = stream.next(); assertTrue( ( "listOfUnitDefinitions" != next.getName() ) == false ); stream = null; } } }