Changeset 657 in tmcsimulator for trunk/test/tmcsim/cadsimulator/viewer/CADConsoleViewerTest.java
- Timestamp:
- 09/12/2022 01:30:08 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/tmcsim/cadsimulator/viewer/CADConsoleViewerTest.java
r455 r657 34 34 console.setWriter(sw); 35 35 } 36 /** 37 * compare StringWriter contents against expected 36 /** compare StringWriter contents against expected 37 * @param expected contains just the most recent lines of output 38 * @param errmsg message to be displayed if test fails 39 * improved to verify line by line 38 40 */ 39 private void verify(String msg, String expect) 40 { 41 String result = sw.toString().trim(); 42 result = result.replaceAll("\n", ","); 43 String fullExpect = expect.trim(); 44 fullExpect = fullExpect.replaceAll("\n", ","); 45 assertTrue(msg + ": " + result, result.endsWith(fullExpect)); 46 } 41 private void verify(String errmsg, String expect) 42 { 43 44 String result = sw.toString().trim().replace("\r",""); // Remove windows line feed characters 45 String[] results = result.split("\n"); //System.getProperty("line.separator")); // split into lines 46 String[] expecteds = expect.trim().split("\n"); 47 int rIdx = results.length-1; // index to results array 48 // Work backwards from the most recent line of output 49 for (int eIdx=expecteds.length-1; eIdx >= 0; eIdx--) 50 { 51 //System.out.println("Verifying "+eIdx+". "+expecteds[eIdx]+" against "+results[rIdx]); 52 assertEquals(errmsg + " line "+eIdx, expecteds[eIdx], results[rIdx]); 53 rIdx--; 54 } 55 } 47 56 48 57 public static void pause(int millis) … … 233 242 } 234 243 235 public void testNetworkID() 236 { 237 String expected10 = 238 "--- CAD Simulator ---\n" 239 + "Elapsed Simulation Time : 0:00:00\n" 240 + "Status : No Script\n" 241 + "Connected CAD Terminals : 0\n" 242 + "Simulation Manager Connected: No\n" 243 + "Connected to Paramics : No\n" 244 + "Network Loaded : 17\n" 245 + "-- Info Messages --\n\n" 246 + "-- Error Messages --\n\n"; 247 // this will tell the model it has a new network ID 248 cadmodel.setParamicsNetworkLoaded("17"); 249 cadmodel.setParamicsStatus(CADEnums.PARAMICS_STATUS.LOADED); 250 pause(500); 251 verify("network id should be 17", expected10); 252 } 244 253 245 }
Note: See TracChangeset
for help on using the changeset viewer.
