1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
---|
2 | * jflex *
|
---|
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 |
|
---|
21 | package JFlex.tests;
|
---|
22 |
|
---|
23 | import junit.framework.TestCase;
|
---|
24 | import JFlex.Out;
|
---|
25 | import JFlex.PackEmitter;
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * PackEmitterTest
|
---|
29 | *
|
---|
30 | * @author Gerwin Klein
|
---|
31 | * @version $Revision: 433 $, $Date: 2009-01-31 19:52:34 +1100 (Sat, 31 Jan 2009) $
|
---|
32 | */
|
---|
33 | public class PackEmitterTest extends TestCase {
|
---|
34 |
|
---|
35 | private PackEmitter p;
|
---|
36 |
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Constructor for PackEmitterTest.
|
---|
40 | */
|
---|
41 | public PackEmitterTest() {
|
---|
42 | super("PackEmitter test");
|
---|
43 | }
|
---|
44 |
|
---|
45 | public void setUp() {
|
---|
46 | p = new PackEmitter("Bla") {
|
---|
47 | public void emitUnpack() { }
|
---|
48 | };
|
---|
49 | }
|
---|
50 |
|
---|
51 | public void testInit() {
|
---|
52 | p.emitInit();
|
---|
53 | assertEquals(
|
---|
54 | " private static final int [] ZZ_BLA = zzUnpackBla();" + Out.NL +
|
---|
55 | Out.NL +
|
---|
56 | " private static final String ZZ_BLA_PACKED_0 =" + Out.NL +
|
---|
57 | " \"",
|
---|
58 | p.toString());
|
---|
59 | }
|
---|
60 |
|
---|
61 | public void testEmitUCplain() {
|
---|
62 | p.emitUC(8);
|
---|
63 | p.emitUC(0xFF00);
|
---|
64 |
|
---|
65 | assertEquals("\\10\\uff00", p.toString());
|
---|
66 | }
|
---|
67 |
|
---|
68 | public void testLineBreak() {
|
---|
69 | for (int i = 0; i < 36; i++) {
|
---|
70 | p.breaks();
|
---|
71 | p.emitUC(i);
|
---|
72 | }
|
---|
73 | System.out.println(p);
|
---|
74 | assertEquals(
|
---|
75 | "\\0\\1\\2\\3\\4\\5\\6\\7\\10\\11\\12\\13\\14\\15\\16\\17\"+"+Out.NL+
|
---|
76 | " \"\\20\\21\\22\\23\\24\\25\\26\\27\\30\\31\\32\\33\\34\\35\\36\\37\"+"+Out.NL+
|
---|
77 | " \"\\40\\41\\42\\43",
|
---|
78 | p.toString());
|
---|
79 | }
|
---|
80 | }
|
---|