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.gcc;
21  
22  import java.io.File;
23  
24  import com.github.maven_nar.cpptasks.compiler.AbstractProcessor;
25  import com.github.maven_nar.cpptasks.parser.CParser;
26  import com.github.maven_nar.cpptasks.parser.FortranParser;
27  import com.github.maven_nar.cpptasks.parser.Parser;
28  
29  /**
30   * Test gcc compiler adapter
31   * 
32   */
33  public class TestGccCCompiler extends TestGccCompatibleCCompiler {
34    public TestGccCCompiler(final String name) {
35      super(name);
36    }
37  
38    @Override
39    protected GccCompatibleCCompiler create() {
40      return GccCCompiler.getInstance();
41    }
42  
43    public void testBidObjectiveAssembly() {
44      final GccCCompiler compiler = GccCCompiler.getInstance();
45      assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler.bid("foo.s"));
46    }
47  
48    public void testBidObjectiveC() {
49      final GccCCompiler compiler = GccCCompiler.getInstance();
50      assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler.bid("foo.m"));
51    }
52  
53    public void testBidObjectiveCpp() {
54      final GccCCompiler compiler = GccCCompiler.getInstance();
55      assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler.bid("foo.mm"));
56    }
57  
58    public void testBidPreprocessedCpp() {
59      final GccCCompiler compiler = GccCCompiler.getInstance();
60      assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, compiler.bid("foo.ii"));
61    }
62  
63    public void testCreateCParser1() {
64      final Parser parser = GccCCompiler.getInstance().createParser(new File("foo.c"));
65      assertTrue(parser instanceof CParser);
66    }
67  
68    public void testCreateCParser2() {
69      final Parser parser = GccCCompiler.getInstance().createParser(new File("foo."));
70      assertTrue(parser instanceof CParser);
71    }
72  
73    public void testCreateCParser3() {
74      final Parser parser = GccCCompiler.getInstance().createParser(new File("foo"));
75      assertTrue(parser instanceof CParser);
76    }
77  
78    public void testCreateFortranParser1() {
79      final Parser parser = GccCCompiler.getInstance().createParser(new File("foo.f"));
80      assertTrue(parser instanceof FortranParser);
81    }
82  
83    public void testCreateFortranParser2() {
84      final Parser parser = GccCCompiler.getInstance().createParser(new File("foo.FoR"));
85      assertTrue(parser instanceof FortranParser);
86    }
87  
88    public void testCreateFortranParser3() {
89      final Parser parser = GccCCompiler.getInstance().createParser(new File("foo.f90"));
90      assertTrue(parser instanceof FortranParser);
91    }
92  
93  }