- Timestamp:
- 12/21/05 11:21:12 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/org.modelica.mdt.test/src/org/modelica/mdt/test/TestProxyParser.java
r215 r240 42 42 package org.modelica.mdt.test; 43 43 44 import java.util.Vector; 45 46 import org.modelica.mdt.internal.omcproxy.CompileError; 47 import org.modelica.mdt.internal.omcproxy.ProxyParser; 48 import org.modelica.mdt.internal.omcproxy.UnexpectedReplyException; 44 import org.modelica.mdt.compiler.ICompileError; 45 import org.modelica.mdt.compiler.UnexpectedReplyException; 46 import org.modelica.mdt.omc.internal.OMCParser; 49 47 50 48 import junit.framework.TestCase; 51 49 52 50 /** 53 * Test various methods in org.modelica.mdt. internal.omcproxy.ProxyParser51 * Test various methods in org.modelica.mdt.omc.internal.OMCParser 54 52 * @author Elmir Jagudin 55 53 */ … … 58 56 59 57 /** 60 * test parsing some single nested lists with ProxyParser.parseList() 61 */ 62 public void testParseSimpleList() 63 { 64 /* 65 * some combinations of empty lists 66 */ 67 Vector<Object> res; 68 69 res = ProxyParser.parseList("{}"); 70 assertEquals(0, res.size()); 71 72 res = ProxyParser.parseList("{ }"); 73 assertEquals(0, res.size()); 74 75 res = ProxyParser.parseList("{ }"); 76 assertEquals(0, res.size()); 77 78 79 res = ProxyParser.parseList("{ \n}"); 80 assertEquals(0, res.size()); 81 82 res = ProxyParser.parseList("{ \n }"); 83 assertEquals(0, res.size()); 84 85 /* 86 * single element lists 87 */ 88 res = ProxyParser.parseList("{hej}"); 89 assertEquals(1, res.size()); 90 assertEquals("hej", (String)res.elementAt(0)); 91 92 res = ProxyParser.parseList("{ muu}"); 93 assertEquals(1,res.size()); 94 assertEquals("muu", (String)res.elementAt(0)); 95 96 res = ProxyParser.parseList("{ muu }"); 97 assertEquals(1, res.size()); 98 assertEquals("muu", (String)res.elementAt(0)); 99 100 res = ProxyParser.parseList("{muu }"); 101 assertEquals(1, res.size()); 102 assertEquals("muu", (String)res.elementAt(0)); 103 104 105 /* 106 * two element lists 107 */ 108 res = ProxyParser.parseList("{hej,peter}"); 109 assertEquals(2, res.size()); 110 assertEquals("hej", (String)res.elementAt(0)); 111 assertEquals("peter", (String)res.elementAt(1)); 112 113 res = ProxyParser.parseList("{peter, labb}"); 114 assertEquals("peter", (String)res.elementAt(0)); 115 assertEquals("labb", (String)res.elementAt(1)); 116 117 res = ProxyParser.parseList("{peter ,labb}"); 118 assertEquals("peter", (String)res.elementAt(0)); 119 assertEquals("labb", (String)res.elementAt(1)); 120 121 res = ProxyParser.parseList("{peter ,labb}"); 122 assertEquals("peter", (String)res.elementAt(0)); 123 assertEquals("labb", (String)res.elementAt(1)); 124 125 /* 126 * tree elements list 127 */ 128 res = ProxyParser.parseList("{alan, l, cox}"); 129 assertEquals(3, res.size()); 130 assertEquals("alan", (String)res.elementAt(0)); 131 assertEquals("l", (String)res.elementAt(1)); 132 assertEquals("cox", (String)res.elementAt(2)); 133 134 res = ProxyParser.parseList("{alan,l,cox}"); 135 assertEquals(3, res.size()); 136 assertEquals("alan", (String)res.elementAt(0)); 137 assertEquals("l", (String)res.elementAt(1)); 138 assertEquals("cox", (String)res.elementAt(2)); 139 140 } 141 142 public void testParseList() 143 { 144 Vector v = ProxyParser.parseList("{{a ,b } , c }"); 145 assertTrue(v.get(0) instanceof Vector); 146 assertTrue(v.size() == 2); 147 assertTrue(((Vector)v.get(0)).get(0).equals("a")); 148 assertTrue(((Vector)v.get(0)).get(1).equals("b")); 149 assertTrue(v.get(1).equals("c")); 150 151 v = ProxyParser.parseList("{a, b, c}"); 152 assertTrue(v.size() == 3); 153 assertTrue(v.get(0).equals("a")); 154 assertTrue(v.get(1).equals("b")); 155 assertTrue(v.get(2).equals("c")); 156 157 v = ProxyParser.parseList("{a, b, c={a, b, c}}"); 158 assertTrue(v.size() == 3); 159 assertTrue(v.get(0).equals("a")); 160 assertTrue(v.get(1).equals("b")); 161 assertTrue(v.get(2).equals("c={a, b, c}")); 162 163 v = ProxyParser.parseList("{,,}"); 164 assertTrue(v.size() == 0); 165 166 v = ProxyParser.parseList("{foo={bar, gzonk}}"); 167 assertTrue(v.size() == 1); 168 assertTrue(v.get(0).equals("foo={bar, gzonk}")); 169 } 170 171 172 173 /** 174 * Test if ProxyParser.parseErrorString() works as prescribed. 58 * Test if OMCParser.parseErrorString() works as prescribed. 175 59 * @throws UnexpectedReplyException 176 60 */ … … 182 66 String errorString = 183 67 "[c:/folde/hej.mo:2:1]: error: unexpected tooken: muu\n"; 184 CompileError[] errors = ProxyParser.parseErrorString(errorString);68 ICompileError[] errors = OMCParser.parseErrorString(errorString); 185 69 186 70 assertEquals(1, errors.length); 187 CompileError error = errors[0];71 ICompileError error = errors[0]; 188 72 assertEquals(2, error.getLine()); 189 73 assertEquals("unexpected tooken: muu", error.getErrorDescription()); … … 193 77 "[c:/folder he/hej.mo:4:1]: error: unexpected end of file\n" + 194 78 "[c:/folder he/hej.mo:15:1]: error: hej remar\n"; 195 errors = ProxyParser.parseErrorString(errorString);79 errors = OMCParser.parseErrorString(errorString); 196 80 assertEquals(2, errors.length); 197 81 … … 207 91 errorString = 208 92 "[/usr/folde/hej.mo:12:1]: error: unexpected tooken: muu\n"; 209 errors = ProxyParser.parseErrorString(errorString);93 errors = OMCParser.parseErrorString(errorString); 210 94 211 95 assertEquals(1, errors.length); … … 218 102 "[/hej/hop/hej.mo:453:1]: error: unexpected end of file\n" + 219 103 "[/usr/local/modelica/hej.mo:715:1]: error: hej remar\n"; 220 errors = ProxyParser.parseErrorString(errorString);104 errors = OMCParser.parseErrorString(errorString); 221 105 assertEquals(2, errors.length); 222 106 … … 230 114 231 115 /* no errors aka empty error string */ 232 errors = ProxyParser.parseErrorString("");116 errors = OMCParser.parseErrorString(""); 233 117 assertEquals(0, errors.length); 234 118 }
Note: See TracChangeset
for help on using the changeset viewer.