summaryrefslogtreecommitdiffstats
path: root/test/junit/net/sf/antcontrib/cpptasks/gcc
diff options
context:
space:
mode:
authormattinger <[email protected]>2006-11-07 21:16:39 +0000
committermattinger <[email protected]>2006-11-07 21:16:39 +0000
commitc8da7ec534c959db815f272819dafaf61e49a9bd (patch)
tree16dfe231dadf33c0829ca23efe8a0021502d99eb /test/junit/net/sf/antcontrib/cpptasks/gcc
parent93d3419f7217a29d266acf2884c6327f1953cb3f (diff)
Initial import of cpptasks code
git-svn-id: file:///home/sven/projects/JOGL/temp/ant-contrib/svn/ant-contrib-code/trunk/cpptasks@62 32d7a393-a5a9-423c-abd3-5d954feb1f2f
Diffstat (limited to 'test/junit/net/sf/antcontrib/cpptasks/gcc')
-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
5 files changed, 591 insertions, 0 deletions
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]);
+ }
+}