summaryrefslogtreecommitdiffstats
path: root/src/tests/org/anarres/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/org/anarres/cpp')
-rw-r--r--src/tests/org/anarres/cpp/CppReaderTestCase.java2
-rw-r--r--src/tests/org/anarres/cpp/LexerSourceTestCase.java32
-rw-r--r--src/tests/org/anarres/cpp/MainTestCase.java15
3 files changed, 43 insertions, 6 deletions
diff --git a/src/tests/org/anarres/cpp/CppReaderTestCase.java b/src/tests/org/anarres/cpp/CppReaderTestCase.java
index 5aeee06..6097436 100644
--- a/src/tests/org/anarres/cpp/CppReaderTestCase.java
+++ b/src/tests/org/anarres/cpp/CppReaderTestCase.java
@@ -17,7 +17,7 @@ public class CppReaderTestCase extends BaseTestCase implements Test {
p.getPreprocessor().setIncludePath(
Collections.singletonList("src/input")
);
- p.getPreprocessor().setFlags(Preprocessor.FL_LINEMARKER);
+ p.getPreprocessor().getFeatures().add(Feature.LINEMARKERS);
BufferedReader b = new BufferedReader(p);
String line;
diff --git a/src/tests/org/anarres/cpp/LexerSourceTestCase.java b/src/tests/org/anarres/cpp/LexerSourceTestCase.java
index e8fb410..2d61e28 100644
--- a/src/tests/org/anarres/cpp/LexerSourceTestCase.java
+++ b/src/tests/org/anarres/cpp/LexerSourceTestCase.java
@@ -12,7 +12,7 @@ import static org.anarres.cpp.Token.*;
public class LexerSourceTestCase extends BaseTestCase implements Test {
- private void testLexerSource(String in, int[] out)
+ private void testLexerSource(String in, int... out)
throws Exception {
System.out.println("Testing '" + in + "' => " +
Arrays.toString(out));
@@ -29,14 +29,36 @@ public class LexerSourceTestCase extends BaseTestCase implements Test {
public void testJoinReader()
throws Exception {
- testLexerSource("int a = 5;", new int[] {
+ testLexerSource("int a = 5;",
IDENTIFIER, WHITESPACE, IDENTIFIER, WHITESPACE,
'=', WHITESPACE, INTEGER, ';', EOF
- });
+ );
- testLexerSource("# # foo", new int[] {
+ // \n is WHITESPACE because ppvalid = false
+ testLexerSource("# # \r\n\n\r \rfoo",
HASH, WHITESPACE, '#', WHITESPACE, IDENTIFIER
- });
+ );
+
+ testLexerSource("%:%:", PASTE);
+ testLexerSource("%:?", '#', '?');
+ testLexerSource("%:%=", '#', MOD_EQ);
+ testLexerSource("0x1234ffdUL 0765I",
+ INTEGER, WHITESPACE, INTEGER);
+
+ testLexerSource("+= -= *= /= %= <= >= >>= <<= &= |= ^= x",
+ PLUS_EQ, WHITESPACE,
+ SUB_EQ, WHITESPACE,
+ MULT_EQ, WHITESPACE,
+ DIV_EQ, WHITESPACE,
+ MOD_EQ, WHITESPACE,
+ LE, WHITESPACE,
+ GE, WHITESPACE,
+ RSH_EQ, WHITESPACE,
+ LSH_EQ, WHITESPACE,
+ AND_EQ, WHITESPACE,
+ OR_EQ, WHITESPACE,
+ XOR_EQ, WHITESPACE,
+ IDENTIFIER);
}
diff --git a/src/tests/org/anarres/cpp/MainTestCase.java b/src/tests/org/anarres/cpp/MainTestCase.java
new file mode 100644
index 0000000..a42f3d2
--- /dev/null
+++ b/src/tests/org/anarres/cpp/MainTestCase.java
@@ -0,0 +1,15 @@
+package org.anarres.cpp;
+
+import java.io.*;
+
+import junit.framework.Test;
+
+import static org.anarres.cpp.Token.*;
+
+public class MainTestCase extends BaseTestCase {
+
+ public void testMain() throws Exception {
+ Main.main(new String[] { "-V" });
+ }
+
+}