KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JFlex > tests > RegExpTests


1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * JFlex 1.4.1 *
3  * Copyright (C) 1998-2004 Gerwin Klein <lsf@jflex.de> *
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
21 package JFlex.tests;
22
23 import JFlex.*;
24 import junit.framework.TestCase;
25
26 /**
27  * Unit tests for JFlex.RegExp
28  *
29  * @author Gerwin Klein
30  * @version $Revision: 1.5 $, $Date: 2004/11/06 23:03:30 $
31  */

32 public class RegExpTests extends TestCase implements sym {
33   
34   /**
35    * Constructor for RegExpTests.
36    *
37    * @param name the test name
38    */

39   public RegExpTests(String JavaDoc name) {
40     super(name);
41   }
42
43   public void testCharClass() {
44     Macros m = new Macros();
45     RegExp e1 = new RegExp1(CCLASS, new Interval('a','z'));
46     RegExp e2 = new RegExp1(CHAR, new Character JavaDoc('Z'));
47     RegExp e3 = new RegExp1(CCLASS, new Interval('0','9'));
48     m.insert("macro", e3);
49     RegExp s = new RegExp1(STAR, e1);
50     RegExp u = new RegExp1(MACROUSE, "macro");
51     RegExp b = new RegExp2(BAR, e2, u);
52     assertTrue(e1.isCharClass(m));
53     assertTrue(e2.isCharClass(m));
54     assertTrue(b.isCharClass(m));
55     assertTrue(!s.isCharClass(m));
56     assertTrue(u.isCharClass(m));
57   }
58 }
59
Popular Tags