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.compiler;
21
22 import java.io.File;
23
24 import com.github.maven_nar.cpptasks.CCTask;
25 import com.github.maven_nar.cpptasks.LinkerDef;
26 import com.github.maven_nar.cpptasks.ProcessorDef;
27 import com.github.maven_nar.cpptasks.TargetDef;
28 import com.github.maven_nar.cpptasks.VersionInfo;
29 import com.github.maven_nar.cpptasks.types.LibraryTypeEnum;
30
31
32
33
34
35
36 public class TestAbstractLinker extends TestAbstractProcessor {
37 private class DummyAbstractLinker extends AbstractLinker {
38 public DummyAbstractLinker() {
39 super(new String[] {
40 ".obj", ".lib"
41 }, new String[] {
42 ".map", ".exp"
43 });
44 }
45
46 @Override
47 public LinkerConfiguration createConfiguration(final CCTask task, final LinkType linkType,
48 final ProcessorDef[] def1, final LinkerDef def2, final TargetDef targetPlatform, final VersionInfo versionInfo) {
49 return null;
50 }
51
52 @Override
53 public String getIdentifier() {
54 return "dummy";
55 }
56
57 @Override
58 public File[] getLibraryPath() {
59 return new File[0];
60 }
61
62 @Override
63 public String[] getLibraryPatterns(final String[] libnames, final LibraryTypeEnum libType) {
64 return libnames;
65 }
66
67 @Override
68 public Linker getLinker(final LinkType type) {
69 return null;
70 }
71
72 @Override
73 public String[] getOutputFileNames(final String sourceFile, final VersionInfo versionInfo) {
74 return new String[0];
75 }
76
77 public String[][] getRuntimeLibraries(final boolean debug, final boolean multithreaded, final boolean staticLink) {
78 return new String[2][0];
79 }
80
81 @Override
82 public boolean isCaseSensitive() {
83 return true;
84 }
85 }
86
87 public TestAbstractLinker(final String name) {
88 super(name);
89 }
90
91 @Override
92 protected AbstractProcessor create() {
93 return new DummyAbstractLinker();
94 }
95
96 public void testBid() {
97 final AbstractProcessor compiler = create();
98 int bid = compiler.bid("c:/foo\\bar\\hello.obj");
99 assertEquals(100, bid);
100 bid = compiler.bid("c:/foo\\bar/hello.lib");
101 assertEquals(100, bid);
102 bid = compiler.bid("c:/foo\\bar\\hello.map");
103 assertEquals(0, bid);
104 bid = compiler.bid("c:/foo\\bar/hello.map");
105 assertEquals(0, bid);
106 bid = compiler.bid("c:/foo\\bar/hello.c");
107 assertEquals(1, bid);
108 bid = compiler.bid("c:/foo\\bar/hello.cpp");
109 assertEquals(1, bid);
110 }
111 }