1 20 21 package JFlex.tests; 22 23 import JFlex.IntCharSet; 24 import JFlex.Interval; 25 import junit.framework.TestCase; 26 27 33 public class CharClassesTest extends TestCase { 34 35 39 public CharClassesTest(String arg0) { 40 super(arg0); 41 } 42 43 public void testAdd1() { 44 IntCharSet set = new IntCharSet(new Interval('a','h')); 45 set.add(new Interval('o','z')); 46 set.add(new Interval('A','Z')); 47 set.add(new Interval('h','o')); 48 assertEquals("{ ['A'-'Z']['a'-'z'] }", set.toString()); 49 } 50 51 public void testAdd2() { 52 IntCharSet set = new IntCharSet(new Interval('a','h')); 53 set.add(new Interval('o','z')); 54 set.add(new Interval('A','Z')); 55 set.add(new Interval('i','n')); 56 assertEquals("{ ['A'-'Z']['a'-'z'] }", set.toString()); 57 } 58 59 public void testAdd3() { 60 IntCharSet set = new IntCharSet(new Interval('a','h')); 61 set.add(new Interval('o','z')); 62 set.add(new Interval('A','Z')); 63 set.add(new Interval('a','n')); 64 assertEquals("{ ['A'-'Z']['a'-'z'] }", set.toString()); 65 } 66 67 public void testMergeLast() { 68 IntCharSet set = new IntCharSet(new Interval('a','k')); 69 assertEquals("{ ['a'-'k'] }", set.toString()); 70 set.add('l'); 71 assertEquals("{ ['a'-'l'] }", set.toString()); 72 } 73 74 public void testAddChar() { 75 IntCharSet set = new IntCharSet(new Interval('a','h')); 76 set.add(new Interval('o','z')); 77 set.add('n'); 78 set.add('k'); 79 assertEquals("{ ['a'-'h']['k']['n'-'z'] }", set.toString()); 80 set.add('i'); 81 assertEquals("{ ['a'-'i']['k']['n'-'z'] }", set.toString()); 82 set.add('j'); 83 assertEquals("{ ['a'-'k']['n'-'z'] }", set.toString()); 84 set.add(new Interval('l','m')); 85 assertEquals("{ ['a'-'z'] }", set.toString()); 86 } 87 88 public void testCopy() { 89 IntCharSet set = new IntCharSet(new Interval('a','z')); 90 IntCharSet copy = set.copy(); 91 Interval i = set.getNext(); 92 i.end = 'h'; 93 assertEquals("{ ['a'-'h'] }", set.toString()); 94 assertEquals("{ ['a'-'z'] }", copy.toString()); 95 } 96 97 public void testCaseless() { 98 IntCharSet set = new IntCharSet(new Interval('a','c')); 99 set.add(new Interval('h','o')); 100 assertEquals("{ ['A'-'C']['H'-'O']['a'-'c']['h'-'o'] }", 101 set.getCaseless().toString()); 102 } 103 } 104 | Popular Tags |