source: other-projects/rsyntax-textarea/devel-packages/jflex-1.4.3/examples/simple-maven/src/test/java/YylexTest.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: 1.5 KB
Line 
1import java.io.BufferedReader;
2import java.io.File;
3import java.io.FileOutputStream;
4import java.io.FileReader;
5import java.io.IOException;
6import java.io.PrintStream;
7
8import junit.framework.TestCase;
9
10/**
11 * This is an integration test.
12 *
13 * The class Yylex is generated by JFLex from
14 * <code>src/main/jflex/simple.flex</code>.
15 *
16 * @author regis
17 *
18 */
19public class YylexTest extends TestCase {
20
21 private static final String OUTPUT_FILE = "target/output.actual";
22
23 /**
24 * Test that Yylex parser behaves like expected.
25 *
26 * @throws IOException
27 */
28 public void testOutput() throws IOException {
29 String[] argv = new String[1];
30 argv[0] = "src/test/resources/test.txt";
31
32 // the Yylex prints status on stdout
33 File actual = new File("target/output.actual");
34 actual.delete();
35 FileOutputStream fos = new FileOutputStream(OUTPUT_FILE, true);
36 System.setOut(new PrintStream(fos));
37
38 Yylex.main(argv);
39
40 fos.close();
41
42 // test actual is expected
43 File expected = new File("src/test/resources/output.good");
44 assertTrue(expected.isFile());
45 assertTrue(actual.isFile());
46
47 BufferedReader actualContent = new BufferedReader(
48 new FileReader(actual));
49 BufferedReader expectedContent = new BufferedReader(new FileReader(
50 expected));
51
52 for (int lineNumber = 1;lineNumber!=-1; lineNumber++) {
53 String expectedLine = expectedContent.readLine();
54 String actualLine = actualContent.readLine();
55 assertEquals("Line "+lineNumber, expectedLine, actualLine);
56 if (expectedLine==null) lineNumber=-2; //EOF
57 }
58 }
59}
Note: See TracBrowser for help on using the repository browser.