diff options
Diffstat (limited to 'cmake/elfinfo/src/main/test/io/trygvis/ld/NameTest.java')
-rw-r--r-- | cmake/elfinfo/src/main/test/io/trygvis/ld/NameTest.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/cmake/elfinfo/src/main/test/io/trygvis/ld/NameTest.java b/cmake/elfinfo/src/main/test/io/trygvis/ld/NameTest.java new file mode 100644 index 0000000..8d7502f --- /dev/null +++ b/cmake/elfinfo/src/main/test/io/trygvis/ld/NameTest.java @@ -0,0 +1,50 @@ +package io.trygvis.ld; + +import io.trygvis.ld.antlr.GnuLdLexer; +import io.trygvis.ld.antlr.GnuLdParser; +import org.antlr.v4.runtime.ANTLRInputStream; +import org.antlr.v4.runtime.CommonTokenStream; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class NameTest { + @Test + public void testName1() throws Exception { + a("foo", "foo"); + } + + @Test + public void testName2() throws Exception { + a("\"foo bar\"", "foo bar"); + } + + // TODO: not really expected + @Test + public void testName3() throws Exception { + a("\"foo bar\"", "foo bar"); + } + + private void a(String input, String expected) { + /* + CommonTokenStream tokens = new CommonTokenStream(new GnuLdLexer(new ANTLRInputStream(input))); + tokens.fill(); + for (Object tok : tokens.getTokens()) { + System.out.println(tok); + } + GnuLdParser parser = new GnuLdParser(tokens); + +// StringGnuLdVisitor visitor = new StringGnuLdVisitor(); + GnuLdParser.NameContext name = parser.name(); + + System.out.println("Input : |" + input + "|"); + System.out.println("String tree: " + name.toStringTree(parser)); + +// visitor.visit(name); + String actual = StringGnuLdVisitor.parseName(name); + + parser.setTrace(true); + assertEquals(input + "\n" + name.toStringTree(), expected, actual); + */ + } +} |