1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.github.maven_nar.cpptasks.gcc;
21
22 import junit.framework.TestCase;
23
24 import com.github.maven_nar.cpptasks.OutputTypeEnum;
25 import com.github.maven_nar.cpptasks.compiler.LinkType;
26 import com.github.maven_nar.cpptasks.compiler.Linker;
27
28
29
30
31 public class TestGccLinker extends TestCase {
32 private final String realOSName;
33
34
35
36
37
38
39
40 public TestGccLinker(final String name) {
41 super(name);
42 this.realOSName = System.getProperty("os.name");
43 }
44
45 @Override
46 protected void tearDown() throws java.lang.Exception {
47 System.setProperty("os.name", this.realOSName);
48 }
49
50 public void testGetLinkerDarwinPlugin() {
51 System.setProperty("os.name", "Mac OS X");
52 final GccLinker linker = GccLinker.getInstance();
53 final OutputTypeEnum outputType = new OutputTypeEnum();
54 outputType.setValue("plugin");
55 final LinkType linkType = new LinkType();
56 linkType.setOutputType(outputType);
57 final Linker pluginLinker = linker.getLinker(linkType);
58 assertEquals("libfoo.bundle", pluginLinker.getOutputFileNames("foo", null)[0]);
59 }
60
61 public void testGetLinkerDarwinShared() {
62 System.setProperty("os.name", "Mac OS X");
63 final GccLinker linker = GccLinker.getInstance();
64 final OutputTypeEnum outputType = new OutputTypeEnum();
65 outputType.setValue("shared");
66 final LinkType linkType = new LinkType();
67 linkType.setOutputType(outputType);
68 final Linker sharedLinker = linker.getLinker(linkType);
69 assertEquals("libfoo.dylib", sharedLinker.getOutputFileNames("foo", null)[0]);
70 }
71
72 public void testGetLinkerNonDarwinPlugin() {
73 System.setProperty("os.name", "Microsoft Windows");
74 final GccLinker linker = GccLinker.getInstance();
75 final OutputTypeEnum outputType = new OutputTypeEnum();
76 outputType.setValue("plugin");
77 final LinkType linkType = new LinkType();
78 linkType.setOutputType(outputType);
79 final Linker pluginLinker = linker.getLinker(linkType);
80 assertEquals("libfoo.so", pluginLinker.getOutputFileNames("foo", null)[0]);
81 }
82
83 public void testGetLinkerNonDarwinShared() {
84 System.setProperty("os.name", "Microsoft Windows");
85 final GccLinker linker = GccLinker.getInstance();
86 final OutputTypeEnum outputType = new OutputTypeEnum();
87 outputType.setValue("shared");
88 final LinkType linkType = new LinkType();
89 linkType.setOutputType(outputType);
90 final Linker sharedLinker = linker.getLinker(linkType);
91 assertEquals("libfoo.so", sharedLinker.getOutputFileNames("foo", null)[0]);
92 }
93 }