From 683d490074d93baa8a47db7ec43b7bd31145a12a Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Thu, 5 Nov 2009 23:00:15 +0100 Subject: Tar file expanded and committed --- .../sf/antcontrib/cpptasks/parser/TestCParser.java | 199 +++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 src/test/java/net/sf/antcontrib/cpptasks/parser/TestCParser.java (limited to 'src/test/java/net/sf/antcontrib/cpptasks/parser/TestCParser.java') diff --git a/src/test/java/net/sf/antcontrib/cpptasks/parser/TestCParser.java b/src/test/java/net/sf/antcontrib/cpptasks/parser/TestCParser.java new file mode 100644 index 0000000..d5e9888 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/parser/TestCParser.java @@ -0,0 +1,199 @@ +/* + * + * Copyright 2002-2005 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.parser; + +import junit.framework.TestCase; + +import java.io.CharArrayReader; +import java.io.IOException; + +/** + * Tests for the CParser class. + */ +public final class TestCParser + extends TestCase { + /** + * Constructor. + * @param name String test name + */ + public TestCParser(final String name) { + super(name); + } + + /** + * Checks parsing of #include . + * @throws IOException test fails on IOException + */ + public void testImmediateImportBracket() throws IOException { + CharArrayReader reader = new CharArrayReader( + "#import nowhatever ".toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 1); + assertEquals("foo.h", includes[0]); + } + + /** + * Checks parsing of #import "foo.h". + * @throws IOException test fails on IOException + */ + public void testImmediateImportQuote() throws IOException { + CharArrayReader reader = new CharArrayReader("#import \"foo.h\" " + .toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 1); + assertEquals("foo.h", includes[0]); + } + + /** + * Checks parsing of #include . + * @throws IOException test fails on IOException + */ + public void testImmediateIncludeBracket() throws IOException { + CharArrayReader reader = new CharArrayReader("#include " + .toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 1); + assertEquals("foo.h", includes[0]); + } + + /** + * Checks parsing of #include "foo.h". + * @throws IOException test fails on IOException. + */ + public void testImmediateIncludeQuote() throws IOException { + CharArrayReader reader = new CharArrayReader( + "#include \"foo.h\" ".toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 1); + assertEquals("foo.h", includes[0]); + } + + /** + * Checks parsing of #import