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 junit.framework.TestCase;
23
24
25
26 public abstract class TestCompilerConfiguration extends TestCase {
27 public TestCompilerConfiguration(final String name) {
28 super(name);
29 }
30
31 protected abstract CompilerConfiguration create();
32
33 public String getObjectFileExtension() {
34 return ".o";
35 }
36
37 public void testBid() {
38 final CompilerConfiguration compiler = create();
39 int bid = compiler.bid("c:/foo\\bar\\hello.c");
40 assertEquals(100, bid);
41 bid = compiler.bid("c:/foo\\bar/hello.c");
42 assertEquals(100, bid);
43 bid = compiler.bid("c:/foo\\bar\\hello.h");
44 assertEquals(1, bid);
45 bid = compiler.bid("c:/foo\\bar/hello.h");
46 assertEquals(1, bid);
47 bid = compiler.bid("c:/foo\\bar/hello.pas");
48 assertEquals(0, bid);
49 bid = compiler.bid("c:/foo\\bar/hello.java");
50 assertEquals(0, bid);
51 }
52
53 public void testGetOutputFileName1() {
54 final CompilerConfiguration compiler = create();
55 final String input = "c:/foo\\bar\\hello.c";
56
57
58
59 try {
60 final String[] output = compiler.getOutputFileNames(input, null);
61 } catch (final java.lang.IllegalStateException ex) {
62 }
63 }
64
65 public void testGetOutputFileName2() {
66 final CompilerConfiguration compiler = create();
67
68 String[] output = compiler.getOutputFileNames("c:/foo/bar/hello.c", null);
69 String[] output2 = compiler.getOutputFileNames("c:/foo/bar/fake/../hello.c", null);
70 assertEquals(output[0], output2[0]);
71
72 output = compiler.getOutputFileNames("hello.c", null);
73 assertNotSame(output[0], output2[0]);
74
75 output2 = compiler.getOutputFileNames("fake/../hello.c", null);
76 assertEquals(output[0], output2[0]);
77
78 output = compiler.getOutputFileNames("c:/foo/bar/hello.h", null);
79 assertEquals(0, output.length);
80 output = compiler.getOutputFileNames("c:/foo/bar/fake/../hello.h", null);
81 assertEquals(0, output.length);
82 }
83 }