summaryrefslogtreecommitdiff
path: root/test/junit/net
diff options
context:
space:
mode:
authorMark Donszelmann <Mark.Donszelmann@gmail.com>2005-11-18 21:02:34 +0000
committerMark Donszelmann <Mark.Donszelmann@gmail.com>2005-11-18 21:02:34 +0000
commit1381c87965ab669820a4a7b48c09aca026f5b478 (patch)
tree947d5ba097efbc93fae515fdae35e626c1be7bef /test/junit/net
downloadcpptasks-parallel-1381c87965ab669820a4a7b48c09aca026f5b478.tar.gz
cpptasks-parallel-1381c87965ab669820a4a7b48c09aca026f5b478.tar.bz2
cpptasks-parallel-1381c87965ab669820a4a7b48c09aca026f5b478.tar.xz
cpptasks-parallel-1381c87965ab669820a4a7b48c09aca026f5b478.zip
Diffstat (limited to 'test/junit/net')
-rw-r--r--test/junit/net/CVS/Entries1
-rw-r--r--test/junit/net/CVS/Repository1
-rw-r--r--test/junit/net/CVS/Root1
-rw-r--r--test/junit/net/sf/CVS/Entries1
-rw-r--r--test/junit/net/sf/CVS/Repository1
-rw-r--r--test/junit/net/sf/CVS/Root1
-rw-r--r--test/junit/net/sf/antcontrib/CVS/Entries1
-rw-r--r--test/junit/net/sf/antcontrib/CVS/Repository1
-rw-r--r--test/junit/net/sf/antcontrib/CVS/Root1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/CVS/Entries23
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/CVS/Repository1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/CVS/Root1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/MockBuildListener.java172
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/MockFileCollector.java90
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/TestAllClasses.java57
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/TestCCTask.java128
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/TestCUtil.java121
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/TestCompilerDef.java357
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/TestCompilerEnum.java51
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/TestDependencyTable.java79
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/TestLinkerDef.java323
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/TestLinkerEnum.java41
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/TestOutputTypeEnum.java39
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/TestProcessorDef.java278
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/TestTargetHistoryTable.java141
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/TestTargetInfo.java134
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/TestXMLConsumer.java100
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/borland/CVS/Entries2
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/borland/CVS/Repository1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/borland/CVS/Root1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/borland/TestBorlandCCompiler.java37
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/compiler/CVS/Entries7
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/compiler/CVS/Repository1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/compiler/CVS/Root1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractCompiler.java85
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractLinker.java89
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractProcessor.java80
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/compiler/TestCommandLineCompilerConfiguration.java59
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/compiler/TestCompilerConfiguration.java68
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/compiler/TestLinkType.java59
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/devstudio/CVS/Entries4
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/devstudio/CVS/Repository1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/devstudio/CVS/Root1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioLinker.java44
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/devstudio/TestInstalledDevStudio.java31
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/devstudio/TestInstalledDevStudioLinker.java60
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/gcc/CVS/Entries6
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/gcc/CVS/Repository1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/gcc/CVS/Root1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/gcc/TestAbstractArLibrarian.java79
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/gcc/TestAbstractLdLinker.java247
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccCCompiler.java80
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccCompatibleCCompiler.java105
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccLinker.java80
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/package.html28
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/parser/CVS/Entries5
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/parser/CVS/Repository1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/parser/CVS/Root1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/parser/TestAbstractParser.java26
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/parser/TestCParser.java197
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/parser/TestFortranParser.java79
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/parser/package.html27
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/trolltech/CVS/Entries4
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/trolltech/CVS/Repository1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/trolltech/CVS/Root1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectCompiler.java74
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectParser.java58
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/trolltech/package.html27
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/types/CVS/Entries4
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/types/CVS/Repository1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/types/CVS/Root1
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/types/TestDefineArgument.java124
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/types/TestLibrarySet.java301
-rw-r--r--test/junit/net/sf/antcontrib/cpptasks/types/package.html28
74 files changed, 4363 insertions, 0 deletions
diff --git a/test/junit/net/CVS/Entries b/test/junit/net/CVS/Entries
new file mode 100644
index 0000000..04c4303
--- /dev/null
+++ b/test/junit/net/CVS/Entries
@@ -0,0 +1 @@
+D/sf////
diff --git a/test/junit/net/CVS/Repository b/test/junit/net/CVS/Repository
new file mode 100644
index 0000000..7c6da67
--- /dev/null
+++ b/test/junit/net/CVS/Repository
@@ -0,0 +1 @@
+cpptasks/test/junit/net
diff --git a/test/junit/net/CVS/Root b/test/junit/net/CVS/Root
new file mode 100644
index 0000000..1ac95cd
--- /dev/null
+++ b/test/junit/net/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ant-contrib
diff --git a/test/junit/net/sf/CVS/Entries b/test/junit/net/sf/CVS/Entries
new file mode 100644
index 0000000..f19339c
--- /dev/null
+++ b/test/junit/net/sf/CVS/Entries
@@ -0,0 +1 @@
+D/antcontrib////
diff --git a/test/junit/net/sf/CVS/Repository b/test/junit/net/sf/CVS/Repository
new file mode 100644
index 0000000..854d26b
--- /dev/null
+++ b/test/junit/net/sf/CVS/Repository
@@ -0,0 +1 @@
+cpptasks/test/junit/net/sf
diff --git a/test/junit/net/sf/CVS/Root b/test/junit/net/sf/CVS/Root
new file mode 100644
index 0000000..1ac95cd
--- /dev/null
+++ b/test/junit/net/sf/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ant-contrib
diff --git a/test/junit/net/sf/antcontrib/CVS/Entries b/test/junit/net/sf/antcontrib/CVS/Entries
new file mode 100644
index 0000000..18d9c65
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/CVS/Entries
@@ -0,0 +1 @@
+D/cpptasks////
diff --git a/test/junit/net/sf/antcontrib/CVS/Repository b/test/junit/net/sf/antcontrib/CVS/Repository
new file mode 100644
index 0000000..cf57a7e
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/CVS/Repository
@@ -0,0 +1 @@
+cpptasks/test/junit/net/sf/antcontrib
diff --git a/test/junit/net/sf/antcontrib/CVS/Root b/test/junit/net/sf/antcontrib/CVS/Root
new file mode 100644
index 0000000..1ac95cd
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ant-contrib
diff --git a/test/junit/net/sf/antcontrib/cpptasks/CVS/Entries b/test/junit/net/sf/antcontrib/cpptasks/CVS/Entries
new file mode 100644
index 0000000..34f5f14
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/CVS/Entries
@@ -0,0 +1,23 @@
+/MockBuildListener.java/1.2/Sat Feb 28 19:04:46 2004//
+/MockFileCollector.java/1.2/Thu Apr 22 08:06:53 2004//
+/TestAllClasses.java/1.26/Thu Apr 22 08:06:53 2004//
+/TestCCTask.java/1.15/Sat May 1 01:40:39 2004//
+/TestCUtil.java/1.11/Sat Feb 28 19:04:46 2004//
+/TestCompilerDef.java/1.14/Tue May 11 03:50:11 2004//
+/TestCompilerEnum.java/1.5/Mon Aug 15 13:57:31 2005/-ko/
+/TestDependencyTable.java/1.2/Sat Feb 28 19:04:46 2004//
+/TestLinkerDef.java/1.11/Thu Apr 22 08:06:53 2004//
+/TestLinkerEnum.java/1.3/Sat Feb 28 19:04:46 2004//
+/TestOutputTypeEnum.java/1.3/Sat Feb 28 19:04:46 2004//
+/TestProcessorDef.java/1.12/Tue May 11 03:50:11 2004//
+/TestTargetHistoryTable.java/1.10/Tue May 11 03:50:11 2004//
+/TestTargetInfo.java/1.13/Tue May 11 03:50:11 2004//
+/TestXMLConsumer.java/1.2/Sat Feb 28 19:04:46 2004//
+/package.html/1.1/Fri Apr 16 04:04:11 2004//
+D/borland////
+D/compiler////
+D/devstudio////
+D/gcc////
+D/parser////
+D/trolltech////
+D/types////
diff --git a/test/junit/net/sf/antcontrib/cpptasks/CVS/Repository b/test/junit/net/sf/antcontrib/cpptasks/CVS/Repository
new file mode 100644
index 0000000..04ae15a
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/CVS/Repository
@@ -0,0 +1 @@
+cpptasks/test/junit/net/sf/antcontrib/cpptasks
diff --git a/test/junit/net/sf/antcontrib/cpptasks/CVS/Root b/test/junit/net/sf/antcontrib/cpptasks/CVS/Root
new file mode 100644
index 0000000..1ac95cd
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ant-contrib
diff --git a/test/junit/net/sf/antcontrib/cpptasks/MockBuildListener.java b/test/junit/net/sf/antcontrib/cpptasks/MockBuildListener.java
new file mode 100644
index 0000000..ffa6083
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/MockBuildListener.java
@@ -0,0 +1,172 @@
+/*
+ *
+ * Copyright 2003-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;
+import java.util.Vector;
+
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildListener;
+/**
+ * Captures build events
+ *
+ */
+public class MockBuildListener implements BuildListener {
+ private Vector buildFinishedEvents = new Vector();
+ private Vector buildStartedEvents = new Vector();
+ private Vector messageLoggedEvents = new Vector();
+ private Vector targetFinishedEvents = new Vector();
+ private Vector targetStartedEvents = new Vector();
+ private Vector taskFinishedEvents = new Vector();
+ private Vector taskStartedEvents = new Vector();
+ /**
+ * Signals that the last target has finished. This event will still be
+ * fired if an error occurred during the build.
+ *
+ * @param event
+ * An event with any relevant extra information. Must not be
+ * <code>null</code>.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void buildFinished(BuildEvent event) {
+ buildFinishedEvents.addElement(event);
+ }
+ /**
+ * Signals that a build has started. This event is fired before any targets
+ * have started.
+ *
+ * @param event
+ * An event with any relevant extra information. Must not be
+ * <code>null</code>.
+ */
+ public void buildStarted(BuildEvent event) {
+ buildStartedEvents.addElement(event);
+ }
+ public Vector getBuildFinishedEvents() {
+ return new Vector(buildFinishedEvents);
+ }
+ /**
+ * Gets a list of buildStarted events
+ *
+ * @return list of build started events
+ */
+ public Vector getBuildStartedEvents() {
+ return new Vector(buildStartedEvents);
+ }
+ /**
+ * Gets message logged events
+ *
+ * @return
+ */
+ public Vector getMessageLoggedEvents() {
+ return new Vector(messageLoggedEvents);
+ }
+ /**
+ * Gets target finished events
+ *
+ * @return
+ */
+ public Vector getTargetFinishedEvents() {
+ return new Vector(targetFinishedEvents);
+ }
+ /**
+ * Gets target started events
+ *
+ * @return
+ */
+ public Vector getTargetStartedEvents() {
+ return new Vector(targetStartedEvents);
+ }
+ /**
+ * Gets task finished events
+ *
+ * @return
+ */
+ public Vector getTaskFinishedEvents() {
+ return new Vector(taskFinishedEvents);
+ }
+ /**
+ * Gets task started events
+ *
+ * @return
+ */
+ public Vector getTaskStartedEvents() {
+ return new Vector(taskStartedEvents);
+ }
+ /**
+ * Signals a message logging event.
+ *
+ * @param event
+ * An event with any relevant extra information. Must not be
+ * <code>null</code>.
+ *
+ * @see BuildEvent#getMessage()
+ * @see BuildEvent#getPriority()
+ */
+ public void messageLogged(BuildEvent event) {
+ messageLoggedEvents.addElement(event);
+ }
+ /**
+ * Signals that a target has finished. This event will still be fired if an
+ * error occurred during the build.
+ *
+ * @param event
+ * An event with any relevant extra information. Must not be
+ * <code>null</code>.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void targetFinished(BuildEvent event) {
+ targetFinishedEvents.addElement(event);
+ }
+ /**
+ * Signals that a target is starting.
+ *
+ * @param event
+ * An event with any relevant extra information. Must not be
+ * <code>null</code>.
+ *
+ * @see BuildEvent#getTarget()
+ */
+ public void targetStarted(BuildEvent event) {
+ targetStartedEvents.addElement(event);
+ }
+ /**
+ * Signals that a task has finished. This event will still be fired if an
+ * error occurred during the build.
+ *
+ * @param event
+ * An event with any relevant extra information. Must not be
+ * <code>null</code>.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void taskFinished(BuildEvent event) {
+ taskFinishedEvents.addElement(event);
+ }
+ /**
+ * Signals that a task is starting.
+ *
+ * @param event
+ * An event with any relevant extra information. Must not be
+ * <code>null</code>.
+ *
+ * @see BuildEvent#getTask()
+ */
+ public void taskStarted(BuildEvent event) {
+ taskStartedEvents.addElement(event);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/MockFileCollector.java b/test/junit/net/sf/antcontrib/cpptasks/MockFileCollector.java
new file mode 100644
index 0000000..d1768fd
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/MockFileCollector.java
@@ -0,0 +1,90 @@
+/*
+ *
+ * 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.
+ */
+package net.sf.antcontrib.cpptasks;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Implementation of FileVisitor that collects visited files for later
+ * retrieval.
+ *
+ * @author Curt Arnold
+ *
+ */
+public final class MockFileCollector
+ implements FileVisitor {
+
+ /**
+ * list of fileName parameter values.
+ */
+ private final List fileNames = new ArrayList();
+
+ /**
+ * list of baseDir parameter values.
+ */
+ private final List baseDirs = new ArrayList();
+
+ /**
+ * Constructor.
+ *
+ */
+ public MockFileCollector() {
+ }
+
+ /**
+ * Implementation of FileVisitor.visit.
+ * @param baseDir base directory
+ * @param fileName file name
+ */
+ public void visit(final File baseDir, final String fileName) {
+ fileNames.add(fileName);
+ baseDirs.add(baseDir);
+ }
+
+ /**
+ * Get value of fileName parameter for a specified index.
+ *
+ * @param index
+ * index
+ * @return value of failName parameter
+ */
+ public String getFileName(final int index) {
+ return (String) fileNames.get(index);
+ }
+
+ /**
+ * Get value of baseDir parameter for the specified index.
+ *
+ * @param index
+ * index
+ * @return value of baseDir parameter
+ */
+ public File getBaseDir(final int index) {
+ return (File) baseDirs.get(index);
+ }
+
+ /**
+ * Get count of calls to FileVisitor.visit.
+ *
+ * @return count of calls.
+ */
+ public int size() {
+ return fileNames.size();
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/TestAllClasses.java b/test/junit/net/sf/antcontrib/cpptasks/TestAllClasses.java
new file mode 100644
index 0000000..e8d7c33
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/TestAllClasses.java
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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;
+import junit.framework.TestSuite;
+/**
+ * Test for abstract compiler class
+ *
+ * Override create to test concrete compiler implementions
+ */
+public class TestAllClasses extends TestSuite {
+ public static TestSuite suite() {
+ return new TestAllClasses("TestAllClasses");
+ }
+ public TestAllClasses(String name) {
+ super(name);
+ addTestSuite(net.sf.antcontrib.cpptasks.TestCUtil.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.borland.TestBorlandCCompiler.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.compiler.TestAbstractCompiler.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.compiler.TestAbstractLinker.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.compiler.TestAbstractProcessor.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.TestCCTask.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.TestCompilerEnum.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.compiler.TestCommandLineCompilerConfiguration.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.TestDependencyTable.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.types.TestDefineArgument.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.devstudio.TestDevStudioLinker.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.TestLinkerDef.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.TestTargetInfo.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.types.TestLibrarySet.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.TestCompilerDef.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.parser.TestCParser.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.gcc.TestGccCCompiler.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.gcc.TestAbstractLdLinker.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.gcc.TestAbstractArLibrarian.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.TestTargetHistoryTable.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.TestOutputTypeEnum.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.compiler.TestLinkType.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.TestLinkerEnum.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.gcc.TestAbstractLdLinker.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.gcc.TestAbstractArLibrarian.class);
+ addTestSuite(net.sf.antcontrib.cpptasks.gcc.TestGccLinker.class);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/TestCCTask.java b/test/junit/net/sf/antcontrib/cpptasks/TestCCTask.java
new file mode 100644
index 0000000..82faae2
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/TestCCTask.java
@@ -0,0 +1,128 @@
+/*
+ *
+ * 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;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Hashtable;
+import java.util.Vector;
+import junit.framework.TestCase;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration;
+import net.sf.antcontrib.cpptasks.gcc.GccCCompiler;
+
+/**
+ * Tests for CCTask.
+ *
+ */
+public final class TestCCTask
+ extends TestCase {
+ /**
+ * Constructor.
+ * @param name test name
+ *
+ */
+ public TestCCTask(final String name) {
+ super(name);
+ }
+
+ /**
+ * Test that a target with no existing object file is
+ * returned by getTargetsToBuildByConfiguration.
+ */
+ public void testGetTargetsToBuildByConfiguration1() {
+ CompilerConfiguration config1 = new CommandLineCompilerConfiguration(
+ (GccCCompiler) GccCCompiler.getInstance(), "dummy",
+ new File[0], new File[0], new File[0], "", new String[0],
+ new ProcessorParam[0], true, new String[0]);
+ TargetInfo target1 = new TargetInfo(config1, new File[] {new File(
+ "src/foo.bar")}
+ , null, new File("foo.obj"), true);
+ Hashtable targets = new Hashtable();
+ targets.put(target1.getOutput(), target1);
+ Hashtable targetsByConfig = CCTask
+ .getTargetsToBuildByConfiguration(targets);
+ Vector targetsForConfig1 = (Vector) targetsByConfig.get(config1);
+ assertNotNull(targetsForConfig1);
+ assertEquals(1, targetsForConfig1.size());
+ TargetInfo targetx = (TargetInfo) targetsForConfig1.elementAt(0);
+ assertSame(target1, targetx);
+ }
+
+ /**
+ * Test that a target that is up to date is not returned by
+ * getTargetsToBuildByConfiguration.
+ *
+ */
+ public void testGetTargetsToBuildByConfiguration2() {
+ CompilerConfiguration config1 = new CommandLineCompilerConfiguration(
+ (GccCCompiler) GccCCompiler.getInstance(), "dummy",
+ new File[0], new File[0], new File[0], "", new String[0],
+ new ProcessorParam[0], false, new String[0]);
+ //
+ // target doesn't need to be rebuilt
+ //
+ TargetInfo target1 = new TargetInfo(config1, new File[] {new File(
+ "src/foo.bar")}
+ , null, new File("foo.obj"), false);
+ Hashtable targets = new Hashtable();
+ targets.put(target1.getOutput(), target1);
+ //
+ // no targets need to be built, return a zero-length hashtable
+ //
+ Hashtable targetsByConfig = CCTask
+ .getTargetsToBuildByConfiguration(targets);
+ assertEquals(0, targetsByConfig.size());
+ }
+
+ /**
+ * Tests that the default value of failonerror is true.
+ */
+ public void testGetFailOnError() {
+ CCTask task = new CCTask();
+ boolean failOnError = task.getFailonerror();
+ assertEquals(true, failOnError);
+ }
+
+ /**
+ * Tests that setting failonerror is effective.
+ */
+ public void testSetFailOnError() {
+ CCTask task = new CCTask();
+ task.setFailonerror(false);
+ boolean failOnError = task.getFailonerror();
+ assertEquals(false, failOnError);
+ task.setFailonerror(true);
+ failOnError = task.getFailonerror();
+ assertEquals(true, failOnError);
+ }
+
+ /**
+ * Test checks for the presence of antlib.xml.
+ * @throws IOException if stream can't be closed.
+ *
+ */
+ public void testAntlibXmlPresent() throws IOException {
+ InputStream stream = TestCCTask.class.getClassLoader()
+ .getResourceAsStream("net/sf/antcontrib/cpptasks/antlib.xml");
+ if (stream != null) {
+ stream.close();
+ }
+ assertNotNull("antlib.xml missing", stream);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/TestCUtil.java b/test/junit/net/sf/antcontrib/cpptasks/TestCUtil.java
new file mode 100644
index 0000000..c15bf31
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/TestCUtil.java
@@ -0,0 +1,121 @@
+/*
+ *
+ * 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;
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+/**
+ * Tests for CUtil class
+ */
+public class TestCUtil extends TestCase {
+ public TestCUtil(String name) {
+ super(name);
+ }
+ public void testGetPathFromEnvironment() {
+ File[] files = CUtil.getPathFromEnvironment("LIB", ";");
+ assertNotNull(files);
+ }
+ public void testGetRelativePath1() throws IOException {
+ String canonicalBase = new File("/foo/bar/").getCanonicalPath();
+ String rel = CUtil.getRelativePath(canonicalBase, new File(
+ "/foo/bar/baz"));
+ assertEquals("baz", rel);
+ }
+ public void testGetRelativePath2() throws IOException {
+ String canonicalBase = new File("/foo/bar/").getCanonicalPath();
+ String rel = CUtil
+ .getRelativePath(canonicalBase, new File("/foo/bar/"));
+ assertEquals(".", rel);
+ }
+ public void testGetRelativePath3() throws IOException {
+ String canonicalBase = new File("/foo/bar/").getCanonicalPath();
+ String rel = CUtil.getRelativePath(canonicalBase,
+ new File("/foo/bar/a"));
+ assertEquals("a", rel);
+ }
+ public void testGetRelativePath4() throws IOException {
+ String canonicalBase = new File("/foo/bar/").getCanonicalPath();
+ String rel = CUtil.getRelativePath(canonicalBase, new File("/foo/"));
+ assertEquals("..", rel);
+ }
+ public void testGetRelativePath5() throws IOException {
+ String canonicalBase = new File("/foo/bar/").getCanonicalPath();
+ String rel = CUtil.getRelativePath(canonicalBase, new File("/a"));
+ String expected = ".." + File.separator + ".." + File.separator + "a";
+ assertEquals(expected, rel);
+ }
+ public void testGetRelativePath6() throws IOException {
+ String canonicalBase = new File("/foo/bar/").getCanonicalPath();
+ String rel = CUtil.getRelativePath(canonicalBase, new File(
+ "/foo/baz/bar"));
+ String expected = ".." + File.separator + "baz" + File.separator
+ + "bar";
+ assertEquals(expected, rel);
+ }
+ public void testGetRelativePath7() throws IOException {
+ String canonicalBase = new File("/foo/bar/").getCanonicalPath();
+ //
+ // skip the UNC test unless running on Windows
+ //
+ String osName = System.getProperty("os.name");
+ if (osName.indexOf("Windows") >= 0) {
+ File uncFile = new File("\\\\fred\\foo.bar");
+ String uncPath;
+ try {
+ uncPath = uncFile.getCanonicalPath();
+ } catch (IOException ex) {
+ uncPath = uncFile.toString();
+ }
+ String rel = CUtil.getRelativePath(canonicalBase, uncFile);
+ assertEquals(uncPath, rel);
+ }
+ }
+ public void testParsePath1() {
+ File[] files = CUtil.parsePath("", ";");
+ assertEquals(0, files.length);
+ }
+ public void testParsePath2() {
+ String workingDir = System.getProperty("user.dir");
+ File[] files = CUtil.parsePath(workingDir, ";");
+ assertEquals(1, files.length);
+ File workingDirFile = new File(workingDir);
+ assertEquals(workingDirFile, files[0]);
+ }
+ public void testParsePath3() {
+ String workingDir = System.getProperty("user.dir");
+ File[] files = CUtil.parsePath(workingDir + ";", ";");
+ assertEquals(1, files.length);
+ assertEquals(new File(workingDir), files[0]);
+ }
+ public void testParsePath4() {
+ String workingDir = System.getProperty("user.dir");
+ String javaHome = System.getProperty("java.home");
+ File[] files = CUtil.parsePath(workingDir + ";" + javaHome, ";");
+ assertEquals(2, files.length);
+ assertEquals(new File(workingDir), files[0]);
+ assertEquals(new File(javaHome), files[1]);
+ }
+ public void testParsePath5() {
+ String workingDir = System.getProperty("user.dir");
+ String javaHome = System.getProperty("java.home");
+ File[] files = CUtil.parsePath(workingDir + ";" + javaHome + ";", ";");
+ assertEquals(2, files.length);
+ assertEquals(new File(workingDir), files[0]);
+ assertEquals(new File(javaHome), files[1]);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/TestCompilerDef.java b/test/junit/net/sf/antcontrib/cpptasks/TestCompilerDef.java
new file mode 100644
index 0000000..c553756
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/TestCompilerDef.java
@@ -0,0 +1,357 @@
+/*
+ *
+ * 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;
+
+import java.io.File;
+import java.io.IOException;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.Compiler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioCCompiler;
+import net.sf.antcontrib.cpptasks.gcc.GccCCompiler;
+import net.sf.antcontrib.cpptasks.types.CompilerArgument;
+import net.sf.antcontrib.cpptasks.types.ConditionalPath;
+import net.sf.antcontrib.cpptasks.types.DefineArgument;
+import net.sf.antcontrib.cpptasks.types.DefineSet;
+import net.sf.antcontrib.cpptasks.types.IncludePath;
+import net.sf.antcontrib.cpptasks.types.SystemIncludePath;
+import net.sf.antcontrib.cpptasks.types.UndefineArgument;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * Tests for CompilerDef.
+ */
+public final class TestCompilerDef
+ extends TestProcessorDef {
+ /**
+ * Constructor.
+ *
+ * @param name
+ * test name
+ */
+ public TestCompilerDef(final String name) {
+ super(name);
+ }
+
+ /**
+ * Creates a new processor.
+ *
+ * @return new processor
+ */
+ protected ProcessorDef create() {
+ return new CompilerDef();
+ }
+
+ /**
+ * This method tests CompilerDef.getActiveDefines.
+ *
+ * A CompilerDef is created similar to what would be created for
+ *
+ * <cc><defineset><define name="DEBUG" if="debug"/> <define name="NDEBUG"
+ * unless="debug"/> </defineset> </cc>
+ *
+ * Then getActiveDefines is called for a project without and with the
+ * "debug" property defined. Return value from getActiveDefines should
+ * contain one member
+ */
+ public void testGetActiveDefines() {
+ Project project = new org.apache.tools.ant.Project();
+ CompilerDef def = new CompilerDef();
+ def.setProject(project);
+ DefineSet defset = new DefineSet();
+ DefineArgument arg1 = new DefineArgument();
+ arg1.setName("DEBUG");
+ arg1.setIf("debug");
+ defset.addDefine(arg1);
+ DefineArgument arg2 = new DefineArgument();
+ arg2.setName("NDEBUG");
+ arg2.setUnless("debug");
+ defset.addDefine(arg2);
+ def.addConfiguredDefineset(defset);
+ //
+ // Evaluate without "debug" set
+ //
+ UndefineArgument[] activeArgs = def.getActiveDefines();
+ assertEquals(1, activeArgs.length);
+ assertEquals("NDEBUG", activeArgs[0].getName());
+ //
+ // Set the "debug" property
+ //
+ project.setProperty("debug", "");
+ activeArgs = def.getActiveDefines();
+ assertEquals(1, activeArgs.length);
+ assertEquals("DEBUG", activeArgs[0].getName());
+ }
+
+ /**
+ * This method tests CompilerDef.getActiveIncludePath.
+ *
+ * A CompilerDef is created similar to what would be created for
+ *
+ * <cc><includepath location=".." if="debug"/> </cc>
+ *
+ * and is evaluate for a project without and without "debug" set
+ */
+ public void testGetActiveIncludePaths() {
+ Project project = new org.apache.tools.ant.Project();
+ CompilerDef def = new CompilerDef();
+ def.setProject(project);
+ ConditionalPath path = def.createIncludePath();
+ path.setLocation(new File(".."));
+ path.setIf("debug");
+ //
+ // Evaluate without "debug" set
+ //
+ String[] includePaths = def.getActiveIncludePaths();
+ assertEquals(0, includePaths.length);
+ //
+ // Set the "debug" property
+ //
+ project.setProperty("debug", "");
+ includePaths = def.getActiveIncludePaths();
+ assertEquals(1, includePaths.length);
+ }
+
+ /**
+ * Tests that setting classname to the Gcc compiler is effective.
+ */
+ public void testGetGcc() {
+ CompilerDef compilerDef = (CompilerDef) create();
+ compilerDef.setClassname("net.sf.antcontrib.cpptasks.gcc.GccCCompiler");
+ Compiler comp = (Compiler) compilerDef.getProcessor();
+ assertNotNull(comp);
+ assertSame(GccCCompiler.getInstance(), comp);
+ }
+
+ /**
+ * Tests that setting classname to the MSVC compiler is effective.
+ */
+ public void testGetMSVC() {
+ CompilerDef compilerDef = (CompilerDef) create();
+ compilerDef
+ .setClassname(
+ "net.sf.antcontrib.cpptasks.devstudio.DevStudioCCompiler");
+ Compiler comp = (Compiler) compilerDef.getProcessor();
+ assertNotNull(comp);
+ assertSame(DevStudioCCompiler.getInstance(), comp);
+ }
+
+ /**
+ * Tests that setting classname to an bogus class name results in a
+ * BuildException.
+ */
+ public void testUnknownClass() {
+ CompilerDef compilerDef = (CompilerDef) create();
+ try {
+ compilerDef
+ .setClassname("net.sf.antcontrib.cpptasks.bogus.BogusCompiler");
+ } catch (BuildException ex) {
+ return;
+ }
+ fail("Exception not thrown");
+ }
+
+ /**
+ * Test that setting classname to a class that doesn't support Compiler
+ * throws a BuildException.
+ *
+ */
+ public void testWrongType() {
+ CompilerDef compilerDef = (CompilerDef) create();
+ try {
+ compilerDef
+ .setClassname("net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker");
+ } catch (BuildException ex) {
+ return;
+ }
+ fail("Exception not thrown");
+ }
+
+ /**
+ * Gets the command line arguments that precede filenames.
+ *
+ * @param processor
+ * processor under test
+ * @return command line arguments
+ */
+ protected String[] getPreArguments(final ProcessorDef processor) {
+ return ((CommandLineCompilerConfiguration) getConfiguration(processor))
+ .getPreArguments();
+ }
+
+ /**
+ * Tests if a fileset enclosed in the base compiler definition is effective.
+ *
+ * @throws IOException
+ * if unable to create or delete a temporary file
+ */
+ public void testExtendsFileSet() throws IOException {
+ super.testExtendsFileSet(File.createTempFile("cpptaskstest", ".cpp"));
+ }
+
+ /**
+ * Tests if the rebuild attribute of the base compiler definition is
+ * effective.
+ *
+ */
+ public void testExtendsRebuild() {
+ testExtendsRebuild(new CompilerDef());
+ }
+
+ /**
+ * Tests that compilerarg's contained in the base compiler definition are
+ * effective.
+ */
+ public void testExtendsCompilerArgs() {
+ CompilerDef baseLinker = new CompilerDef();
+ CompilerArgument linkerArg = new CompilerArgument();
+ linkerArg.setValue("/base");
+ baseLinker.addConfiguredCompilerArg(linkerArg);
+ CompilerDef extendedLinker = (CompilerDef) createExtendedProcessorDef(
+ baseLinker);
+ String[] preArgs = getPreArguments(extendedLinker);
+ assertEquals(2, preArgs.length);
+ assertEquals("/base", preArgs[0]);
+ }
+
+ /**
+ * Tests that defineset's contained in the base compiler definition are
+ * effective.
+ */
+ public void testExtendsDefineSet() {
+ CompilerDef baseCompiler = new CompilerDef();
+ DefineSet defSet = new DefineSet();
+ DefineArgument define = new DefineArgument();
+ define.setName("foo");
+ define.setValue("bar");
+ defSet.addDefine(define);
+ baseCompiler.addConfiguredDefineset(defSet);
+ CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef(
+ baseCompiler);
+ String[] preArgs = getPreArguments(extendedCompiler);
+ assertEquals(2, preArgs.length);
+ assertEquals("-Dfoo=bar", preArgs[1]);
+ }
+
+ /**
+ * Tests that includepath's contained in the base compiler definition are
+ * effective.
+ */
+ public void testExtendsIncludePath() {
+ CompilerDef baseCompiler = new CompilerDef();
+ CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef(
+ baseCompiler);
+ IncludePath path = baseCompiler.createIncludePath();
+ path.setPath("/tmp");
+ String[] preArgs = getPreArguments(extendedCompiler);
+ assertEquals(2, preArgs.length);
+ assertEquals("-I", preArgs[1].substring(0, 2));
+ }
+
+ /**
+ * Tests that sysincludepath's contained in the base compiler definition are
+ * effective.
+ */
+ public void testExtendsSysIncludePath() {
+ CompilerDef baseCompiler = new CompilerDef();
+ CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef(
+ baseCompiler);
+ SystemIncludePath path = baseCompiler.createSysIncludePath();
+ path.setPath("/tmp");
+ String[] preArgs = getPreArguments(extendedCompiler);
+ assertEquals(2, preArgs.length);
+ assertEquals("-I", preArgs[1].substring(0, 2));
+ }
+
+ /**
+ * Sets the name attribute.
+ *
+ * @param compiler
+ * compiler under test
+ * @param name
+ * compiler name
+ */
+ private static void setCompilerName(final CompilerDef compiler,
+ final String name) {
+ CompilerEnum compilerName = new CompilerEnum();
+ compilerName.setValue(name);
+ compiler.setName(compilerName);
+ }
+
+ /**
+ * Tests that the extend attribute of the base compiler definition is
+ * effective.
+ */
+ public void testExtendsExceptions() {
+ CompilerDef baseCompiler = new CompilerDef();
+ baseCompiler.setExceptions(true);
+ CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef(
+ baseCompiler);
+ setCompilerName(extendedCompiler, "msvc");
+ String[] preArgs = getPreArguments(extendedCompiler);
+ assertEquals("/GX", preArgs[2]);
+ }
+
+ /**
+ * Tests that the multithread attribute of the base compiler definition is
+ * effective.
+ */
+ public void testExtendsMultithreaded() {
+ CompilerDef baseCompiler = new CompilerDef();
+ baseCompiler.setMultithreaded(false);
+ CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef(
+ baseCompiler);
+ setCompilerName(extendedCompiler, "msvc");
+ CCTask cctask = new CCTask();
+ LinkType linkType = new LinkType();
+ linkType.setStaticRuntime(true);
+ CommandLineCompilerConfiguration config = (CommandLineCompilerConfiguration)
+ extendedCompiler
+ .createConfiguration(cctask, linkType, null, null, null);
+ String[] preArgs = config.getPreArguments();
+ assertEquals("/ML", preArgs[3]);
+ }
+
+ /**
+ * Tests that the name attribute in the base compiler is effective.
+ */
+ public void testExtendsName() {
+ CompilerDef baseCompiler = new CompilerDef();
+ setCompilerName(baseCompiler, "msvc");
+ CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef(
+ baseCompiler);
+ extendedCompiler.setExceptions(true);
+ String[] preArgs = getPreArguments(extendedCompiler);
+ assertEquals("/GX", preArgs[2]);
+ }
+
+ /**
+ * Tests that the classname attribute in the base compiler is effective.
+ */
+ public void testExtendsClassname() {
+ CompilerDef baseCompiler = new CompilerDef();
+ baseCompiler
+ .setClassname(
+ "net.sf.antcontrib.cpptasks.devstudio.DevStudioCCompiler");
+ CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef(
+ baseCompiler);
+ extendedCompiler.setExceptions(true);
+ String[] preArgs = getPreArguments(extendedCompiler);
+ assertEquals("/GX", preArgs[2]);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/TestCompilerEnum.java b/test/junit/net/sf/antcontrib/cpptasks/TestCompilerEnum.java
new file mode 100644
index 0000000..6fc72ba
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/TestCompilerEnum.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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;
+import junit.framework.TestCase;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * Tests for CompilerEnum.
+ */
+public class TestCompilerEnum extends TestCase {
+ /**
+ * Create instance of TestCompilerEnum.
+ * @param name test name.
+ */
+ public TestCompilerEnum(final String name) {
+ super(name);
+ }
+ /**
+ * Test that "gcc" is recognized as a compiler enum.
+ */
+ public void testCompilerEnum1() {
+ CompilerEnum compilerEnum = new CompilerEnum();
+ compilerEnum.setValue("gcc");
+ assertTrue(compilerEnum.getIndex() >= 0);
+ }
+ /**
+ * Test that "bogus" is not recognized as a compiler enum.
+ */
+ public void testCompilerEnum2() {
+ CompilerEnum compilerEnum = new CompilerEnum();
+ try {
+ compilerEnum.setValue("bogus");
+ fail();
+ } catch (BuildException ex) {
+ }
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/TestDependencyTable.java b/test/junit/net/sf/antcontrib/cpptasks/TestDependencyTable.java
new file mode 100644
index 0000000..2a02a0b
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/TestDependencyTable.java
@@ -0,0 +1,79 @@
+/*
+ *
+ * Copyright 2003-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;
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.xml.sax.SAXException;
+/**
+ * DependencyTable tests
+ *
+ * @author curta
+ */
+public class TestDependencyTable extends TestXMLConsumer {
+ /**
+ * Default constructor
+ */
+ public TestDependencyTable() {
+ super();
+ }
+ /**
+ * Constructor
+ *
+ * @param testName
+ * test name
+ */
+ public TestDependencyTable(String testName) {
+ super(testName);
+ }
+ /**
+ * Loads a dependency file from OpenSHORE (http://www.openshore.org)
+ *
+ * @throws IOException
+ */
+ public void testLoadOpenshore() throws IOException,
+ ParserConfigurationException, SAXException {
+ String tmpDir = System.getProperty("java.io.tmpdir");
+ try {
+ copyResourceToTmpDir("files/openshore/dependencies.xml",
+ "dependencies.xml");
+ DependencyTable dependencies = new DependencyTable(new File(tmpDir));
+ dependencies.load();
+ } finally {
+ deleteTmpFile("dependencies.xml");
+ }
+ }
+ /**
+ * Loads a dependency file from Xerces-C (http://xml.apache.org)
+ *
+ * @throws IOException
+ */
+ public void testLoadXerces() throws IOException,
+ ParserConfigurationException, SAXException {
+ String tmpDir = System.getProperty("java.io.tmpdir");
+ try {
+ copyResourceToTmpDir("files/xerces-c/dependencies.xml",
+ "dependencies.xml");
+ DependencyTable dependencies = new DependencyTable(new File(tmpDir));
+ dependencies.load();
+ } finally {
+ deleteTmpFile("dependencies.xml");
+ }
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/TestLinkerDef.java b/test/junit/net/sf/antcontrib/cpptasks/TestLinkerDef.java
new file mode 100644
index 0000000..decd10a
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/TestLinkerDef.java
@@ -0,0 +1,323 @@
+/*
+ *
+ * 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;
+
+import java.io.File;
+import java.io.IOException;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker;
+import net.sf.antcontrib.cpptasks.gcc.GccLinker;
+import net.sf.antcontrib.cpptasks.types.FlexLong;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+import net.sf.antcontrib.cpptasks.types.LinkerArgument;
+import net.sf.antcontrib.cpptasks.types.SystemLibrarySet;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.FlexInteger;
+
+/**
+ * Tests for LinkerDef class.
+ */
+public final class TestLinkerDef
+ extends TestProcessorDef {
+ /**
+ * Constructor.
+ *
+ * @param name
+ * test name
+ */
+ public TestLinkerDef(final String name) {
+ super(name);
+ }
+
+ /**
+ * Creates a processor.
+ *
+ * @return new linker
+ */
+ protected ProcessorDef create() {
+ return new LinkerDef();
+ }
+
+ /**
+ * Test if setting the classname attribute to the name of the GCC linker
+ * results in the singleton GCC linker.
+ */
+ public void testGetGcc() {
+ LinkerDef linkerDef = (LinkerDef) create();
+ linkerDef.setClassname("net.sf.antcontrib.cpptasks.gcc.GccLinker");
+ Linker comp = (Linker) linkerDef.getProcessor();
+ assertNotNull(comp);
+ assertSame(GccLinker.getInstance(), comp);
+ }
+
+ /**
+ * Test if setting the classname attribute to the name of the MSVC linker
+ * results in the singleton MSVC linker.
+ */
+ public void testGetMSVC() {
+ LinkerDef linkerDef = (LinkerDef) create();
+ linkerDef
+ .setClassname("net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker");
+ Linker comp = (Linker) linkerDef.getProcessor();
+ assertNotNull(comp);
+ assertSame(DevStudioLinker.getInstance(), comp);
+ }
+
+ /**
+ * Tests if setting the classname attribute to an bogus classname results in
+ * a BuildException.
+ *
+ */
+ public void testUnknownClass() {
+ LinkerDef linkerDef = (LinkerDef) create();
+ try {
+ linkerDef
+ .setClassname("net.sf.antcontrib.cpptasks.bogus.BogusLinker");
+ } catch (BuildException ex) {
+ return;
+ }
+ fail("should have thrown exception");
+ }
+
+ /**
+ * Tests if setting the classname to the name of a class that doesn't
+ * support Linker throws a BuildException.
+ *
+ */
+ public void testWrongType() {
+ LinkerDef linkerDef = (LinkerDef) create();
+ try {
+ linkerDef.setClassname("net.sf.antcontrib.cpptasks.CCTask");
+ } catch (ClassCastException ex) {
+ return;
+ }
+ fail("should have thrown exception");
+ }
+
+ /**
+ * Gets the command line arguments that appear before the filenames.
+ *
+ * @param processor processor under test
+ * @return command line arguments
+ */
+ protected String[] getPreArguments(final ProcessorDef processor) {
+ return ((CommandLineLinkerConfiguration) getConfiguration(processor))
+ .getPreArguments();
+ }
+
+ /**
+ * Sets the name attribute.
+ *
+ * @param linker
+ * linker defintion
+ * @param name
+ * linker name
+ */
+ private static void setLinkerName(final LinkerDef linker,
+ final String name) {
+ LinkerEnum linkerName = new LinkerEnum();
+ linkerName.setValue(name);
+ linker.setName(linkerName);
+ }
+
+ /**
+ * Tests that linkerarg's that appear in the base linker are effective when
+ * creating the command line for a linker that extends it.
+ */
+ public void testExtendsLinkerArgs() {
+ LinkerDef baseLinker = new LinkerDef();
+ LinkerArgument linkerArg = new LinkerArgument();
+ linkerArg.setValue("/base");
+ baseLinker.addConfiguredLinkerArg(linkerArg);
+ LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef(
+ baseLinker);
+ String[] preArgs = getPreArguments(extendedLinker);
+ assertEquals(1, preArgs.length);
+ assertEquals("/base", preArgs[0]);
+ }
+
+ /**
+ * Tests that fileset's that appear in the base linker are effective when
+ * creating the command line for a linker that extends it.
+ * @throws IOException if unable to create or delete temporary file
+ */
+ public void testExtendsFileSet() throws IOException {
+ super.testExtendsFileSet(File.createTempFile("cpptaskstest", ".o"));
+ }
+
+ /**
+ * Tests that libset's that appear in the base linker are effective when
+ * creating the command line for a linker that extends it.
+ */
+ public void testExtendsLibSet() {
+ LinkerDef baseLinker = new LinkerDef();
+ LibrarySet libset = new LibrarySet();
+ LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef(
+ baseLinker);
+ libset.setProject(baseLinker.getProject());
+ CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("advapi32");
+ libset.setLibs(libs);
+ baseLinker.addLibset(libset);
+ CommandLineLinkerConfiguration config = (CommandLineLinkerConfiguration)
+ getConfiguration(extendedLinker);
+ String[] libnames = config.getLibraryNames();
+ assertEquals(1, libnames.length);
+ assertEquals("advapi32", libnames[0]);
+ }
+
+ /**
+ * Tests that syslibset's that appear in the base linker are effective when
+ * creating the command line for a linker that extends it.
+ */
+ public void testExtendsSysLibSet() {
+ LinkerDef baseLinker = new LinkerDef();
+ SystemLibrarySet libset = new SystemLibrarySet();
+ LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef(
+ baseLinker);
+ libset.setProject(baseLinker.getProject());
+ CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("advapi32");
+ libset.setLibs(libs);
+ baseLinker.addSyslibset(libset);
+ CommandLineLinkerConfiguration config = (CommandLineLinkerConfiguration)
+ getConfiguration(extendedLinker);
+ String[] libnames = config.getLibraryNames();
+ assertEquals(1, libnames.length);
+ assertEquals("advapi32", libnames[0]);
+ }
+
+ /**
+ * Tests that the base attribute in the base linker is effective when
+ * creating the command line for a linker that extends it.
+ */
+ public void testExtendsBase() {
+ LinkerDef baseLinker = new LinkerDef();
+ baseLinker.setBase(new FlexLong("10000"));
+ LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef(
+ baseLinker);
+ setLinkerName(extendedLinker, "msvc");
+ String[] preArgs = getPreArguments(extendedLinker);
+ assertEquals("/BASE:0x2710", preArgs[2]);
+ }
+
+ /**
+ * Tests that the stack attribute in the base linker is effective when
+ * creating the command line for a linker that extends it.
+ */
+ public void testExtendsStack() {
+ LinkerDef baseLinker = new LinkerDef();
+ baseLinker.setStack(new FlexInteger("10000"));
+ LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef(
+ baseLinker);
+ setLinkerName(extendedLinker, "msvc");
+ String[] preArgs = getPreArguments(extendedLinker);
+ assertEquals("/STACK:0x2710", preArgs[2]);
+ }
+
+ /**
+ * Tests that the entry attribute in the base linker is effective when
+ * creating the command line for a linker that extends it.
+ */
+ public void testExtendsEntry() {
+ LinkerDef baseLinker = new LinkerDef();
+ baseLinker.setEntry("foo");
+ LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef(
+ baseLinker);
+ String[] preArgs = getPreArguments(extendedLinker);
+ assertEquals("-e", preArgs[0]);
+ assertEquals("foo", preArgs[1]);
+ }
+
+ /**
+ * Tests that the fixed attribute in the base linker is effective when
+ * creating the command line for a linker that extends it.
+ */
+ public void testExtendsFixed() {
+ LinkerDef baseLinker = new LinkerDef();
+ baseLinker.setFixed(true);
+ LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef(
+ baseLinker);
+ setLinkerName(extendedLinker, "msvc");
+ String[] preArgs = getPreArguments(extendedLinker);
+ assertEquals("/FIXED", preArgs[2]);
+ }
+
+ /**
+ * Tests that the incremental attribute in the base linker is effective when
+ * creating the command line for a linker that extends it.
+ */
+ public void testExtendsIncremental() {
+ LinkerDef baseLinker = new LinkerDef();
+ baseLinker.setIncremental(true);
+ LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef(
+ baseLinker);
+ setLinkerName(extendedLinker, "msvc");
+ String[] preArgs = getPreArguments(extendedLinker);
+ assertEquals("/INCREMENTAL:YES", preArgs[1]);
+ }
+
+ /**
+ * Tests that the map attribute in the base linker is effective when
+ * creating the command line for a linker that extends it.
+ */
+ public void testExtendsMap() {
+ LinkerDef baseLinker = new LinkerDef();
+ baseLinker.setMap(true);
+ LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef(
+ baseLinker);
+ setLinkerName(extendedLinker, "msvc");
+ String[] preArgs = getPreArguments(extendedLinker);
+ assertEquals("/MAP", preArgs[2]);
+ }
+
+ /**
+ * Tests that the rebuild attribute in the base linker is effective when
+ * creating the command line for a linker that extends it.
+ */
+ public void testExtendsRebuild() {
+ testExtendsRebuild(new LinkerDef());
+ }
+
+ /**
+ * Tests that the name attribute in the base linker is effective when
+ * creating the command line for a linker that extends it.
+ */
+ public void testExtendsName() {
+ LinkerDef baseLinker = new LinkerDef();
+ setLinkerName(baseLinker, "msvc");
+ LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef(
+ baseLinker);
+ extendedLinker.setBase(new FlexLong("10000"));
+ String[] preArgs = getPreArguments(extendedLinker);
+ assertEquals("/BASE:0x2710", preArgs[2]);
+ }
+
+ /**
+ * Tests that the classname attribute in the base linker is effective when
+ * creating the command line for a linker that extends it.
+ */
+ public void testExtendsClassname() {
+ LinkerDef baseLinker = new LinkerDef();
+ baseLinker
+ .setClassname("net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker");
+ LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef(
+ baseLinker);
+ extendedLinker.setBase(new FlexLong("10000"));
+ String[] preArgs = getPreArguments(extendedLinker);
+ assertEquals("/BASE:0x2710", preArgs[2]);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/TestLinkerEnum.java b/test/junit/net/sf/antcontrib/cpptasks/TestLinkerEnum.java
new file mode 100644
index 0000000..77158d7
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/TestLinkerEnum.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * Copyright 2003-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;
+import junit.framework.TestCase;
+/**
+ *
+ * Tests for LinkerEnum
+ *
+ * @author CurtA
+ */
+public class TestLinkerEnum extends TestCase {
+ /**
+ * @param test
+ * case name
+ */
+ public TestLinkerEnum(String name) {
+ super(name);
+ }
+ /**
+ * Test checks that enumeration contains value g++
+ *
+ * See patch [ 676276 ] Enhanced support for Mac OS X
+ */
+ public void testContainsValueGpp() {
+ assertTrue(new LinkerEnum().containsValue("g++"));
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/TestOutputTypeEnum.java b/test/junit/net/sf/antcontrib/cpptasks/TestOutputTypeEnum.java
new file mode 100644
index 0000000..61bb2b7
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/TestOutputTypeEnum.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * Copyright 2003-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;
+import junit.framework.TestCase;
+/**
+ * @author CurtA
+ */
+public class TestOutputTypeEnum extends TestCase {
+ /**
+ * Default constructor
+ *
+ * @see junit.framework.TestCase#TestCase(String)
+ */
+ public TestOutputTypeEnum(String name) {
+ super(name);
+ }
+ /**
+ * Test checks that output type enum contains "plugin"
+ *
+ * See patch [ 676276 ] Enhanced support for Mac OS X
+ */
+ public void testContainsValuePlugin() {
+ assertTrue(new OutputTypeEnum().containsValue("plugin"));
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/TestProcessorDef.java b/test/junit/net/sf/antcontrib/cpptasks/TestProcessorDef.java
new file mode 100644
index 0000000..c4e2905
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/TestProcessorDef.java
@@ -0,0 +1,278 @@
+/*
+ *
+ * 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;
+
+import java.io.File;
+import java.io.IOException;
+import junit.framework.TestCase;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;
+import net.sf.antcontrib.cpptasks.types.ConditionalFileSet;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.Reference;
+
+/**
+ * Tests for ProcessorDef.
+ */
+public abstract class TestProcessorDef
+ extends TestCase {
+
+ /**
+ * Constructor.
+ *
+ * @param name
+ * test name
+ */
+ public TestProcessorDef(final String name) {
+ super(name);
+ }
+
+ /**
+ * Creates a new processor definition.
+ *
+ * @return created processor definition
+ */
+ protected abstract ProcessorDef create();
+
+ /**
+ * Tests that isActive returns true when "if" references a set property.
+ */
+ public final void testIsActive2() {
+ ProcessorDef arg = create();
+ Project project = new Project();
+ project.setProperty("cond", "");
+ arg.setProject(project);
+ arg.setIf("cond");
+ assertTrue(arg.isActive());
+ }
+
+ /**
+ * Tests that isActive returns false when "if" references an unset property.
+ */
+ public final void testIsActive3() {
+ ProcessorDef arg = create();
+ arg.setProject(new Project());
+ arg.setIf("cond");
+ assertTrue(!arg.isActive());
+ }
+
+ /**
+ * Tests that evaluating isActive when "if" refernces a property with the
+ * value "false" throws an exception to warn of a suspicious value.
+ *
+ */
+ public final void testIsActive4() {
+ ProcessorDef arg = create();
+ Project project = new Project();
+ project.setProperty("cond", "false");
+ arg.setProject(project);
+ arg.setIf("cond");
+ try {
+ boolean isActive = arg.isActive();
+ } catch (BuildException ex) {
+ return;
+ }
+ fail("Should throw exception for suspicious value");
+ }
+
+ /**
+ * Tests that isActive returns false when "unless" references a set
+ * property.
+ */
+ public final void testIsActive5() {
+ ProcessorDef arg = create();
+ Project project = new Project();
+ project.setProperty("cond", "");
+ arg.setProject(project);
+ arg.setUnless("cond");
+ assertTrue(!arg.isActive());
+ }
+
+ /**
+ * Tests that isActive returns true when "unless" references an unset
+ * property.
+ */
+ public final void testIsActive6() {
+ ProcessorDef arg = create();
+ arg.setProject(new Project());
+ arg.setUnless("cond");
+ assertTrue(arg.isActive());
+ }
+
+ /**
+ * Tests that evaluating isActive when "unless" references a property with
+ * the value "false" throws an exception to warn of a suspicious value.
+ *
+ */
+ public final void testIsActive7() {
+ ProcessorDef arg = create();
+ Project project = new Project();
+ project.setProperty("cond", "false");
+ arg.setProject(project);
+ arg.setUnless("cond");
+ try {
+ boolean isActive = arg.isActive();
+ } catch (BuildException ex) {
+ return;
+ }
+ fail("Should throw exception for suspicious value");
+ }
+
+ /**
+ * Tests if a processor is active when both "if" and "unless" are specified
+ * and the associated properties are set.
+ *
+ */
+ public final void testIsActive8() {
+ ProcessorDef arg = create();
+ Project project = new Project();
+ project.setProperty("cond", "");
+ arg.setProject(project);
+ arg.setIf("cond");
+ arg.setUnless("cond");
+ assertTrue(!arg.isActive());
+ }
+
+ /**
+ * Creates a processor initialized to be an extension of the base processor.
+ *
+ * @param baseProcessor
+ * base processor
+ * @return extending processor
+ */
+ protected final ProcessorDef createExtendedProcessorDef(
+ final ProcessorDef baseProcessor) {
+ Project project = new Project();
+ baseProcessor.setProject(project);
+ baseProcessor.setId("base");
+ project.addReference("base", baseProcessor);
+ ProcessorDef extendedLinker = create();
+ extendedLinker.setProject(project);
+ extendedLinker.setExtends(new Reference("base"));
+ return extendedLinker;
+ }
+
+ /**
+ * Gets the processor configuration.
+ *
+ * @param extendedProcessor
+ * processor under test
+ * @return configuration
+ */
+ protected final ProcessorConfiguration getConfiguration(
+ final ProcessorDef extendedProcessor) {
+ CCTask cctask = new CCTask();
+ LinkType linkType = new LinkType();
+ return extendedProcessor.createConfiguration(cctask,
+ linkType,
+ null,
+ null,
+ null);
+ }
+
+ /**
+ * Gets command line arguments that precede filenames.
+ *
+ * @param processor
+ * processor under test
+ * @return array of command line parameters
+ */
+ protected abstract String[] getPreArguments(final ProcessorDef processor);
+
+ /**
+ * Tests that a fileset in the base processor is effective when evaluating
+ * the files included in an extending processor.
+ *
+ * @param tempFile
+ * temporary file
+ * @throws IOException
+ * if unable to delete file
+ */
+ protected final void testExtendsFileSet(final File tempFile) throws
+ IOException {
+ ProcessorDef baseLinker = create();
+ ConditionalFileSet fileSet = new ConditionalFileSet();
+ ProcessorDef extendedLinker = createExtendedProcessorDef(baseLinker);
+ fileSet.setProject(baseLinker.getProject());
+ fileSet.setDir(new File(tempFile.getParent()));
+ fileSet.setIncludes(tempFile.getName());
+ baseLinker.addFileset(fileSet);
+ MockFileCollector collector = new MockFileCollector();
+ extendedLinker.visitFiles(collector);
+ tempFile.delete();
+ assertEquals(1, collector.size());
+ }
+
+ /**
+ * Tests that the if attribute in the base processor is effective when
+ * evaluating if an extending processor is active.
+ */
+ public final void testExtendsIf() {
+ ProcessorDef baseLinker = create();
+ baseLinker.setIf("bogus");
+ ProcessorDef extendedLinker = createExtendedProcessorDef(baseLinker);
+ boolean isActive = extendedLinker.isActive();
+ assertEquals(false, isActive);
+ baseLinker.getProject().setProperty("bogus", "");
+ isActive = extendedLinker.isActive();
+ assertEquals(true, isActive);
+ }
+
+ /**
+ * Tests that the unless attribute in the base processor is effective when
+ * evaluating if an extending processor is active.
+ */
+ public final void testExtendsUnless() {
+ ProcessorDef baseLinker = create();
+ baseLinker.setUnless("bogus");
+ ProcessorDef extendedLinker = createExtendedProcessorDef(baseLinker);
+ boolean isActive = extendedLinker.isActive();
+ assertEquals(true, isActive);
+ baseLinker.getProject().setProperty("bogus", "");
+ isActive = extendedLinker.isActive();
+ assertEquals(false, isActive);
+ }
+
+ /**
+ * Tests that the debug attribute in the base processor is effective when
+ * creating the command line for a processor that extends it.
+ */
+ public final void testExtendsDebug() {
+ ProcessorDef baseLinker = create();
+ baseLinker.setDebug(true);
+ ProcessorDef extendedLinker = createExtendedProcessorDef(baseLinker);
+ String[] preArgs = getPreArguments(extendedLinker);
+ assertEquals("-g", preArgs[preArgs.length - 1]);
+ }
+
+ /**
+ * Tests that the rebuild attribute in the base processor is effective when
+ * creating the command line for a processor that extends it.
+ *
+ * @param baseProcessor
+ * processor under test
+ */
+ protected final void testExtendsRebuild(
+ final ProcessorDef baseProcessor) {
+ baseProcessor.setRebuild(true);
+ ProcessorDef extendedLinker = createExtendedProcessorDef(baseProcessor);
+ ProcessorConfiguration config = getConfiguration(extendedLinker);
+ boolean rebuild = config.getRebuild();
+ assertEquals(true, rebuild);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/TestTargetHistoryTable.java b/test/junit/net/sf/antcontrib/cpptasks/TestTargetHistoryTable.java
new file mode 100644
index 0000000..1b3a656
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/TestTargetHistoryTable.java
@@ -0,0 +1,141 @@
+/*
+ *
+ * Copyright 2003-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;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;
+import net.sf.antcontrib.cpptasks.VersionInfo;
+/**
+ * Tests for TargetHistoryTable
+ *
+ * @author CurtA
+ */
+public class TestTargetHistoryTable extends TestXMLConsumer {
+ private static class MockProcessorConfiguration
+ implements
+ ProcessorConfiguration {
+ public MockProcessorConfiguration() {
+ }
+ public int bid(String fileName) {
+ return 100;
+ }
+ public String getIdentifier() {
+ return "Mock Configuration";
+ }
+ public String[] getOutputFileNames(String baseName, VersionInfo versionInfo) {
+ return new String[] { baseName };
+ }
+ public ProcessorParam[] getParams() {
+ return new ProcessorParam[0];
+ }
+ public boolean getRebuild() {
+ return false;
+ }
+ }
+ /**
+ * Constructor
+ *
+ * @param name
+ * test case name
+ * @see junit.framework.TestCase#TestCase(String)
+ */
+ public TestTargetHistoryTable(String name) {
+ super(name);
+ }
+ /**
+ * Tests loading a stock history file
+ *
+ * @throws IOException
+ */
+ public void testLoadOpenshore() throws IOException {
+ try {
+ copyResourceToTmpDir("files/openshore/history.xml", "history.xml");
+ CCTask task = new CCTask();
+ String tmpDir = System.getProperty("java.io.tmpdir");
+ TargetHistoryTable history = new TargetHistoryTable(task, new File(
+ tmpDir));
+ } finally {
+ deleteTmpFile("history.xml");
+ }
+ }
+ /**
+ * Tests loading a stock history file
+ *
+ * @throws IOException
+ */
+ public void testLoadXerces() throws IOException {
+ try {
+ copyResourceToTmpDir("files/xerces-c/history.xml", "history.xml");
+ CCTask task = new CCTask();
+ String tmpDir = System.getProperty("java.io.tmpdir");
+ TargetHistoryTable history = new TargetHistoryTable(task, new File(
+ tmpDir));
+ } finally {
+ deleteTmpFile("history.xml");
+ }
+ }
+ /**
+ * Tests for bug fixed by patch [ 650397 ] Fix: Needless rebuilds on Unix
+ *
+ * @throws IOException
+ */
+ public void testUpdateTimeResolution() throws IOException {
+ File compiledFile = null;
+ try {
+ //
+ // delete any history file that might exist
+ // in the test output directory
+ String tempDir = System.getProperty("java.io.tmpdir");
+ File historyFile = new File(tempDir, "history.xml");
+ if (historyFile.exists()) {
+ historyFile.delete();
+ }
+ TargetHistoryTable table = new TargetHistoryTable(null, new File(
+ tempDir));
+ //
+ // create a dummy compiled unit
+ //
+ compiledFile = new File(tempDir, "dummy.o");
+ FileOutputStream compiledStream = new FileOutputStream(compiledFile);
+ compiledStream.close();
+ //
+ // lastModified times can be slightly less than
+ // task start time due to file system resolution.
+ // Mimic this by slightly incrementing the last modification time.
+ //
+ long startTime = compiledFile.lastModified() + 1;
+ //
+ // update the table
+ //
+ table.update(new MockProcessorConfiguration(),
+ new String[]{"dummy.o"}, null);
+ //
+ // commit. If "compiled" file was judged to be
+ // valid we should have a history file.
+ //
+ table.commit();
+ assertTrue("History file was not created", historyFile.exists());
+ assertTrue("History file was empty", historyFile.length() > 10);
+ } finally {
+ if (compiledFile != null && compiledFile.exists()) {
+ compiledFile.delete();
+ }
+ }
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/TestTargetInfo.java b/test/junit/net/sf/antcontrib/cpptasks/TestTargetInfo.java
new file mode 100644
index 0000000..5851805
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/TestTargetInfo.java
@@ -0,0 +1,134 @@
+/*
+ *
+ * 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;
+import java.io.File;
+import junit.framework.TestCase;
+import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.ProgressMonitor;
+import org.apache.tools.ant.BuildException;
+import net.sf.antcontrib.cpptasks.VersionInfo;
+
+
+/**
+ * A description of a file built or to be built
+ */
+public class TestTargetInfo extends TestCase {
+ private class DummyConfiguration implements CompilerConfiguration {
+ public int bid(String filename) {
+ return 1;
+ }
+ public void close() {
+ }
+ public void compile(CCTask task, File workingDir, String[] source,
+ boolean relentless, ProgressMonitor monitor)
+ throws BuildException {
+ throw new BuildException("Not implemented");
+ }
+ public CompilerConfiguration[] createPrecompileConfigurations(
+ File file, String[] exceptFiles) {
+ return null;
+ }
+ public String getIdentifier() {
+ return "dummy";
+ }
+ public String[] getIncludeDirectories() {
+ return new String[0];
+ }
+ public String getIncludePathIdentifier() {
+ return "dummyIncludePath";
+ }
+ public String[] getOutputFileNames(String inputFile, VersionInfo versionInfo) {
+ return new String[0];
+ }
+ public CompilerParam getParam(String name) {
+ return null;
+ }
+ public ProcessorParam[] getParams() {
+ return new ProcessorParam[0];
+ }
+ public boolean getRebuild() {
+ return false;
+ }
+ public boolean isPrecompileGeneration() {
+ return true;
+ }
+ public DependencyInfo parseIncludes(CCTask task, File baseDir, File file) {
+ return null;
+ }
+ }
+ public TestTargetInfo(String name) {
+ super(name);
+ }
+ public void testConstructorNullConfig() {
+ try {
+ new TargetInfo(null, new File[]{new File("")}, null, new File(""),
+ false);
+ fail("Didn't throw exception");
+ } catch (NullPointerException ex) {
+ }
+ }
+ public void testConstructorNullOutput() {
+ CompilerConfiguration config = new DummyConfiguration();
+ try {
+ new TargetInfo(config, new File[]{new File("")}, null, null, false);
+ fail("Didn't throw exception");
+ } catch (NullPointerException ex) {
+ }
+ }
+ public void testConstructorNullSource() {
+ CompilerConfiguration config = new DummyConfiguration();
+ try {
+ new TargetInfo(config, null, null, new File(""), false);
+ fail("Didn't throw exception");
+ } catch (NullPointerException ex) {
+ }
+ }
+ public void testGetRebuild() {
+ CompilerConfiguration config = new DummyConfiguration();
+ TargetInfo targetInfo = new TargetInfo(config, new File[]{new File(
+ "FoO.BaR")}, null, new File("foo.o"), false);
+ assertEquals(false, targetInfo.getRebuild());
+ targetInfo = new TargetInfo(config, new File[]{new File("FoO.BaR")},
+ null, new File("foo.o"), true);
+ assertEquals(true, targetInfo.getRebuild());
+ }
+ public void testGetSource() {
+ CompilerConfiguration config = new DummyConfiguration();
+ TargetInfo targetInfo = new TargetInfo(config, new File[]{new File(
+ "FoO.BaR")}, null, new File("foo.o"), false);
+ String source = targetInfo.getSources()[0].getName();
+ assertEquals(source, "FoO.BaR");
+ }
+ public void testHasSameSource() {
+ CompilerConfiguration config = new DummyConfiguration();
+ TargetInfo targetInfo = new TargetInfo(config, new File[]{new File(
+ "foo.bar")}, null, new File("foo.o"), false);
+ boolean hasSame = targetInfo.getSources()[0]
+ .equals(new File("foo.bar"));
+ assertTrue(hasSame);
+ hasSame = targetInfo.getSources()[0].equals(new File("boo.far"));
+ assertEquals(hasSame, false);
+ }
+ public void testMustRebuild() {
+ CompilerConfiguration config = new DummyConfiguration();
+ TargetInfo targetInfo = new TargetInfo(config, new File[]{new File(
+ "FoO.BaR")}, null, new File("foo.o"), false);
+ assertEquals(false, targetInfo.getRebuild());
+ targetInfo.mustRebuild();
+ assertEquals(true, targetInfo.getRebuild());
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/TestXMLConsumer.java b/test/junit/net/sf/antcontrib/cpptasks/TestXMLConsumer.java
new file mode 100644
index 0000000..7c8c86f
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/TestXMLConsumer.java
@@ -0,0 +1,100 @@
+/*
+ *
+ * Copyright 2003-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;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+/**
+ * Base class for tests on classes that consume or public XML documents.
+ *
+ * @author Curt Arnold
+ *
+ */
+public class TestXMLConsumer extends TestCase {
+ /**
+ * Loads a TargetHistoryTable from a resource
+ *
+ * @param resourceName
+ * resouce name, such as "files/openshore/history.xml".
+ * @return TargetHistoryTable
+ */
+ public static final void copyResourceToTmpDir(String resourceName,
+ String tmpFile) throws IOException {
+ String tmpDir = System.getProperty("java.io.tmpdir");
+ //
+ // attempt to get resource from jar
+ // (should succeed unless testing in IDE)
+ InputStream src = null;
+ if (TestTargetHistoryTable.class.getClassLoader().getResource(
+ resourceName) != null) {
+ src = TestTargetHistoryTable.class.getClassLoader()
+ .getResourceAsStream(resourceName);
+ }
+ //
+ // if not found, try to find it relative to the current directory
+ //
+ if (src == null) {
+ src = new FileInputStream(resourceName);
+ }
+ assertNotNull("Could not locate resource " + resourceName, src);
+ try {
+ File destFile = new File(tmpDir, tmpFile);
+ FileOutputStream dest = new FileOutputStream(destFile);
+ try {
+ int bytesRead = 0;
+ byte[] buffer = new byte[4096];
+ do {
+ bytesRead = src.read(buffer);
+ if (bytesRead > 0) {
+ dest.write(buffer, 0, bytesRead);
+ }
+ } while (bytesRead == buffer.length);
+ } finally {
+ dest.close();
+ }
+ } finally {
+ src.close();
+ }
+ }
+ /**
+ * Deletes a file, if it exists, from the user's temporary directory.
+ *
+ * @param tmpName
+ * file name, may not be null
+ */
+ public static void deleteTmpFile(String tmpName) throws IOException {
+ String tmpDir = System.getProperty("java.io.tmpdir");
+ File tmpFile = new File(tmpDir, tmpName);
+ if (tmpFile.exists()) {
+ tmpFile.delete();
+ }
+ }
+ /**
+ * @param arg0
+ */
+ protected TestXMLConsumer(String testName) {
+ super(testName);
+ }
+
+ protected TestXMLConsumer() {
+ super("TestXMLConsumer");
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/borland/CVS/Entries b/test/junit/net/sf/antcontrib/cpptasks/borland/CVS/Entries
new file mode 100644
index 0000000..67679a7
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/borland/CVS/Entries
@@ -0,0 +1,2 @@
+/TestBorlandCCompiler.java/1.4/Sat Feb 28 19:04:47 2004/-ko/
+D
diff --git a/test/junit/net/sf/antcontrib/cpptasks/borland/CVS/Repository b/test/junit/net/sf/antcontrib/cpptasks/borland/CVS/Repository
new file mode 100644
index 0000000..f147a09
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/borland/CVS/Repository
@@ -0,0 +1 @@
+cpptasks/test/junit/net/sf/antcontrib/cpptasks/borland
diff --git a/test/junit/net/sf/antcontrib/cpptasks/borland/CVS/Root b/test/junit/net/sf/antcontrib/cpptasks/borland/CVS/Root
new file mode 100644
index 0000000..1ac95cd
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/borland/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ant-contrib
diff --git a/test/junit/net/sf/antcontrib/cpptasks/borland/TestBorlandCCompiler.java b/test/junit/net/sf/antcontrib/cpptasks/borland/TestBorlandCCompiler.java
new file mode 100644
index 0000000..ddafc5e
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/borland/TestBorlandCCompiler.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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.borland;
+import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor;
+import net.sf.antcontrib.cpptasks.compiler.TestAbstractCompiler;
+/**
+ * Borland C++ Compiler adapter tests
+ *
+ * Override create to test concrete compiler implementions
+ */
+public class TestBorlandCCompiler extends TestAbstractCompiler {
+ public TestBorlandCCompiler(String name) {
+ super(name);
+ }
+ protected AbstractProcessor create() {
+ return BorlandCCompiler.getInstance();
+ }
+ protected String getObjectExtension() {
+ return ".obj";
+ }
+ public void testGetIdentfier() {
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/compiler/CVS/Entries b/test/junit/net/sf/antcontrib/cpptasks/compiler/CVS/Entries
new file mode 100644
index 0000000..07eeda9
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/compiler/CVS/Entries
@@ -0,0 +1,7 @@
+/TestAbstractCompiler.java/1.21/Tue May 11 03:50:12 2004//
+/TestAbstractLinker.java/1.20/Tue May 11 03:50:13 2004//
+/TestAbstractProcessor.java/1.17/Tue May 11 03:50:12 2004//
+/TestCommandLineCompilerConfiguration.java/1.10/Sat Feb 28 19:04:47 2004//
+/TestCompilerConfiguration.java/1.9/Tue May 11 03:50:13 2004//
+/TestLinkType.java/1.2/Sat Feb 28 19:04:47 2004//
+D
diff --git a/test/junit/net/sf/antcontrib/cpptasks/compiler/CVS/Repository b/test/junit/net/sf/antcontrib/cpptasks/compiler/CVS/Repository
new file mode 100644
index 0000000..43e8cff
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/compiler/CVS/Repository
@@ -0,0 +1 @@
+cpptasks/test/junit/net/sf/antcontrib/cpptasks/compiler
diff --git a/test/junit/net/sf/antcontrib/cpptasks/compiler/CVS/Root b/test/junit/net/sf/antcontrib/cpptasks/compiler/CVS/Root
new file mode 100644
index 0000000..1ac95cd
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/compiler/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ant-contrib
diff --git a/test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractCompiler.java b/test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractCompiler.java
new file mode 100644
index 0000000..5a1e66b
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractCompiler.java
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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.compiler;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CompilerDef;
+import net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.parser.CParser;
+import net.sf.antcontrib.cpptasks.parser.Parser;
+import net.sf.antcontrib.cpptasks.VersionInfo;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * Test for abstract compiler class
+ *
+ * Override create to test concrete compiler implementions
+ */
+public class TestAbstractCompiler extends TestAbstractProcessor {
+ private class DummyAbstractCompiler extends AbstractCompiler {
+ public DummyAbstractCompiler() {
+ super(new String[]{".cpp", ".c"},
+ new String[]{".hpp", ".h", ".inl"}, ".o");
+ }
+ public void compile(CCTask task, File[] srcfile, File[] outputfile,
+ CompilerConfiguration config) throws BuildException {
+ throw new BuildException("Not implemented");
+ }
+ public CompilerConfiguration createConfiguration(CCTask task,
+ LinkType linkType, ProcessorDef[] def1, CompilerDef def2,
+ net.sf.antcontrib.cpptasks.TargetDef targetPlatform,
+ VersionInfo versionInfo) {
+ return null;
+ }
+ public Parser createParser(File file) {
+ return new CParser();
+ }
+ public String getIdentifier() {
+ return "dummy";
+ }
+ public Linker getLinker(LinkType type) {
+ return null;
+ }
+ }
+ public TestAbstractCompiler(String name) {
+ super(name);
+ }
+ protected AbstractProcessor create() {
+ return new DummyAbstractCompiler();
+ }
+ protected String getObjectExtension() {
+ return ".o";
+ }
+ public void testCanParseTlb() {
+ AbstractCompiler compiler = (AbstractCompiler) create();
+ assertEquals(false, compiler.canParse(new File("sample.tlb")));
+ }
+ public void testGetOutputFileName1() {
+ AbstractProcessor compiler = create();
+ String[] output = compiler.getOutputFileNames("c:/foo\\bar\\hello.c", null);
+ assertEquals("hello" + getObjectExtension(), output[0]);
+ output = compiler.getOutputFileNames("c:/foo\\bar/hello.c", null);
+ assertEquals("hello" + getObjectExtension(), output[0]);
+ output = compiler.getOutputFileNames("hello.c", null);
+ assertEquals("hello" + getObjectExtension(), output[0]);
+ output = compiler.getOutputFileNames("c:/foo\\bar\\hello.h", null);
+ assertEquals(0, output.length);
+ output = compiler.getOutputFileNames("c:/foo\\bar/hello.h", null);
+ assertEquals(0, output.length);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractLinker.java b/test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractLinker.java
new file mode 100644
index 0000000..b444a0a
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractLinker.java
@@ -0,0 +1,89 @@
+/*
+ *
+ * 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.compiler;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.LinkerDef;
+import net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+import net.sf.antcontrib.cpptasks.TargetDef;
+import net.sf.antcontrib.cpptasks.VersionInfo;
+
+/**
+ * Test for abstract compiler class
+ *
+ * Override create to test concrete compiler implementions
+ */
+public class TestAbstractLinker extends TestAbstractProcessor {
+ private class DummyAbstractLinker extends AbstractLinker {
+ public DummyAbstractLinker() {
+ super(new String[]{".obj", ".lib"}, new String[]{".map", ".exp"});
+ }
+ public LinkerConfiguration createConfiguration(final CCTask task,
+ final LinkType linkType,
+ final ProcessorDef[] def1,
+ final LinkerDef def2,
+ final TargetDef targetPlatform,
+ final VersionInfo versionInfo) {
+ return null;
+ }
+ public String getIdentifier() {
+ return "dummy";
+ }
+ public File[] getLibraryPath() {
+ return new File[0];
+ }
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ return libnames;
+ }
+ public Linker getLinker(LinkType type) {
+ return null;
+ }
+ public String[] getOutputFileNames(String sourceFile, VersionInfo versionInfo) {
+ return new String[0];
+ }
+ public String[][] getRuntimeLibraries(boolean debug,
+ boolean multithreaded, boolean staticLink) {
+ return new String[2][0];
+ }
+ public boolean isCaseSensitive() {
+ return true;
+ }
+ }
+ public TestAbstractLinker(String name) {
+ super(name);
+ }
+ protected AbstractProcessor create() {
+ return new DummyAbstractLinker();
+ }
+ public void testBid() {
+ AbstractProcessor compiler = create();
+ int bid = compiler.bid("c:/foo\\bar\\hello.obj");
+ assertEquals(100, bid);
+ bid = compiler.bid("c:/foo\\bar/hello.lib");
+ assertEquals(100, bid);
+ bid = compiler.bid("c:/foo\\bar\\hello.map");
+ assertEquals(0, bid);
+ bid = compiler.bid("c:/foo\\bar/hello.map");
+ assertEquals(0, bid);
+ bid = compiler.bid("c:/foo\\bar/hello.c");
+ assertEquals(1, bid);
+ bid = compiler.bid("c:/foo\\bar/hello.cpp");
+ assertEquals(1, bid);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractProcessor.java b/test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractProcessor.java
new file mode 100644
index 0000000..f2c04a3
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractProcessor.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.compiler;
+import junit.framework.TestCase;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.VersionInfo;
+/**
+ * Test for abstract compiler class
+ *
+ * Override create to test concrete compiler implementions
+ */
+public class TestAbstractProcessor extends TestCase {
+ private class DummyAbstractProcessor extends AbstractProcessor {
+ public DummyAbstractProcessor() {
+ super(new String[]{".cpp", ".c"},
+ new String[]{".hpp", ".h", ".inl"});
+ }
+ public ProcessorConfiguration createConfiguration(CCTask task,
+ LinkType linkType, ProcessorDef[] defaultProvider,
+ ProcessorDef specificProvider,
+ net.sf.antcontrib.cpptasks.TargetDef targetPlatform,
+ VersionInfo versionInfo) {
+ return null;
+ }
+ public String getIdentifier() {
+ return "dummy";
+ }
+ public Linker getLinker(LinkType type) {
+ return null;
+ }
+ public String[] getOutputFileNames(String sourceFile, VersionInfo versionInfo) {
+ return new String[0];
+ }
+ public String[][] getRuntimeLibraries(boolean debug,
+ boolean multithreaded, boolean staticLink) {
+ return new String[2][0];
+ }
+ }
+ public TestAbstractProcessor(String name) {
+ super(name);
+ }
+ protected AbstractProcessor create() {
+ return new DummyAbstractProcessor();
+ }
+ public void testBid() {
+ AbstractProcessor compiler = create();
+ int bid = compiler.bid("c:/foo\\bar\\hello.c");
+ assertEquals(100, bid);
+ bid = compiler.bid("c:/foo\\bar/hello.c");
+ assertEquals(100, bid);
+ bid = compiler.bid("c:/foo\\bar\\hello.h");
+ assertEquals(1, bid);
+ bid = compiler.bid("c:/foo\\bar/hello.h");
+ assertEquals(1, bid);
+ bid = compiler.bid("c:/foo\\bar/hello.pas");
+ assertEquals(0, bid);
+ bid = compiler.bid("c:/foo\\bar/hello.java");
+ assertEquals(0, bid);
+ }
+ public void testGetIdentfier() {
+ AbstractProcessor compiler = create();
+ String id = compiler.getIdentifier();
+ assertEquals("dummy", id);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/compiler/TestCommandLineCompilerConfiguration.java b/test/junit/net/sf/antcontrib/cpptasks/compiler/TestCommandLineCompilerConfiguration.java
new file mode 100644
index 0000000..a22fa0d
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/compiler/TestCommandLineCompilerConfiguration.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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.compiler;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.ProcessorParam;
+import net.sf.antcontrib.cpptasks.gcc.GccCCompiler;
+/**
+ */
+public class TestCommandLineCompilerConfiguration
+ extends
+ TestCompilerConfiguration {
+ private final CommandLineCompiler compiler;
+ private final String compilerId;
+ public TestCommandLineCompilerConfiguration(String name) {
+ super(name);
+ compiler = (GccCCompiler) GccCCompiler.getInstance();
+ compilerId = compiler.getIdentifier();
+ }
+ protected CompilerConfiguration create() {
+ return new CommandLineCompilerConfiguration(compiler, "dummy",
+ new File[0], new File[0], new File[0], "",
+ new String[]{"/Id:/gcc"}, new ProcessorParam[0], false,
+ new String[0]);
+ }
+ public void testConstructorNullCompiler() {
+ try {
+ new CommandLineCompilerConfiguration(null, "dummy", new File[0],
+ new File[0], new File[0], "", new String[0],
+ new ProcessorParam[0], false, new String[0]);
+ fail("Should throw exception for null compiler");
+ } catch (NullPointerException ex) {
+ }
+ }
+ public void testGetIdentifier() {
+ CompilerConfiguration config = create();
+ String id = config.getIdentifier();
+ assertEquals("dummy", id);
+ }
+ public void testToString() {
+ CompilerConfiguration config = create();
+ String toString = config.toString();
+ assertEquals("dummy", toString);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/compiler/TestCompilerConfiguration.java b/test/junit/net/sf/antcontrib/cpptasks/compiler/TestCompilerConfiguration.java
new file mode 100644
index 0000000..a928ae4
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/compiler/TestCompilerConfiguration.java
@@ -0,0 +1,68 @@
+/*
+ *
+ * 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.compiler;
+import junit.framework.TestCase;
+/**
+ */
+public abstract class TestCompilerConfiguration extends TestCase {
+ public TestCompilerConfiguration(String name) {
+ super(name);
+ }
+ protected abstract CompilerConfiguration create();
+ public String getObjectFileExtension() {
+ return ".o";
+ }
+ public void testBid() {
+ CompilerConfiguration compiler = create();
+ int bid = compiler.bid("c:/foo\\bar\\hello.c");
+ assertEquals(100, bid);
+ bid = compiler.bid("c:/foo\\bar/hello.c");
+ assertEquals(100, bid);
+ bid = compiler.bid("c:/foo\\bar\\hello.h");
+ assertEquals(1, bid);
+ bid = compiler.bid("c:/foo\\bar/hello.h");
+ assertEquals(1, bid);
+ bid = compiler.bid("c:/foo\\bar/hello.pas");
+ assertEquals(0, bid);
+ bid = compiler.bid("c:/foo\\bar/hello.java");
+ assertEquals(0, bid);
+ }
+ public void testGetOutputFileName1() {
+ CompilerConfiguration compiler = create();
+ String input = "c:/foo\\bar\\hello.c";
+ //
+ // may cause IllegalStateException since
+ // setPlatformInfo has not been called
+ try {
+ String[] output = compiler.getOutputFileNames(input, null);
+ } catch (java.lang.IllegalStateException ex) {
+ }
+ }
+ public void testGetOutputFileName2() {
+ CompilerConfiguration compiler = create();
+ String[] output = compiler.getOutputFileNames("c:/foo\\bar\\hello.c", null);
+ assertEquals("hello" + getObjectFileExtension(), output[0]);
+ output = compiler.getOutputFileNames("c:/foo\\bar/hello.c", null);
+ assertEquals("hello" + getObjectFileExtension(), output[0]);
+ output = compiler.getOutputFileNames("hello.c", null);
+ assertEquals("hello" + getObjectFileExtension(), output[0]);
+ output = compiler.getOutputFileNames("c:/foo\\bar\\hello.h", null);
+ assertEquals(0, output.length);
+ output = compiler.getOutputFileNames("c:/foo\\bar/hello.h", null);
+ assertEquals(0, output.length);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/compiler/TestLinkType.java b/test/junit/net/sf/antcontrib/cpptasks/compiler/TestLinkType.java
new file mode 100644
index 0000000..a7e3a45
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/compiler/TestLinkType.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * Copyright 2003-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.compiler;
+import junit.framework.TestCase;
+import net.sf.antcontrib.cpptasks.OutputTypeEnum;
+/**
+ * Tests for LinkType
+ *
+ * @author CurtA
+ */
+public class TestLinkType extends TestCase {
+ /**
+ * Constructor
+ *
+ * @param name
+ * test case name
+ */
+ public TestLinkType(String name) {
+ super(name);
+ }
+ /**
+ * Tests if isPluginModule returns true when set to plugin output type
+ *
+ * See patch [ 676276 ] Enhanced support for Mac OS X
+ */
+ public void testIsPluginFalse() {
+ LinkType type = new LinkType();
+ OutputTypeEnum pluginType = new OutputTypeEnum();
+ pluginType.setValue("executable");
+ type.setOutputType(pluginType);
+ assertTrue(!type.isPluginModule());
+ }
+ /**
+ * Tests if isPluginModule returns true when set to plugin output type
+ *
+ * See patch [ 676276 ] Enhanced support for Mac OS X
+ */
+ public void testIsPluginTrue() {
+ LinkType type = new LinkType();
+ OutputTypeEnum pluginType = new OutputTypeEnum();
+ pluginType.setValue("plugin");
+ type.setOutputType(pluginType);
+ assertTrue(type.isPluginModule());
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/devstudio/CVS/Entries b/test/junit/net/sf/antcontrib/cpptasks/devstudio/CVS/Entries
new file mode 100644
index 0000000..a84cfa7
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/devstudio/CVS/Entries
@@ -0,0 +1,4 @@
+/TestDevStudioLinker.java/1.10/Mon Apr 5 09:34:15 2004//
+/TestInstalledDevStudio.java/1.6/Sat Feb 28 19:04:47 2004//
+/TestInstalledDevStudioLinker.java/1.7/Sat Feb 28 19:04:47 2004//
+D
diff --git a/test/junit/net/sf/antcontrib/cpptasks/devstudio/CVS/Repository b/test/junit/net/sf/antcontrib/cpptasks/devstudio/CVS/Repository
new file mode 100644
index 0000000..54d7855
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/devstudio/CVS/Repository
@@ -0,0 +1 @@
+cpptasks/test/junit/net/sf/antcontrib/cpptasks/devstudio
diff --git a/test/junit/net/sf/antcontrib/cpptasks/devstudio/CVS/Root b/test/junit/net/sf/antcontrib/cpptasks/devstudio/CVS/Root
new file mode 100644
index 0000000..1ac95cd
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/devstudio/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ant-contrib
diff --git a/test/junit/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioLinker.java b/test/junit/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioLinker.java
new file mode 100644
index 0000000..7fdaabe
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioLinker.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.devstudio;
+import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor;
+import net.sf.antcontrib.cpptasks.compiler.TestAbstractLinker;
+import org.apache.tools.ant.taskdefs.condition.Os;
+/**
+ * Test for Microsoft Developer Studio linker
+ *
+ * Override create to test concrete compiler implementions
+ */
+public class TestDevStudioLinker extends TestAbstractLinker {
+ public TestDevStudioLinker(String name) {
+ super(name);
+ }
+ protected AbstractProcessor create() {
+ return DevStudioLinker.getInstance();
+ }
+ public void testGetIdentfier() {
+ if (!Os.isFamily("windows")) {
+ return;
+ }
+ AbstractProcessor compiler = create();
+ String id = compiler.getIdentifier();
+ boolean hasMSLinker = ((id.indexOf("Microsoft") >= 0) && (id
+ .indexOf("Linker") >= 0))
+ || id.indexOf("link") >= 0;
+ assertTrue(hasMSLinker);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/devstudio/TestInstalledDevStudio.java b/test/junit/net/sf/antcontrib/cpptasks/devstudio/TestInstalledDevStudio.java
new file mode 100644
index 0000000..3e29c91
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/devstudio/TestInstalledDevStudio.java
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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.devstudio;
+import junit.framework.TestSuite;
+/**
+ * Tests that depend on DevStudio being installed
+ *
+ */
+public class TestInstalledDevStudio extends TestSuite {
+ public static TestSuite suite() {
+ return new TestInstalledDevStudio("TestInstalledDevStudio");
+ }
+ public TestInstalledDevStudio(String name) {
+ super(name);
+ addTestSuite(net.sf.antcontrib.cpptasks.devstudio.TestInstalledDevStudioLinker.class);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/devstudio/TestInstalledDevStudioLinker.java b/test/junit/net/sf/antcontrib/cpptasks/devstudio/TestInstalledDevStudioLinker.java
new file mode 100644
index 0000000..07f1339
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/devstudio/TestInstalledDevStudioLinker.java
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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.devstudio;
+
+import java.io.File;
+
+
+/**
+ * Test for Microsoft Developer Studio linker
+ *
+ * Override create to test concrete compiler implementions
+ */
+public class TestInstalledDevStudioLinker extends TestDevStudioLinker
+{
+ public TestInstalledDevStudioLinker(String name) {
+ super(name);
+ }
+
+ public void testGetLibraryPath() {
+ File[] libpath = DevStudioLinker.getInstance().getLibraryPath();
+ //
+ // unless you tweak the library path
+ // it should have more thean three entries
+ assertTrue(libpath.length >= 2);
+ //
+ // check if these files can be found
+ //
+ String[] libnames = new String[] { "kernel32.lib",
+ "advapi32.lib", "msvcrt.lib", "mfc42.lib", "mfc70.lib" };
+ boolean[] libfound = new boolean[libnames.length];
+ for (int i = 0; i < libpath.length; i++) {
+ for (int j = 0; j < libnames.length; j++) {
+ File libfile = new File(libpath[i], libnames[j]);
+ if (libfile.exists()) {
+ libfound[j] = true;
+ }
+ }
+ }
+ assertTrue("kernel32 not found", libfound[0]);
+ assertTrue("advapi32 not found", libfound[1]);
+ assertTrue("msvcrt not found", libfound[2]);
+ if(!(libfound[3] || libfound[4])) {
+ fail("mfc42.lib or mfc70.lib not found");
+ }
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/gcc/CVS/Entries b/test/junit/net/sf/antcontrib/cpptasks/gcc/CVS/Entries
new file mode 100644
index 0000000..f6cc3a6
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/gcc/CVS/Entries
@@ -0,0 +1,6 @@
+/TestAbstractArLibrarian.java/1.6/Tue May 11 03:50:12 2004//
+/TestAbstractLdLinker.java/1.7/Wed Apr 21 21:46:50 2004//
+/TestGccCCompiler.java/1.7/Sat Feb 28 19:04:47 2004//
+/TestGccCompatibleCCompiler.java/1.3/Sat Feb 28 19:04:47 2004//
+/TestGccLinker.java/1.5/Tue May 11 03:50:12 2004//
+D
diff --git a/test/junit/net/sf/antcontrib/cpptasks/gcc/CVS/Repository b/test/junit/net/sf/antcontrib/cpptasks/gcc/CVS/Repository
new file mode 100644
index 0000000..288ae90
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/gcc/CVS/Repository
@@ -0,0 +1 @@
+cpptasks/test/junit/net/sf/antcontrib/cpptasks/gcc
diff --git a/test/junit/net/sf/antcontrib/cpptasks/gcc/CVS/Root b/test/junit/net/sf/antcontrib/cpptasks/gcc/CVS/Root
new file mode 100644
index 0000000..1ac95cd
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/gcc/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ant-contrib
diff --git a/test/junit/net/sf/antcontrib/cpptasks/gcc/TestAbstractArLibrarian.java b/test/junit/net/sf/antcontrib/cpptasks/gcc/TestAbstractArLibrarian.java
new file mode 100644
index 0000000..0fc8449
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/gcc/TestAbstractArLibrarian.java
@@ -0,0 +1,79 @@
+/*
+ *
+ * Copyright 2003-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.gcc;
+import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor;
+import net.sf.antcontrib.cpptasks.compiler.TestAbstractLinker;
+/**
+ * Tests for classes that derive from AbstractArLibrarian
+ *
+ * @author CurtA
+ */
+public class TestAbstractArLibrarian extends TestAbstractLinker {
+ /**
+ * Constructor
+ *
+ * @param name
+ * test name
+ * @see junit.framework.TestCase#TestCase(String)
+ */
+ public TestAbstractArLibrarian(String name) {
+ super(name);
+ }
+ /**
+ * Creates item under test @returns item under test
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.TestAbstractProcessor#create()
+ */
+ protected AbstractProcessor create() {
+ return GccLibrarian.getInstance();
+ }
+ /**
+ * Override of
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.TestAbstractProcessor#testBid()
+ */
+ public void testBid() {
+ AbstractProcessor compiler = create();
+ int bid = compiler.bid("c:/foo\\bar\\hello.o");
+ assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, bid);
+ }
+ public void testGetIdentfier() {
+ AbstractProcessor processor = create();
+ String id = processor.getIdentifier();
+ assertTrue(id.indexOf("ar") >= 0);
+ }
+ /**
+ * Tests for library patterns
+ *
+ * See patch [ 676276 ] Enhanced support for Mac OS X
+ */
+ public void testGetLibraryPatterns() {
+ String[] libnames = new String[]{"foo"};
+ String[] patterns = ((AbstractArLibrarian) create())
+ .getLibraryPatterns(libnames, null);
+ assertEquals(0, patterns.length);
+ }
+ /**
+ * Tests output file for ar library
+ *
+ * See bug [ 687732 ] Filenames for gcc static library does start with lib
+ */
+ public void testOutputFileName() {
+ String[] outputFiles = GccLibrarian.getInstance().getOutputFileNames("x", null);
+ assertEquals("libx.a", outputFiles[0]);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/gcc/TestAbstractLdLinker.java b/test/junit/net/sf/antcontrib/cpptasks/gcc/TestAbstractLdLinker.java
new file mode 100644
index 0000000..63996c5
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/gcc/TestAbstractLdLinker.java
@@ -0,0 +1,247 @@
+/*
+ *
+ * Copyright 2003-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.gcc;
+import java.io.File;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.OutputTypeEnum;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+/**
+ * Test ld linker adapter abstract base class
+ *
+ * Override create to test concrete compiler implementions
+ */
+public class TestAbstractLdLinker extends TestCase {
+ private final String realOSName;
+ public TestAbstractLdLinker(String name) {
+ super(name);
+ realOSName = System.getProperty("os.name");
+ }
+ protected AbstractLdLinker getLinker() {
+ return GccLinker.getInstance();
+ }
+ protected void tearDown() throws java.lang.Exception {
+ System.setProperty("os.name", realOSName);
+ }
+ /**
+ * Checks for proper arguments for plugin generation on Darwin
+ *
+ * See [ 676276 ] Enhanced support for Mac OS X
+ */
+ public void testAddImpliedArgsDarwinPlugin() {
+ System.setProperty("os.name", "Mac OS X");
+ AbstractLdLinker linker = getLinker();
+ Vector args = new Vector();
+ LinkType pluginType = new LinkType();
+ OutputTypeEnum pluginOutType = new OutputTypeEnum();
+ pluginOutType.setValue("plugin");
+ pluginType.setOutputType(pluginOutType);
+ linker.addImpliedArgs(false, pluginType, args);
+ assertEquals(1, args.size());
+ assertEquals("-bundle", args.elementAt(0));
+ }
+ /**
+ * Checks for proper arguments for shared generation on Darwin
+ *
+ * See [ 676276 ] Enhanced support for Mac OS X
+ */
+ public void testAddImpliedArgsDarwinShared() {
+ System.setProperty("os.name", "Mac OS X");
+ AbstractLdLinker linker = getLinker();
+ Vector args = new Vector();
+ LinkType pluginType = new LinkType();
+ OutputTypeEnum pluginOutType = new OutputTypeEnum();
+ pluginOutType.setValue("shared");
+ pluginType.setOutputType(pluginOutType);
+ linker.addImpliedArgs(false, pluginType, args);
+ assertEquals(2, args.size());
+ assertEquals("-prebind", args.elementAt(0));
+ assertEquals("-dynamiclib", args.elementAt(1));
+ }
+ /**
+ * Checks for proper arguments for plugin generation on Darwin
+ *
+ * See [ 676276 ] Enhanced support for Mac OS X
+ */
+ public void testAddImpliedArgsNonDarwinPlugin() {
+ System.setProperty("os.name", "VAX/VMS");
+ AbstractLdLinker linker = getLinker();
+ Vector args = new Vector();
+ LinkType pluginType = new LinkType();
+ OutputTypeEnum pluginOutType = new OutputTypeEnum();
+ pluginOutType.setValue("plugin");
+ pluginType.setOutputType(pluginOutType);
+ linker.addImpliedArgs(false, pluginType, args);
+ assertEquals(1, args.size());
+ assertEquals("-shared", args.elementAt(0));
+ }
+ /**
+ * Checks for proper arguments for shared generation on Darwin
+ *
+ * See [ 676276 ] Enhanced support for Mac OS X
+ */
+ public void testAddImpliedArgsNonDarwinShared() {
+ System.setProperty("os.name", "VAX/VMS");
+ AbstractLdLinker linker = getLinker();
+ Vector args = new Vector();
+ LinkType pluginType = new LinkType();
+ OutputTypeEnum pluginOutType = new OutputTypeEnum();
+ pluginOutType.setValue("shared");
+ pluginType.setOutputType(pluginOutType);
+ linker.addImpliedArgs(false, pluginType, args);
+ assertEquals(1, args.size());
+ assertEquals("-shared", args.elementAt(0));
+ }
+ public void testAddLibrarySetDirSwitch() {
+ AbstractLdLinker linker = getLinker();
+ CCTask task = new CCTask();
+ LibrarySet[] sets = new LibrarySet[]{new LibrarySet()};
+ /* throws an Exception in setLibs otherwise */
+ sets[0].setProject(new org.apache.tools.ant.Project());
+ sets[0].setDir(new File("/foo"));
+ sets[0].setLibs(new CUtil.StringArrayBuilder("bart,cart,dart"));
+ Vector preargs = new Vector();
+ Vector midargs = new Vector();
+ Vector endargs = new Vector();
+ String[] rc = linker.addLibrarySets(task, sets, preargs, midargs,
+ endargs);
+ String libdirSwitch = (String) endargs.elementAt(0);
+ assertEquals(libdirSwitch.substring(0, 2), "-L");
+ //
+ // can't have space after -L or will break Mac OS X
+ //
+ assertTrue(!libdirSwitch.substring(2, 3).equals(" "));
+ assertEquals(libdirSwitch.substring(libdirSwitch.length() - 3), "foo");
+ }
+ public void testAddLibrarySetLibSwitch() {
+ AbstractLdLinker linker = getLinker();
+ CCTask task = new CCTask();
+ LibrarySet[] sets = new LibrarySet[]{new LibrarySet()};
+ /* throws an Exception in setLibs otherwise */
+ sets[0].setProject(new org.apache.tools.ant.Project());
+ sets[0].setDir(new File("/foo"));
+ sets[0].setLibs(new CUtil.StringArrayBuilder("bart,cart,dart"));
+ Vector preargs = new Vector();
+ Vector midargs = new Vector();
+ Vector endargs = new Vector();
+ String[] rc = linker.addLibrarySets(task, sets, preargs, midargs,
+ endargs);
+ assertEquals("-lbart", (String) endargs.elementAt(1));
+ assertEquals("-lcart", (String) endargs.elementAt(2));
+ assertEquals("-ldart", (String) endargs.elementAt(3));
+ assertEquals(endargs.size(), 4);
+ }
+ public void testAddLibrarySetLibFrameworkNonDarwin() {
+ System.setProperty("os.name", "VAX/VMS");
+ AbstractLdLinker linker = getLinker();
+ CCTask task = new CCTask();
+ LibrarySet[] sets = new LibrarySet[]{new LibrarySet()};
+ /* throws an Exception in setLibs otherwise */
+ sets[0].setProject(new org.apache.tools.ant.Project());
+ sets[0].setDir(new File("/foo"));
+ LibraryTypeEnum libType = new LibraryTypeEnum();
+ libType.setValue("framework");
+ sets[0].setType(libType);
+ sets[0].setLibs(new CUtil.StringArrayBuilder("bart,cart,dart"));
+ Vector preargs = new Vector();
+ Vector midargs = new Vector();
+ Vector endargs = new Vector();
+ String[] rc = linker.addLibrarySets(task, sets, preargs, midargs,
+ endargs);
+ assertEquals("-L", ((String) endargs.elementAt(0)).substring(0, 2));
+ assertEquals("-Bdynamic", (String) endargs.elementAt(1));
+ assertEquals("-lbart", (String) endargs.elementAt(2));
+ assertEquals("-lcart", (String) endargs.elementAt(3));
+ assertEquals("-ldart", (String) endargs.elementAt(4));
+ assertEquals(endargs.size(), 5);
+ }
+ public void testAddLibrarySetLibFrameworkDarwin() {
+ System.setProperty("os.name", "Mac OS X");
+ AbstractLdLinker linker = getLinker();
+ CCTask task = new CCTask();
+ LibrarySet[] sets = new LibrarySet[]{new LibrarySet()};
+ /* throws an Exception in setLibs otherwise */
+ sets[0].setProject(new org.apache.tools.ant.Project());
+ sets[0].setDir(new File("/foo"));
+ LibraryTypeEnum libType = new LibraryTypeEnum();
+ libType.setValue("framework");
+ sets[0].setType(libType);
+ sets[0].setLibs(new CUtil.StringArrayBuilder("bart,cart,dart"));
+ Vector preargs = new Vector();
+ Vector midargs = new Vector();
+ Vector endargs = new Vector();
+ String[] rc = linker.addLibrarySets(task, sets, preargs, midargs,
+ endargs);
+ assertEquals("-F", ((String) endargs.elementAt(0)).substring(0, 2));
+ assertEquals("-framework bart", (String) endargs.elementAt(1));
+ assertEquals("-framework cart", (String) endargs.elementAt(2));
+ assertEquals("-framework dart", (String) endargs.elementAt(3));
+ assertEquals(endargs.size(), 4);
+ }
+ public void testAddLibraryStatic() {
+ AbstractLdLinker linker = getLinker();
+ CCTask task = new CCTask();
+ LibrarySet[] sets = new LibrarySet[]{
+ new LibrarySet(),
+ new LibrarySet(),
+ new LibrarySet()};
+ /* throws an Exception in setLibs otherwise */
+ sets[0].setProject(new org.apache.tools.ant.Project());
+ sets[0].setLibs(new CUtil.StringArrayBuilder("bart"));
+ sets[1].setProject(new org.apache.tools.ant.Project());
+ sets[1].setLibs(new CUtil.StringArrayBuilder("cart"));
+ LibraryTypeEnum libType = new LibraryTypeEnum();
+ libType.setValue("static");
+ sets[1].setType(libType);
+ sets[2].setProject(new org.apache.tools.ant.Project());
+ sets[2].setLibs(new CUtil.StringArrayBuilder("dart"));
+ Vector preargs = new Vector();
+ Vector midargs = new Vector();
+ Vector endargs = new Vector();
+ String[] rc = linker.addLibrarySets(task, sets, preargs, midargs,
+ endargs);
+ assertEquals("-lbart", (String) endargs.elementAt(0));
+ assertEquals("-Bstatic", (String) endargs.elementAt(1));
+ assertEquals("-lcart", (String) endargs.elementAt(2));
+ assertEquals("-Bdynamic", (String) endargs.elementAt(3));
+ assertEquals("-ldart", (String) endargs.elementAt(4));
+ assertEquals(endargs.size(), 5);
+ }
+ public void testLibReturnValue() {
+ AbstractLdLinker linker = getLinker();
+ CCTask task = new CCTask();
+ LibrarySet[] sets = new LibrarySet[]{new LibrarySet()};
+ /* throws an Exception in setLibs otherwise */
+ sets[0].setProject(new org.apache.tools.ant.Project());
+ sets[0].setDir(new File("/foo"));
+ sets[0].setLibs(new CUtil.StringArrayBuilder("bart,cart,dart"));
+ Vector preargs = new Vector();
+ Vector midargs = new Vector();
+ Vector endargs = new Vector();
+ String[] rc = linker.addLibrarySets(task, sets, preargs, midargs,
+ endargs);
+ assertEquals(3, rc.length);
+ assertEquals("bart", rc[0]);
+ assertEquals("cart", rc[1]);
+ assertEquals("dart", rc[2]);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccCCompiler.java b/test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccCCompiler.java
new file mode 100644
index 0000000..3abe409
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccCCompiler.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.gcc;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor;
+import net.sf.antcontrib.cpptasks.parser.CParser;
+import net.sf.antcontrib.cpptasks.parser.FortranParser;
+import net.sf.antcontrib.cpptasks.parser.Parser;
+/**
+ * Test gcc compiler adapter
+ *
+ */
+public class TestGccCCompiler extends TestGccCompatibleCCompiler {
+ public TestGccCCompiler(String name) {
+ super(name);
+ }
+ protected GccCompatibleCCompiler create() {
+ return GccCCompiler.getInstance();
+ }
+ public void testBidObjectiveAssembly() {
+ GccCCompiler compiler = GccCCompiler.getInstance();
+ assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler
+ .bid("foo.s"));
+ }
+ public void testBidObjectiveC() {
+ GccCCompiler compiler = GccCCompiler.getInstance();
+ assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler
+ .bid("foo.m"));
+ }
+ public void testBidObjectiveCpp() {
+ GccCCompiler compiler = GccCCompiler.getInstance();
+ assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler
+ .bid("foo.mm"));
+ }
+ public void testBidPreprocessedCpp() {
+ GccCCompiler compiler = GccCCompiler.getInstance();
+ assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler
+ .bid("foo.ii"));
+ }
+ public void testCreateCParser1() {
+ Parser parser = GccCCompiler.getInstance().createParser(
+ new File("foo.c"));
+ assertTrue(parser instanceof CParser);
+ }
+ public void testCreateCParser2() {
+ Parser parser = GccCCompiler.getInstance().createParser(
+ new File("foo."));
+ assertTrue(parser instanceof CParser);
+ }
+ public void testCreateCParser3() {
+ Parser parser = GccCCompiler.getInstance()
+ .createParser(new File("foo"));
+ assertTrue(parser instanceof CParser);
+ }
+ public void testCreateFortranParser1() {
+ Parser parser = GccCCompiler.getInstance().createParser(
+ new File("foo.f"));
+ assertTrue(parser instanceof FortranParser);
+ }
+ public void testCreateFortranParser2() {
+ Parser parser = GccCCompiler.getInstance().createParser(
+ new File("foo.FoR"));
+ assertTrue(parser instanceof FortranParser);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccCompatibleCCompiler.java b/test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccCompatibleCCompiler.java
new file mode 100644
index 0000000..68fab2e
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccCompatibleCCompiler.java
@@ -0,0 +1,105 @@
+/*
+ *
+ * Copyright 2003-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.gcc;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+/**
+ * Tests for gcc compatible compilers
+ *
+ * @author CurtA
+ */
+public abstract class TestGccCompatibleCCompiler extends TestCase {
+ /**
+ * Constructor
+ *
+ * @param name
+ * test case name
+ */
+ public TestGccCompatibleCCompiler(String name) {
+ super(name);
+ }
+ /**
+ * Compiler creation method
+ *
+ * Must be overriden by extending classes
+ *
+ * @return GccCompatibleCCompiler
+ */
+ protected abstract GccCompatibleCCompiler create();
+ /**
+ * Tests command lines switches for warning = 0
+ */
+ public void testWarningLevel0() {
+ GccCompatibleCCompiler compiler = create();
+ Vector args = new Vector();
+ compiler.addWarningSwitch(args, 0);
+ assertEquals(1, args.size());
+ assertEquals("-w", args.elementAt(0));
+ }
+ /**
+ * Tests command lines switches for warning = 1
+ */
+ public void testWarningLevel1() {
+ GccCompatibleCCompiler compiler = create();
+ Vector args = new Vector();
+ compiler.addWarningSwitch(args, 1);
+ assertEquals(0, args.size());
+ }
+ /**
+ * Tests command lines switches for warning = 2
+ */
+ public void testWarningLevel2() {
+ GccCompatibleCCompiler compiler = create();
+ Vector args = new Vector();
+ compiler.addWarningSwitch(args, 2);
+ assertEquals(0, args.size());
+ }
+ /**
+ * Tests command lines switches for warning = 3
+ */
+ public void testWarningLevel3() {
+ GccCompatibleCCompiler compiler = create();
+ Vector args = new Vector();
+ compiler.addWarningSwitch(args, 3);
+ assertEquals(1, args.size());
+ assertEquals("-Wall", args.elementAt(0));
+ }
+ /**
+ * Tests command lines switches for warning = 4
+ */
+ public void testWarningLevel4() {
+ GccCompatibleCCompiler compiler = create();
+ Vector args = new Vector();
+ compiler.addWarningSwitch(args, 4);
+ assertEquals(2, args.size());
+ assertEquals("-W", args.elementAt(0));
+ assertEquals("-Wall", args.elementAt(1));
+ }
+ /**
+ * Tests command lines switches for warning = 5
+ */
+ public void testWarningLevel5() {
+ GccCompatibleCCompiler compiler = create();
+ Vector args = new Vector();
+ compiler.addWarningSwitch(args, 5);
+ assertEquals(3, args.size());
+ assertEquals("-Werror", args.elementAt(0));
+ assertEquals("-W", args.elementAt(1));
+ assertEquals("-Wall", args.elementAt(2));
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccLinker.java b/test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccLinker.java
new file mode 100644
index 0000000..ee3ad8b
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccLinker.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * Copyright 2003-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.gcc;
+import junit.framework.TestCase;
+import net.sf.antcontrib.cpptasks.OutputTypeEnum;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+/**
+ * @author CurtA
+ */
+public class TestGccLinker extends TestCase {
+ private final String realOSName;
+ /**
+ * Constructor
+ *
+ * @param test
+ * name
+ */
+ public TestGccLinker(String name) {
+ super(name);
+ realOSName = System.getProperty("os.name");
+ }
+ protected void tearDown() throws java.lang.Exception {
+ System.setProperty("os.name", realOSName);
+ }
+ public void testGetLinkerDarwinPlugin() {
+ System.setProperty("os.name", "Mac OS X");
+ GccLinker linker = GccLinker.getInstance();
+ OutputTypeEnum outputType = new OutputTypeEnum();
+ outputType.setValue("plugin");
+ LinkType linkType = new LinkType();
+ linkType.setOutputType(outputType);
+ Linker pluginLinker = linker.getLinker(linkType);
+ assertEquals("libfoo.bundle", pluginLinker.getOutputFileNames("foo", null)[0]);
+ }
+ public void testGetLinkerDarwinShared() {
+ System.setProperty("os.name", "Mac OS X");
+ GccLinker linker = GccLinker.getInstance();
+ OutputTypeEnum outputType = new OutputTypeEnum();
+ outputType.setValue("shared");
+ LinkType linkType = new LinkType();
+ linkType.setOutputType(outputType);
+ Linker sharedLinker = linker.getLinker(linkType);
+ assertEquals("libfoo.dylib", sharedLinker.getOutputFileNames("foo", null)[0]);
+ }
+ public void testGetLinkerNonDarwinPlugin() {
+ System.setProperty("os.name", "Microsoft Windows");
+ GccLinker linker = GccLinker.getInstance();
+ OutputTypeEnum outputType = new OutputTypeEnum();
+ outputType.setValue("plugin");
+ LinkType linkType = new LinkType();
+ linkType.setOutputType(outputType);
+ Linker pluginLinker = linker.getLinker(linkType);
+ assertEquals("libfoo.so", pluginLinker.getOutputFileNames("foo", null)[0]);
+ }
+ public void testGetLinkerNonDarwinShared() {
+ System.setProperty("os.name", "Microsoft Windows");
+ GccLinker linker = GccLinker.getInstance();
+ OutputTypeEnum outputType = new OutputTypeEnum();
+ outputType.setValue("shared");
+ LinkType linkType = new LinkType();
+ linkType.setOutputType(outputType);
+ Linker sharedLinker = linker.getLinker(linkType);
+ assertEquals("libfoo.so", sharedLinker.getOutputFileNames("foo", null)[0]);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/package.html b/test/junit/net/sf/antcontrib/cpptasks/package.html
new file mode 100644
index 0000000..eba4e2c
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/package.html
@@ -0,0 +1,28 @@
+<!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 package.
+
+</body>
+</html>
+
diff --git a/test/junit/net/sf/antcontrib/cpptasks/parser/CVS/Entries b/test/junit/net/sf/antcontrib/cpptasks/parser/CVS/Entries
new file mode 100644
index 0000000..8bec227
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/parser/CVS/Entries
@@ -0,0 +1,5 @@
+/TestAbstractParser.java/1.6/Sat Feb 28 19:04:46 2004//
+/TestCParser.java/1.9/Mon Aug 15 13:58:27 2005//
+/TestFortranParser.java/1.2/Sat Jun 26 02:45:18 2004//
+/package.html/1.1/Fri Apr 16 04:04:15 2004//
+D
diff --git a/test/junit/net/sf/antcontrib/cpptasks/parser/CVS/Repository b/test/junit/net/sf/antcontrib/cpptasks/parser/CVS/Repository
new file mode 100644
index 0000000..b216e97
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/parser/CVS/Repository
@@ -0,0 +1 @@
+cpptasks/test/junit/net/sf/antcontrib/cpptasks/parser
diff --git a/test/junit/net/sf/antcontrib/cpptasks/parser/CVS/Root b/test/junit/net/sf/antcontrib/cpptasks/parser/CVS/Root
new file mode 100644
index 0000000..1ac95cd
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/parser/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ant-contrib
diff --git a/test/junit/net/sf/antcontrib/cpptasks/parser/TestAbstractParser.java b/test/junit/net/sf/antcontrib/cpptasks/parser/TestAbstractParser.java
new file mode 100644
index 0000000..5f7eb2a
--- /dev/null
+++ b/test/junit/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/test/junit/net/sf/antcontrib/cpptasks/parser/TestCParser.java b/test/junit/net/sf/antcontrib/cpptasks/parser/TestCParser.java
new file mode 100644
index 0000000..cbecdfb
--- /dev/null
+++ b/test/junit/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/test/junit/net/sf/antcontrib/cpptasks/parser/TestFortranParser.java b/test/junit/net/sf/antcontrib/cpptasks/parser/TestFortranParser.java
new file mode 100644
index 0000000..8078331
--- /dev/null
+++ b/test/junit/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/test/junit/net/sf/antcontrib/cpptasks/parser/package.html b/test/junit/net/sf/antcontrib/cpptasks/parser/package.html
new file mode 100644
index 0000000..bfb9d6e
--- /dev/null
+++ b/test/junit/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>
diff --git a/test/junit/net/sf/antcontrib/cpptasks/trolltech/CVS/Entries b/test/junit/net/sf/antcontrib/cpptasks/trolltech/CVS/Entries
new file mode 100644
index 0000000..4f19176
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/trolltech/CVS/Entries
@@ -0,0 +1,4 @@
+/TestMetaObjectCompiler.java/1.2/Tue May 11 03:50:16 2004//
+/TestMetaObjectParser.java/1.1/Wed May 5 02:50:44 2004//
+/package.html/1.1/Wed May 5 02:50:44 2004//
+D
diff --git a/test/junit/net/sf/antcontrib/cpptasks/trolltech/CVS/Repository b/test/junit/net/sf/antcontrib/cpptasks/trolltech/CVS/Repository
new file mode 100644
index 0000000..6a899c0
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/trolltech/CVS/Repository
@@ -0,0 +1 @@
+cpptasks/test/junit/net/sf/antcontrib/cpptasks/trolltech
diff --git a/test/junit/net/sf/antcontrib/cpptasks/trolltech/CVS/Root b/test/junit/net/sf/antcontrib/cpptasks/trolltech/CVS/Root
new file mode 100644
index 0000000..1ac95cd
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/trolltech/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ant-contrib
diff --git a/test/junit/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectCompiler.java b/test/junit/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectCompiler.java
new file mode 100644
index 0000000..6d97c12
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectCompiler.java
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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.
+ */
+package net.sf.antcontrib.cpptasks.trolltech;
+
+import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor;
+import net.sf.antcontrib.cpptasks.compiler.TestAbstractCompiler;
+
+/**
+ * Tests for Trolltech Meta Object Compiler.
+ *
+ */
+public class TestMetaObjectCompiler
+ extends TestAbstractCompiler {
+ /**
+ * Constructor.
+ * @param name test name
+ */
+ public TestMetaObjectCompiler(final String name) {
+ super(name);
+ }
+
+ /**
+ * Creates compiler for inherited tests.
+ * @return AbstractProcessor compiler
+ */
+ protected AbstractProcessor create() {
+ return MetaObjectCompiler.getInstance();
+ }
+
+ /**
+ * Gets default output file extension.
+ * @return String output file extension
+ */
+ protected String getObjectExtension() {
+ return ".moc";
+ }
+
+ /**
+ * Skip testGetIdentifier.
+ */
+ public void testGetIdentfier() {
+ }
+
+ /**
+ * Override inherited test.
+ */
+ public void testGetOutputFileName1() {
+ AbstractProcessor compiler = MetaObjectCompiler.getInstance();
+ String[] output = compiler.getOutputFileNames("c:/foo\\bar\\hello.cpp", null);
+ assertEquals("hello" + getObjectExtension(), output[0]);
+ output = compiler.getOutputFileNames("c:/foo\\bar/hello.cpp", null);
+ assertEquals("hello" + getObjectExtension(), output[0]);
+ output = compiler.getOutputFileNames("hello.cpp", null);
+ assertEquals("hello" + getObjectExtension(), output[0]);
+ output = compiler.getOutputFileNames("c:/foo\\bar\\hello.h", null);
+ assertEquals("moc_hello.cpp", output[0]);
+ output = compiler.getOutputFileNames("c:/foo\\bar/hello.h", null);
+ assertNull("moc_hello.cpp", output[0]);
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectParser.java b/test/junit/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectParser.java
new file mode 100644
index 0000000..371bdf1
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectParser.java
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.
+ */
+package net.sf.antcontrib.cpptasks.trolltech;
+
+import java.io.CharArrayReader;
+import java.io.IOException;
+import junit.framework.TestCase;
+
+/**
+ * Tests for the MetaObjectParser class.
+ */
+public final class TestMetaObjectParser
+ extends TestCase {
+ /**
+ * Constructor.
+ * @param name String test name
+ */
+ public TestMetaObjectParser(final String name) {
+ super(name);
+ }
+
+ /**
+ * Test that the presence of Q_OBJECT causes hasQObject to return true.
+ * @throws IOException test fails on IOException
+ */
+ public void testHasQObject1() throws IOException {
+ CharArrayReader reader = new CharArrayReader(
+ " Q_OBJECT ".toCharArray());
+ boolean hasQObject = MetaObjectParser.hasQObject(reader);
+ assertTrue(hasQObject);
+ }
+
+ /**
+ * Test that the lack of Q_OBJECT causes hasQObject to return false.
+ * @throws IOException test fails on IOException
+ */
+ public void testHasQObject2() throws IOException {
+ CharArrayReader reader = new CharArrayReader(
+ " Q_OBJ ECT ".toCharArray());
+ boolean hasQObject = MetaObjectParser.hasQObject(reader);
+ assertFalse(hasQObject);
+ }
+
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/trolltech/package.html b/test/junit/net/sf/antcontrib/cpptasks/trolltech/package.html
new file mode 100644
index 0000000..bbdaa89
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/trolltech/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">
+
+Tests for Trolltech Qt uic and moc compilers.
+</body>
+</html>
+
diff --git a/test/junit/net/sf/antcontrib/cpptasks/types/CVS/Entries b/test/junit/net/sf/antcontrib/cpptasks/types/CVS/Entries
new file mode 100644
index 0000000..319dc2e
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/types/CVS/Entries
@@ -0,0 +1,4 @@
+/TestDefineArgument.java/1.8/Sat Feb 28 19:04:47 2004//
+/TestLibrarySet.java/1.14/Thu Apr 22 08:06:55 2004//
+/package.html/1.1/Fri Apr 16 04:04:11 2004//
+D
diff --git a/test/junit/net/sf/antcontrib/cpptasks/types/CVS/Repository b/test/junit/net/sf/antcontrib/cpptasks/types/CVS/Repository
new file mode 100644
index 0000000..5b7ecc7
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/types/CVS/Repository
@@ -0,0 +1 @@
+cpptasks/test/junit/net/sf/antcontrib/cpptasks/types
diff --git a/test/junit/net/sf/antcontrib/cpptasks/types/CVS/Root b/test/junit/net/sf/antcontrib/cpptasks/types/CVS/Root
new file mode 100644
index 0000000..1ac95cd
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/types/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ant-contrib
diff --git a/test/junit/net/sf/antcontrib/cpptasks/types/TestDefineArgument.java b/test/junit/net/sf/antcontrib/cpptasks/types/TestDefineArgument.java
new file mode 100644
index 0000000..e5b53ee
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/types/TestDefineArgument.java
@@ -0,0 +1,124 @@
+/*
+ *
+ * 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.types;
+import junit.framework.TestCase;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+/**
+ * Tests for the DefineArgument class
+ */
+public class TestDefineArgument extends TestCase {
+ public TestDefineArgument(String name) {
+ super(name);
+ }
+ public void testIsActive1() {
+ DefineArgument arg = new DefineArgument();
+ Project project = new Project();
+ try {
+ boolean isActive = arg.isActive(project);
+ } catch (BuildException ex) {
+ return;
+ }
+ fail("isActive should throw exception if name is not set");
+ }
+ public void testIsActive2() {
+ DefineArgument arg = new DefineArgument();
+ arg.setName("TEST");
+ Project project = new Project();
+ project.setProperty("cond", "");
+ arg.setIf("cond");
+ assertTrue(arg.isActive(project));
+ }
+ public void testIsActive3() {
+ DefineArgument arg = new DefineArgument();
+ arg.setName("TEST");
+ Project project = new Project();
+ arg.setIf("cond");
+ assertTrue(!arg.isActive(project));
+ }
+ public void testIsActive4() {
+ DefineArgument arg = new DefineArgument();
+ arg.setName("TEST");
+ Project project = new Project();
+ project.setProperty("cond", "false");
+ arg.setIf("cond");
+ try {
+ boolean isActive = arg.isActive(project);
+ } catch (BuildException ex) {
+ return;
+ }
+ fail("Should throw exception for suspicious value");
+ }
+ public void testIsActive5() {
+ DefineArgument arg = new DefineArgument();
+ arg.setName("TEST");
+ Project project = new Project();
+ project.setProperty("cond", "");
+ arg.setUnless("cond");
+ assertTrue(!arg.isActive(project));
+ }
+ public void testIsActive6() {
+ DefineArgument arg = new DefineArgument();
+ arg.setName("TEST");
+ Project project = new Project();
+ arg.setUnless("cond");
+ assertTrue(arg.isActive(project));
+ }
+ public void testIsActive7() {
+ DefineArgument arg = new DefineArgument();
+ arg.setName("TEST");
+ Project project = new Project();
+ project.setProperty("cond", "false");
+ arg.setUnless("cond");
+ try {
+ boolean isActive = arg.isActive(project);
+ } catch (BuildException ex) {
+ return;
+ }
+ fail("Should throw exception for suspicious value");
+ }
+ public void testIsActive8() {
+ DefineArgument arg = new DefineArgument();
+ arg.setName("TEST");
+ Project project = new Project();
+ project.setProperty("cond", "");
+ arg.setIf("cond");
+ arg.setUnless("cond");
+ assertTrue(!arg.isActive(project));
+ }
+ public void testMerge() {
+ UndefineArgument[] base = new UndefineArgument[2];
+ UndefineArgument[] specific = new UndefineArgument[2];
+ base[0] = new DefineArgument();
+ base[0].setName("foo");
+ base[1] = new UndefineArgument();
+ base[1].setName("hello");
+ specific[0] = new DefineArgument();
+ specific[0].setName("hello");
+ specific[1] = new UndefineArgument();
+ specific[1].setName("world");
+ UndefineArgument[] merged = UndefineArgument.merge(base, specific);
+ assertEquals(3, merged.length);
+ assertEquals("foo", merged[0].getName());
+ assertEquals(true, merged[0].isDefine());
+ assertEquals("hello", merged[1].getName());
+ assertEquals(true, merged[1].isDefine());
+ assertEquals("world", merged[2].getName());
+ assertEquals(false, merged[2].isDefine());
+ }
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/types/TestLibrarySet.java b/test/junit/net/sf/antcontrib/cpptasks/types/TestLibrarySet.java
new file mode 100644
index 0000000..ce0d712
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/types/TestLibrarySet.java
@@ -0,0 +1,301 @@
+/*
+ *
+ * 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.types;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.MockBuildListener;
+import net.sf.antcontrib.cpptasks.MockFileCollector;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioLibrarian;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * Tests for the LibrarySet class.
+ */
+public class TestLibrarySet
+ extends TestCase {
+
+ /**
+ * Constructor.
+ *
+ * @param name
+ * test name
+ */
+ public TestLibrarySet(final String name) {
+ super(name);
+ }
+
+ /**
+ * Evaluate isActive when "if" specifies a property that is set.
+ */
+ public final void testIsActive1() {
+ LibrarySet libset = new LibrarySet();
+ Project project = new Project();
+ project.setProperty("windows", "");
+ libset.setProject(project);
+ libset.setIf("windows");
+ CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("kernel32");
+ libset.setLibs(libs);
+ boolean isActive = libset.isActive(project);
+ assertTrue(isActive);
+ }
+
+ /**
+ * Evaluate isActive when "if" specifies a property whose value suggests the
+ * user thinks the value is significant.
+ *
+ */
+ public final void testIsActive2() {
+ LibrarySet libset = new LibrarySet();
+ Project project = new Project();
+ //
+ // setting the value to false should throw
+ // exception to warn user that they are misusing if
+ //
+ project.setProperty("windows", "false");
+ libset.setIf("windows");
+ try {
+ boolean isActive = libset.isActive(project);
+ } catch (BuildException ex) {
+ return;
+ }
+ fail();
+ }
+
+ /**
+ * Evaluate isActive when "if" specifies a property that is not set.
+ */
+ public final void testIsActive3() {
+ LibrarySet libset = new LibrarySet();
+ Project project = new Project();
+ libset.setIf("windows");
+ boolean isActive = libset.isActive(project);
+ assertTrue(!isActive);
+ }
+
+ /**
+ * Evaluate isActive when "unless" specifies a property that is set.
+ *
+ */
+ public final void testIsActive4() {
+ LibrarySet libset = new LibrarySet();
+ Project project = new Project();
+ project.setProperty("windows", "");
+ libset.setUnless("windows");
+ boolean isActive = libset.isActive(project);
+ assertTrue(!isActive);
+ }
+
+ /**
+ * Evaluate isActive when "unless" specifies a property whose value suggests
+ * the user thinks the value is significant.
+ *
+ */
+ public final void testIsActive5() {
+ LibrarySet libset = new LibrarySet();
+ Project project = new Project();
+ //
+ // setting the value to false should throw
+ // exception to warn user that they are misusing if
+ //
+ project.setProperty("windows", "false");
+ libset.setUnless("windows");
+ try {
+ boolean isActive = libset.isActive(project);
+ } catch (BuildException ex) {
+ return;
+ }
+ fail();
+ }
+
+ /**
+ * Evaluate isActive when "unless" specifies a property that is not set.
+ */
+ public final void testIsActive6() {
+ LibrarySet libset = new LibrarySet();
+ Project project = new Project();
+ libset.setProject(project);
+ libset.setUnless("windows");
+ CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("kernel32");
+ libset.setLibs(libs);
+ boolean isActive = libset.isActive(project);
+ assertTrue(isActive);
+ }
+
+ /**
+ * The libs parameter should not end with .lib, .so, .a etc New behavior is
+ * to warn if it ends in a suspicious extension.
+ */
+ public final void testLibContainsDot() {
+ LibrarySet libset = new LibrarySet();
+ Project p = new Project();
+ MockBuildListener listener = new MockBuildListener();
+ p.addBuildListener(listener);
+ libset.setProject(p);
+ CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("mylib1.1");
+ libset.setLibs(libs);
+ assertEquals(0, listener.getMessageLoggedEvents().size());
+ }
+
+ /**
+ * The libs parameter should not end with .lib, .so, .a etc however the
+ * previous test would cause a build exception for any library containing
+ * periods. Now logs warning message.
+ */
+ public final void testLibContainsDotLib() {
+ LibrarySet libset = new LibrarySet();
+ Project p = new Project();
+ MockBuildListener listener = new MockBuildListener();
+ p.addBuildListener(listener);
+ libset.setProject(p);
+ CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder(
+ "mylib1.lib");
+ libset.setLibs(libs);
+ assertEquals(1, listener.getMessageLoggedEvents().size());
+ }
+
+ /**
+ * Use of a libset or syslibset without a libs attribute should log a
+ * warning message.
+ */
+ public final void testLibNotSpecified() {
+ LibrarySet libset = new LibrarySet();
+ Project p = new Project();
+ MockBuildListener listener = new MockBuildListener();
+ p.addBuildListener(listener);
+ libset.setProject(p);
+ boolean isActive = libset.isActive(p);
+ assertEquals(false, isActive);
+ assertEquals(1, listener.getMessageLoggedEvents().size());
+ }
+
+ /**
+ * this threw an exception prior to 2002-09-05 and started to throw one
+ * again 2002-11-19 up to 2002-12-11.
+ */
+ public final void testShortLibName() {
+ LibrarySet libset = new LibrarySet();
+ CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("li");
+ libset.setProject(new Project());
+ libset.setLibs(libs);
+ }
+
+ /**
+ * The libs parameter should not end with .lib, .so, .a etc however the
+ * previous test would cause a build exception for any library containing
+ * periods. Now logs warning message.
+ */
+ public final void testStartsWithLib() {
+ LibrarySet libset = new LibrarySet();
+ Project p = new Project();
+ MockBuildListener listener = new MockBuildListener();
+ p.addBuildListener(listener);
+ libset.setProject(p);
+ CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder(
+ "libmylib1");
+ libset.setLibs(libs);
+ assertEquals(1, listener.getMessageLoggedEvents().size());
+ }
+
+ /**
+ * This test creates two "fake" libraries in the temporary directory and
+ * check how many are visited.
+ *
+ * @param linker linker
+ * @param expected expected number of visited files
+ * @throws IOException
+ * if unable to write to temporary directory or delete temporary
+ * files
+ */
+ public final void testVisitFiles(final Linker linker,
+ final int expected)
+ throws IOException {
+ LibrarySet libset = new LibrarySet();
+ Project p = new Project();
+ MockBuildListener listener = new MockBuildListener();
+ p.addBuildListener(listener);
+ libset.setProject(p);
+ //
+ // create temporary files named cpptasksXXXXX.lib
+ //
+ File lib1 = File.createTempFile("cpptasks", ".lib");
+ String lib1Name = lib1.getName();
+ lib1Name = lib1Name.substring(0, lib1Name.indexOf(".lib"));
+ File lib2 = File.createTempFile("cpptasks", ".lib");
+ File baseDir = lib1.getParentFile();
+
+ // set the dir attribute to the temporary directory
+ libset.setDir(baseDir);
+ // set libs to the file name without the suffix
+ CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder(lib1Name);
+ libset.setLibs(libs);
+
+ //
+ // collect all files visited
+ MockFileCollector collector = new MockFileCollector();
+ libset.visitLibraries(p, linker, new File[0], collector);
+
+ //
+ // get the canonical paths for the initial and visited libraries
+ String expectedCanonicalPath = lib1.getCanonicalPath();
+ String actualCanonicalPath = null;
+ if (collector.size() == 1) {
+ actualCanonicalPath = new File(collector.getBaseDir(0), collector
+ .getFileName(0)).getCanonicalPath();
+ }
+ //
+ // delete the temporary files
+ lib1.delete();
+ lib2.delete();
+ // was there only one match
+ assertEquals(expected, collector.size());
+ if (expected == 1) {
+ // is its canonical path as expected
+ assertEquals(expectedCanonicalPath, actualCanonicalPath);
+ }
+ }
+
+ /**
+ * Run testVisitFiles with the MSVC Linker
+ * expect one matching file.
+ *
+ * @throws IOException if unable to create or delete temporary file
+ */
+ public final void testLinkerVisitFiles() throws IOException {
+ Linker linker = DevStudioLinker.getInstance();
+ testVisitFiles(linker, 1);
+ }
+
+ /**
+ * Run testVisitFiles with the MSVC Linker
+ * expect one matching file.
+ *
+ * @throws IOException if unable to create or delete temporary file
+ */
+ public final void testLibrarianVisitFiles() throws IOException {
+ Linker linker = DevStudioLibrarian.getInstance();
+ testVisitFiles(linker, 0);
+ }
+
+}
diff --git a/test/junit/net/sf/antcontrib/cpptasks/types/package.html b/test/junit/net/sf/antcontrib/cpptasks/types/package.html
new file mode 100644
index 0000000..e5efbc4
--- /dev/null
+++ b/test/junit/net/sf/antcontrib/cpptasks/types/package.html
@@ -0,0 +1,28 @@
+<!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.types package.
+
+</body>
+</html>
+