1 5 package org.planetamessenger.util.test; 6 7 import org.planetamessenger.test.TestAll; 8 import org.planetamessenger.util.*; 9 10 import junit.framework.Test; 11 import junit.framework.TestCase; 12 import junit.framework.TestSuite; 13 14 22 public class JTestJKeyParser extends TestCase { 23 24 27 public JTestJKeyParser() { 28 29 } 30 31 34 public JTestJKeyParser(String name) { 35 super( name ); 36 } 37 38 39 public static Test suite() { 40 TestSuite suite = new TestSuite("JTestJKeyParser"); 41 suite.addTestSuite( JTestJKeyParser.class ); 42 43 return suite; 44 } 45 46 55 public void replaceTester(String strIn, String strOldSequence, String strNewSequence, String expectedResult) { 56 String result = JKeyParser.replace( strIn, strOldSequence, strNewSequence ); 57 58 boolean pass = result == expectedResult || result != null && result.equals(expectedResult); 59 if( !pass ) { 60 System.err.println("in=\""+strIn+"\", expectedResult=\""+expectedResult+"\", result=\""+result+"\""); 61 } 62 assertTrue( pass ); 63 } 64 65 66 public void testReplace_simple1() { 67 replaceTester( "Hello!", "H", "h", "hello!" ); 68 } 69 70 71 public void testReplace_simple2() { 72 replaceTester( "Hello! How are you doing?", "H", "h", "hello! how are you doing?" ); 73 } 74 75 76 public void testReplace_differentLengths1() { 77 replaceTester( "Hello!", "H", "hello", "Hello!" ); 78 } 79 80 81 public void testReplace_differentLengths2() { 82 replaceTester( "Hello!", "Hello", "h", "Hello!" ); 83 } 84 85 86 89 public static void main(String [] args) { 90 junit.textui.TestRunner.run( JTestJKeyParser.suite() ); 91 } 92 93 } 94 | Popular Tags |