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 com.github.maven_nar.cpptasks.compiler.AbstractProcessor;
23  import com.github.maven_nar.cpptasks.compiler.TestAbstractLinker;
24  
25  /**
26   * Tests for classes that derive from AbstractArLibrarian
27   *
28   * @author CurtA
29   */
30  public class TestAbstractArLibrarian extends TestAbstractLinker {
31    /**
32     * Constructor
33     * 
34     * @param name
35     *          test name
36     * @see junit.framework.TestCase#TestCase(String)
37     */
38    public TestAbstractArLibrarian(final String name) {
39      super(name);
40    }
41  
42    /**
43     * Creates item under test @returns item under test
44     * 
45     * @see com.github.maven_nar.cpptasks.compiler.TestAbstractProcessor#create()
46     */
47    @Override
48    protected AbstractProcessor create() {
49      return GccLibrarian.getInstance();
50    }
51  
52    /**
53     * Override of
54     * 
55     * @see com.github.maven_nar.cpptasks.compiler.TestAbstractProcessor#testBid()
56     */
57    @Override
58    public void testBid() {
59      final AbstractProcessor compiler = create();
60      final int bid = compiler.bid("c:/foo\\bar\\hello.o");
61      assertEquals(AbstractProcessor.DEFAULT_PROCESS_BID, bid);
62    }
63  
64    @Override
65    public void testGetIdentfier() {
66      final AbstractProcessor processor = create();
67      final String id = processor.getIdentifier();
68      assertTrue(id.contains("ar"));
69    }
70  
71    /**
72     * Tests for library patterns
73     * 
74     * See patch [ 676276 ] Enhanced support for Mac OS X
75     */
76    public void testGetLibraryPatterns() {
77      final String[] libnames = new String[] {
78        "foo"
79      };
80      final String[] patterns = ((AbstractArLibrarian) create()).getLibraryPatterns(libnames, null);
81      assertEquals(0, patterns.length);
82    }
83  
84    /**
85     * Tests output file for ar library
86     * 
87     * See bug [ 687732 ] Filenames for gcc static library does start with lib
88     */
89    public void testOutputFileName() {
90      final String[] outputFiles = GccLibrarian.getInstance().getOutputFileNames("x", null);
91      assertEquals("libx.a", outputFiles[0]);
92    }
93  }