View Javadoc

1   /*
2    * #%L
3    * Native ARchive plugin for Maven
4    * %%
5    * Copyright (C) 2002 - 2014 NAR Maven Plugin developers.
6    * %%
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * 
11   * http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package com.github.maven_nar.cpptasks.sun;
21  
22  import java.util.Vector;
23  
24  import junit.framework.TestCase;
25  
26  import com.github.maven_nar.cpptasks.compiler.AbstractProcessor;
27  
28  /**
29   * Test Sun Forte compiler adapter
30   * 
31   */
32  // TODO Since ForteCCCompiler extends GccCompatibleCCompiler, this test
33  // should probably extend TestGccCompatibleCCompiler.
34  public class TestForteCCCompiler extends TestCase {
35    public TestForteCCCompiler(final String name) {
36      super(name);
37    }
38  
39    public void testBidAssembly() {
40      final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
41      assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler.bid("foo.s"));
42    }
43  
44    public void testBidC() {
45      final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
46      assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler.bid("foo.c"));
47    }
48  
49    public void testBidCpp() {
50      final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
51      assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler.bid("foo.C"));
52    }
53  
54    public void testBidCpp2() {
55      final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
56      assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler.bid("foo.cc"));
57    }
58  
59    public void testBidCpp3() {
60      final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
61      assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler.bid("foo.cxx"));
62    }
63  
64    public void testBidCpp4() {
65      final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
66      assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler.bid("foo.cpp"));
67    }
68  
69    public void testBidCpp5() {
70      final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
71      assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler.bid("foo.c++"));
72    }
73  
74    public void testBidPreprocessed() {
75      final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
76      assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler.bid("foo.i"));
77    }
78  
79    /**
80     * Tests command line switches for warning = 0
81     */
82    public void testWarningLevel0() {
83      final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
84      final Vector args = new Vector();
85      compiler.addWarningSwitch(args, 0);
86      assertEquals(1, args.size());
87      assertEquals("-w", args.elementAt(0));
88    }
89  
90    /**
91     * Tests command line switches for warning = 1
92     */
93    public void testWarningLevel1() {
94      final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
95      final Vector args = new Vector();
96      compiler.addWarningSwitch(args, 1);
97      assertEquals(0, args.size());
98    }
99  
100   /**
101    * Tests command line switches for warning = 2
102    */
103   public void testWarningLevel2() {
104     final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
105     final Vector args = new Vector();
106     compiler.addWarningSwitch(args, 2);
107     assertEquals(0, args.size());
108   }
109 
110   /**
111    * Tests command line switches for warning = 3
112    */
113   public void testWarningLevel3() {
114     final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
115     final Vector args = new Vector();
116     compiler.addWarningSwitch(args, 3);
117     assertEquals(1, args.size());
118     assertEquals("+w", args.elementAt(0));
119   }
120 
121   /**
122    * Tests command line switches for warning = 4
123    */
124   public void testWarningLevel4() {
125     final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
126     final Vector args = new Vector();
127     compiler.addWarningSwitch(args, 4);
128     assertEquals(1, args.size());
129     assertEquals("+w2", args.elementAt(0));
130   }
131 
132   /**
133    * Tests command line switches for warning = 5
134    */
135   public void testWarningLevel5() {
136     final ForteCCCompiler compiler = ForteCCCompiler.getInstance();
137     final Vector args = new Vector();
138     compiler.addWarningSwitch(args, 5);
139     assertEquals(2, args.size());
140     assertEquals("+w2", args.elementAt(0));
141     assertEquals("-xwe", args.elementAt(1));
142   }
143 }