move JFlex to CE source
[fedora-idea.git] / tools / lexer / jflex-1.4 / src / JFlex / tests / PackEmitterTest.java
blob9329c7026c848f17909cd553f477092dc0b60f47
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * jflex *
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 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
21 package JFlex.tests;
23 import JFlex.Out;
24 import JFlex.PackEmitter;
25 import junit.framework.TestCase;
27 /**
28 * PackEmitterTest
30 * @author Gerwin Klein
31 * @version $Revision: 1.7 $, $Date: 2004/04/12 10:07:48 $
33 public class PackEmitterTest extends TestCase {
35 private PackEmitter p;
38 /**
39 * Constructor for PackEmitterTest.
41 public PackEmitterTest() {
42 super("PackEmitter test");
45 public void setUp() {
46 p = new PackEmitter("Bla") {
47 public void emitUnpack() { }
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());
61 public void testEmitUCplain() {
62 p.emitUC(8);
63 p.emitUC(0xFF00);
65 assertEquals("\\10\\uff00", p.toString());
68 public void testLineBreak() {
69 for (int i = 0; i < 36; i++) {
70 p.breaks();
71 p.emitUC(i);
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());