1 package gov.nasa.jpf.jvm; 20 21 24 public class TestJavaLangString { 25 public static void main (String [] args) { 26 TestJavaLangString t = new TestJavaLangString(); 27 28 if (args.length > 0) { 29 for (int i = 0; i < args.length; i++) { 30 String func = args[i]; 31 32 if ("testIntern".equals(func)) { 33 t.testIntern(); 34 } else { 35 throw new IllegalArgumentException ("unknown test function"); 36 } 37 } 38 } else { 39 t.testIntern(); 40 } 41 } 42 43 public void testIntern () { 44 String a = "Blah".intern(); 45 String b = new String ("Blah"); 46 47 assert (a != b) : "'new String(intern) != intern' failed"; 48 49 String c = b.intern(); 50 51 assert (a == c) : "'(new String(intern)).intern() == intern' failed"; 52 } 53 } | Popular Tags |