Debian Codegraph @

test/footleg/cavesurvey/converter/CaveConverterTest.java

raw symbols SCIP
1 /**
2 * Copyright (C) 2009-2015 Paul Fretwell - aka 'Footleg' ([email protected])
3 *
4 * This file is part of Cave Converter.
5 *
6 * Cave Converter is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Cave Converter is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Cave Converter. If not, see <http://www.gnu.org/licenses/>.
18 */
19 package footleg.cavesurvey.converter;
20
21 import static org.junit.Assert.*;
22
23 import org.junit.Test;
24
25 import footleg.cavesurvey.converter.CaveConverter.SurveyDataInputFormats;
26 import footleg.cavesurvey.converter.CaveConverter.SurveyDataOutputFormats;
27
28 /**
29 * Unit test class for {@link footleg.cavesurvey.converter.CaveConverter}
30 *
31 * @author Footleg
32 * @version 2015.08.09 (ISO 8601 YYYY.MM.DD)
33 * @since 1.6 (The Java version used)
34 */
35 public class CaveConverterTest {
36
37 /**
38 * Test method for {@link footleg.cavesurvey.converter.CaveConverter#getFormatName(SurveyDataInputFormats)}.
39 */
40 @Test
41 public void testGetFormatNameSurveyDataInputFormats() {
42 String testCompassDisplayName = CaveConverter.getFormatName( SurveyDataInputFormats.Compass );
43 assertEquals("Test correct display name is returned for format", "Compass", testCompassDisplayName);
44
45 String testDXFDisplayName = CaveConverter.getFormatName( SurveyDataInputFormats.DXF );
46 assertEquals("Test correct display name is returned for format", "DXF", testDXFDisplayName);
47
48 String testPocketTopoDisplayName = CaveConverter.getFormatName( SurveyDataInputFormats.PocketTopo );
49 assertEquals("Test correct display name is returned for format", "PocketTopo", testPocketTopoDisplayName);
50
51 String testSurvexDisplayName = CaveConverter.getFormatName( SurveyDataInputFormats.Survex );
52 assertEquals("Test correct display name is returned for format", "Survex", testSurvexDisplayName);
53 }
54
55 /**
56 * Test method for {@link footleg.cavesurvey.converter.CaveConverter#getFormatName(SurveyDataOutputFormats)}.
57 */
58 @Test
59 public void testGetFormatNameSurveyDataOutputFormats() {
60 String testSurvexDisplayName = CaveConverter.getFormatName( SurveyDataOutputFormats.Survex );
61 assertEquals("Test correct display name is returned for format", "Survex", testSurvexDisplayName);
62
63 String testToporobotDisplayName = CaveConverter.getFormatName( SurveyDataOutputFormats.Toporobot );
64 assertEquals("Test correct display name is returned for format", "Toporobot", testToporobotDisplayName);
65 }
66
67 /**
68 * Test method for {@link footleg.cavesurvey.converter.CaveConverter#getFormatName(SurveyDataOutputFormats)}.
69 */
70 @Test
71 public void testInputFormatFromFileExtn() {
72 //Compass files
73 SurveyDataInputFormats testCompassL = CaveConverter.inputFormatFromFileExtn( "dat" );
74 assertEquals("Test correct format is returned for Compass DAT file (lowercase extn)", SurveyDataInputFormats.Compass, testCompassL);
75
76 SurveyDataInputFormats testCompassU = CaveConverter.inputFormatFromFileExtn( "DAT" );
77 assertEquals("Test correct format is returned for Compass DAT file (uppercase extn)", SurveyDataInputFormats.Compass, testCompassU);
78
79 SurveyDataInputFormats testCompassM = CaveConverter.inputFormatFromFileExtn( "dAt" );
80 assertEquals("Test correct format is returned for Compass DAT file (mixedcase extn)", SurveyDataInputFormats.Compass, testCompassM);
81
82 //DXF files
83 SurveyDataInputFormats testDXFL = CaveConverter.inputFormatFromFileExtn( "dxf" );
84 assertEquals("Test correct format is returned for DXF DAT file (lowercase extn)", SurveyDataInputFormats.DXF, testDXFL);
85
86 SurveyDataInputFormats testDXFU = CaveConverter.inputFormatFromFileExtn( "DXF" );
87 assertEquals("Test correct format is returned for DXF DAT file (uppercase extn)", SurveyDataInputFormats.DXF, testDXFU);
88
89 SurveyDataInputFormats testDXFM = CaveConverter.inputFormatFromFileExtn( "dXf" );
90 assertEquals("Test correct format is returned for DXF DAT file (mixedcase extn)", SurveyDataInputFormats.DXF, testDXFM);
91
92 //PocketTopo files
93 SurveyDataInputFormats testPocketTopoL = CaveConverter.inputFormatFromFileExtn( "txt" );
94 assertEquals("Test correct format is returned for PocketTopo DAT file (lowercase extn)", SurveyDataInputFormats.PocketTopo, testPocketTopoL);
95
96 SurveyDataInputFormats testPocketTopoU = CaveConverter.inputFormatFromFileExtn( "TXT" );
97 assertEquals("Test correct format is returned for PocketTopo DAT file (uppercase extn)", SurveyDataInputFormats.PocketTopo, testPocketTopoU);
98
99 SurveyDataInputFormats testPocketTopoM = CaveConverter.inputFormatFromFileExtn( "tXt" );
100 assertEquals("Test correct format is returned for PocketTopo DAT file (mixedcase extn)", SurveyDataInputFormats.PocketTopo, testPocketTopoM);
101
102 //Survex files
103 SurveyDataInputFormats testSurvexL = CaveConverter.inputFormatFromFileExtn( "svx" );
104 assertEquals("Test correct format is returned for Survex DAT file (lowercase extn)", SurveyDataInputFormats.Survex, testSurvexL);
105
106 SurveyDataInputFormats testSurvexU = CaveConverter.inputFormatFromFileExtn( "SVX" );
107 assertEquals("Test correct format is returned for Survex DAT file (uppercase extn)", SurveyDataInputFormats.Survex, testSurvexU);
108
109 SurveyDataInputFormats testSurvexM = CaveConverter.inputFormatFromFileExtn( "sVx" );
110 assertEquals("Test correct format is returned for Survex DAT file (mixedcase extn)", SurveyDataInputFormats.Survex, testSurvexM);
111
112 //Unknown
113 SurveyDataInputFormats testUnknown = CaveConverter.inputFormatFromFileExtn( "xml" );
114 assertEquals("Test null returned for unsupported file extn", null, testUnknown);
115 }
116
117 }