diff options
author | Shevek <[email protected]> | 2014-09-08 17:17:08 -0700 |
---|---|---|
committer | Shevek <[email protected]> | 2014-09-08 17:17:08 -0700 |
commit | 09e951892e640874756690d3e9f7d07613b4f67b (patch) | |
tree | 8a522db3783b9e7d16264e973e4134d2b2694ce5 /src/test | |
parent | a7b9e5655b6521c6e8f3e37b83dcdfa63cb3e9b8 (diff) |
Fix #15.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/anarres/cpp/LexerSourceTest.java | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/test/java/org/anarres/cpp/LexerSourceTest.java b/src/test/java/org/anarres/cpp/LexerSourceTest.java index 80abdd3..b83ddd6 100644 --- a/src/test/java/org/anarres/cpp/LexerSourceTest.java +++ b/src/test/java/org/anarres/cpp/LexerSourceTest.java @@ -1,35 +1,41 @@ package org.anarres.cpp; import java.util.Arrays; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Ignore; import org.junit.Test; import static org.anarres.cpp.Token.*; import static org.junit.Assert.*; public class LexerSourceTest { - private void testLexerSource(String in, boolean textmatch, int... out) + private static final Log LOG = LogFactory.getLog(LexerSourceTest.class); + + public static void testLexerSource(String in, boolean textmatch, int... out) throws Exception { - System.out.println("Testing '" + in + "' => " + LOG.info("Testing '" + in + "' => " + Arrays.toString(out)); StringLexerSource s = new StringLexerSource(in); StringBuilder buf = new StringBuilder(); for (int i = 0; i < out.length; i++) { Token tok = s.token(); - System.out.println("Token is " + tok); + LOG.info("Token is " + tok); assertEquals(out[i], tok.getType()); // assertEquals(col, tok.getColumn()); buf.append(tok.getText()); } Token tok = s.token(); - System.out.println("Token is " + tok); + LOG.info("Token is " + tok); assertEquals(EOF, tok.getType()); if (textmatch) assertEquals(in, buf.toString()); } + @Ignore @Test public void testLexerSource() throws Exception { @@ -100,4 +106,10 @@ public class LexerSourceTest { testLexerSource(".45e6", true, NUMBER); testLexerSource("-6", true, '-', NUMBER); } + + @Test + public void testUnterminatedComment() throws Exception { + testLexerSource("5 /*", false, NUMBER, WHITESPACE, INVALID); // Bug #15 + testLexerSource("5 //", false, NUMBER, WHITESPACE, CPPCOMMENT); + } } |