source: other-projects/rsyntax-textarea/devel-packages/jflex-1.4.3/src/JFlex/tests/CharClassesTest.java@ 25584

Last change on this file since 25584 was 25584, checked in by davidb, 12 years ago

Initial cut an a text edit area for GLI that supports color syntax highlighting

File size: 3.8 KB
Line 
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * JFlex 1.4.3 *
3 * Copyright (C) 1998-2009 Gerwin Klein <[email protected]> *
4 * All rights reserved. *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License. See the file *
8 * COPYRIGHT for more information. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License along *
16 * with this program; if not, write to the Free Software Foundation, Inc., *
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
18 * *
19 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
20
21package JFlex.tests;
22
23import JFlex.IntCharSet;
24import JFlex.Interval;
25import junit.framework.TestCase;
26
27/**
28 * CharClassesTest
29 *
30 * @author Gerwin Klein
31 * @version $Revision: 433 $, $Date: 2009-01-31 19:52:34 +1100 (Sat, 31 Jan 2009) $
32 */
33public class CharClassesTest extends TestCase {
34
35 /**
36 * Constructor for CharClassesTest.
37 * @param arg0
38 */
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}
Note: See TracBrowser for help on using the repository browser.