diff options
author | carnold <[email protected]> | 2007-07-25 23:13:31 +0000 |
---|---|---|
committer | carnold <[email protected]> | 2007-07-25 23:13:31 +0000 |
commit | 6f5b47c1caf518b8ce6b6cf6fd071786377f2fe5 (patch) | |
tree | 5107271a71a87ae1ad55cedb1b7e9e2ac5cb08eb /src/test/java/net/sf/antcontrib/cpptasks/parser | |
parent | 1573cd9e52b01f51233a79787d659806271d69ac (diff) |
Bug 1760649: Rearrge to Maven 2 Standard Directory Layout
git-svn-id: file:///home/sven/projects/JOGL/temp/ant-contrib/svn/ant-contrib-code/cpptasks/trunk@121 32d7a393-a5a9-423c-abd3-5d954feb1f2f
Diffstat (limited to 'src/test/java/net/sf/antcontrib/cpptasks/parser')
4 files changed, 329 insertions, 0 deletions
diff --git a/src/test/java/net/sf/antcontrib/cpptasks/parser/TestAbstractParser.java b/src/test/java/net/sf/antcontrib/cpptasks/parser/TestAbstractParser.java new file mode 100644 index 0000000..5f7eb2a --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/parser/TestAbstractParser.java @@ -0,0 +1,26 @@ +/* + * + * Copyright 2002-2004 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; +/** + * Tests for the CParser class + */ +public class TestAbstractParser extends TestCase { + public TestAbstractParser(String name) { + super(name); + } +} 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..cbecdfb --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/parser/TestCParser.java @@ -0,0 +1,197 @@ +/* + * + * 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 java.io.CharArrayReader; +import java.io.IOException; + +/** + * Tests for the CParser class. + */ +public final class TestCParser + extends TestAbstractParser { + /** + * Constructor. + * @param name String test name + */ + public TestCParser(final String name) { + super(name); + } + + /** + * Checks parsing of #include <foo.h>. + * @throws IOException test fails on IOException + */ + public void testImmediateImportBracket() throws IOException { + CharArrayReader reader = new CharArrayReader( + "#import <foo.h> 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 <foo.h>. + * @throws IOException test fails on IOException + */ + public void testImmediateIncludeBracket() 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 #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 <foo.h. + * @throws IOException test fails on IOException + */ + public void testIncompleteImmediateImportBracket() throws IOException { + CharArrayReader reader = new CharArrayReader("#import <foo.h " + .toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 0); + } + + /** + * Checks parsing of #import "foo.h. + * @throws IOException test fails on IOException + */ + public void testIncompleteImmediateImportQuote() throws IOException { + CharArrayReader reader = new CharArrayReader("#import \"foo.h " + .toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 0); + } + + /** + * Checks parsing of #include <foo.h. + * @throws IOException test fails on IOException + */ + public void testIncompleteImmediateIncludeBracket() throws IOException { + CharArrayReader reader = new CharArrayReader("#include <foo.h " + .toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 0); + } + + /** + * Checks parsing of #include "foo.h. + * @throws IOException test fails on IOException + */ + public void testIncompleteImmediateIncludeQuote() throws IOException { + CharArrayReader reader = new CharArrayReader("#include \"foo.h " + .toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 0); + } + + /** + * Checks parsing of #include foo.h. + * @throws IOException test fails on IOException + */ + public void testNoQuoteOrBracket() throws IOException { + CharArrayReader reader = new CharArrayReader("#include foo.h " + .toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 0); + } + + /** + * Checks parsing of //#include "foo.h". + * @throws IOException test fails on IOException + */ + public void testNotFirstWhitespace() throws IOException { + CharArrayReader reader = new CharArrayReader("//#include \"foo.h\"" + .toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 0); + } + + /** + * Checks parsing when line contains leading whitespace. + * @throws IOException test fails on IOException. + */ + public void testLeadingSpace() 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 when line contains a leading tab. + * @throws IOException test fails on IOException. + */ + public void testLeadingTab() throws IOException { + CharArrayReader reader = new CharArrayReader( + "\t#include \"foo.h\" ".toCharArray()); + CParser parser = new CParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 1); + assertEquals("foo.h", includes[0]); + } + +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/parser/TestFortranParser.java b/src/test/java/net/sf/antcontrib/cpptasks/parser/TestFortranParser.java new file mode 100644 index 0000000..8078331 --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/parser/TestFortranParser.java @@ -0,0 +1,79 @@ +/* + * + * Copyright 2002-2004 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 java.io.CharArrayReader; +import java.io.IOException; + +/** + * Tests for the CParser class. + */ +public final class TestFortranParser + extends TestAbstractParser { + /** + * Constructor. + * @param name String test name + */ + public TestFortranParser(final String name) { + super(name); + } + + /** + * Checks parsing of INCLUDE 'foo.inc'. + * @throws IOException test fails on IOException + */ + public void testINCLUDE() throws IOException { + CharArrayReader reader = new CharArrayReader( + "INCLUDE 'foo.inc' nowhatever ".toCharArray()); + FortranParser parser = new FortranParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 1); + assertEquals("foo.inc", includes[0]); + } + + /** + * Checks parsing of InClUdE 'foo.inc'. + * @throws IOException test fails on IOException + */ + public void testInClUdE() throws IOException { + CharArrayReader reader = new CharArrayReader("InClUdE 'foo.inc' " + .toCharArray()); + FortranParser parser = new FortranParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 1); + assertEquals("foo.inc", includes[0]); + } + + /** + * Checks parsing of InClUdE 'foo.inc'. + * @throws IOException test fails on IOException + */ + public void testMultipleInClUdE() throws IOException { + CharArrayReader reader = new CharArrayReader( + "InClUdE 'foo.inc'\ninclude 'bar.inc' " + .toCharArray()); + FortranParser parser = new FortranParser(); + parser.parse(reader); + String[] includes = parser.getIncludes(); + assertEquals(includes.length, 2); + assertEquals("foo.inc", includes[0]); + assertEquals("bar.inc", includes[1]); + } + +} diff --git a/src/test/java/net/sf/antcontrib/cpptasks/parser/package.html b/src/test/java/net/sf/antcontrib/cpptasks/parser/package.html new file mode 100644 index 0000000..bfb9d6e --- /dev/null +++ b/src/test/java/net/sf/antcontrib/cpptasks/parser/package.html @@ -0,0 +1,27 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head> +<!-- + +Copyright 2004 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. + +--> +</head> +<body bgcolor="white"> + +JUnit tests for the net.sf.antcontrib.cpptasks.parser package. + +</body> +</html> |