diff options
author | Shevek <[email protected]> | 2008-03-21 23:05:04 +0000 |
---|---|---|
committer | Shevek <[email protected]> | 2008-03-21 23:05:04 +0000 |
commit | 5ff55648127c8a8e1b9829775045af986e37647c (patch) | |
tree | b28209b1efe12824fbdcabd4ee9073e93ca30636 /src/tests/org/anarres/cpp/LexerSourceTestCase.java | |
parent | fca34200881fcaf7b84b4210f7a5f40c8925c4d1 (diff) |
move stuff into trunk
Diffstat (limited to 'src/tests/org/anarres/cpp/LexerSourceTestCase.java')
-rw-r--r-- | src/tests/org/anarres/cpp/LexerSourceTestCase.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/tests/org/anarres/cpp/LexerSourceTestCase.java b/src/tests/org/anarres/cpp/LexerSourceTestCase.java new file mode 100644 index 0000000..e8fb410 --- /dev/null +++ b/src/tests/org/anarres/cpp/LexerSourceTestCase.java @@ -0,0 +1,43 @@ +package org.anarres.cpp; + +import java.io.StringReader; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import junit.framework.Test; + +import static org.anarres.cpp.Token.*; + +public class LexerSourceTestCase extends BaseTestCase implements Test { + + private void testLexerSource(String in, int[] out) + throws Exception { + System.out.println("Testing '" + in + "' => " + + Arrays.toString(out)); + StringLexerSource s = new StringLexerSource(in); + + for (int i = 0; i < out.length; i++) { + Token tok = s.token(); + System.out.println("Token is " + tok); + assertEquals(out[i], tok.getType()); + } + assertEquals(EOF, s.token().getType()); + } + + public void testJoinReader() + throws Exception { + + testLexerSource("int a = 5;", new int[] { + IDENTIFIER, WHITESPACE, IDENTIFIER, WHITESPACE, + '=', WHITESPACE, INTEGER, ';', EOF + }); + + testLexerSource("# # foo", new int[] { + HASH, WHITESPACE, '#', WHITESPACE, IDENTIFIER + }); + + } + +} |