Debian Codegraph @

test/footleg/cavesurvey/regression/PocketTopoToSurvexTest.java

raw symbols SCIP
1 /**
2 * Copyright (C) 2009-2016 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.regression;
20
21 import static org.junit.Assert.*;
22
23 import java.io.FileNotFoundException;
24 import java.text.ParseException;
25
26 import org.junit.Test;
27
28 import footleg.cavesurvey.converter.CaveConverter.CmdlineOpt;
29 import footleg.cavesurvey.converter.CaveConverter.CmdlineSplaysOpt;
30 import footleg.cavesurvey.regression.RunFileConverter;
31 import footleg.cavesurvey.tools.TestHelper;
32
33 /**
34 * Regression test class which runs data file conversions and compares the output with reference
35 * files. Tests pass if the output file is identical to the reference file. A file name prefix
36 * is given as the argument for each test conversion. The test will look for an input file with
37 * this prefix and the suffix '_in.txt' and compare the output with a reference file with
38 * this prefix and the suffix '_ref.svx'.
39 *
40 * @author Footleg
41 * @version 2016.12.14 (ISO 8601 YYYY.MM.DD)
42 * @since 1.6 (The Java version used)
43 */
44 public class PocketTopoToSurvexTest {
45
46 @Test
47 public void testPocketTopoToSurvexGourAven() throws ParseException, FileNotFoundException {
48 //Test for older JRE as test result is different due to JRE rounding bug
49 boolean oldJRE = TestHelper.jreRoundingBug();
50 RunFileConverter.setOldJRE(oldJRE);
51 //Convert PocketTopo text export file to Survex format data
52 String fileCompare = RunFileConverter.convertPocketTopoToSurvex( "GourAven", CmdlineSplaysOpt.Default, CmdlineOpt.T,
53 RunFileConverter.defaultCharset );
54 //Reset oldJRE flag for subsequent tests
55 RunFileConverter.setOldJRE(false);
56 assertEquals("Comparing GourAven survex file from PocketTopo with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
57 }
58
59 @Test
60 public void testPocketTopoToSurvexHSC() throws ParseException, FileNotFoundException {
61 //Convert PocketTopo text export file to Survex format data
62 String fileCompare = RunFileConverter.convertPocketTopoToSurvex( "HSC", CmdlineSplaysOpt.Default, CmdlineOpt.T,
63 RunFileConverter.defaultCharset );
64 assertEquals("Comparing HSC survex file from PocketTopo with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
65 }
66
67 @Test
68 public void testPocketTopoToSurvexStomps() throws ParseException, FileNotFoundException {
69 //Test for older JRE as test result is different due to JRE rounding bug
70 boolean oldJRE = TestHelper.jreRoundingBug();
71 RunFileConverter.setOldJRE(oldJRE);
72 //Convert PocketTopo text export file to Survex format data
73 String fileCompare = RunFileConverter.convertPocketTopoToSurvex( "Stomps", CmdlineSplaysOpt.Default, CmdlineOpt.T,
74 RunFileConverter.defaultCharset );
75 //Reset oldJRE flag for subsequent tests
76 RunFileConverter.setOldJRE(false);
77 assertEquals("Comparing Stomps survex file from PocketTopo with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
78 }
79
80 @Test
81 public void testPocketTopoToSurvexUzuGour() throws ParseException, FileNotFoundException {
82 //Convert PocketTopo text export file to Survex format data
83 String fileCompare = RunFileConverter.convertPocketTopoToSurvex( "Uzu-Gour", CmdlineSplaysOpt.Default, CmdlineOpt.T,
84 RunFileConverter.defaultCharset );
85 assertEquals("Comparing Uzu-Gour survex file from PocketTopo with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
86 }
87
88 @Test
89 public void testPocketTopoToSurvexSwil20120909() throws ParseException, FileNotFoundException {
90 //Test for older JRE as test result is different due to JRE rounding bug
91 boolean oldJRE = TestHelper.jreRoundingBug();
92 RunFileConverter.setOldJRE(oldJRE);
93 //Convert PocketTopo text export file to Survex format data
94 String fileCompare = RunFileConverter.convertPocketTopoToSurvex( "Swil20120909", CmdlineSplaysOpt.Default, CmdlineOpt.T,
95 RunFileConverter.defaultCharset );
96 //Reset oldJRE flag for subsequent tests
97 RunFileConverter.setOldJRE(false);
98 assertEquals("Comparing Swil20120909 survex file from PocketTopo with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
99 }
100
101 @Test
102 public void testPocketTopoToSurvexSloppy2ZigZags() throws ParseException, FileNotFoundException {
103 //Test for older JRE as test result is different due to JRE rounding bug
104 boolean oldJRE = TestHelper.jreRoundingBug();
105 RunFileConverter.setOldJRE(oldJRE);
106 //Convert PocketTopo text export file to Survex format data
107 String fileCompare = RunFileConverter.convertPocketTopoToSurvex( "Sloppy2ZigZags", CmdlineSplaysOpt.Default, CmdlineOpt.T,
108 RunFileConverter.defaultCharset );
109 //Reset oldJRE flag for subsequent tests
110 RunFileConverter.setOldJRE(false);
111 assertEquals("Comparing Sloppy2ZigZags survex file from PocketTopo with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
112 }
113
114 @Test
115 public void testPocketTopoToSurvexT_LRUD() throws ParseException, FileNotFoundException {
116 //Test for older JRE as test result is different due to JRE rounding bug
117 boolean oldJRE = TestHelper.jreRoundingBug();
118 RunFileConverter.setOldJRE(oldJRE);
119
120 //Convert PocketTopo text export file to Survex format data
121 /* This was a particularly difficult case for LRUD generation in Survex as reverse legs get put
122 * into a passage data block after the first leg in the passage data was forwards, so the rest
123 * of the block got built with all the LRUD backwards. This case is now fixed and it detects the
124 * 2nd leg going into the block does not follow the leg already added and put it before that leg
125 * in the block, resulting the data being in the correct order.
126 */
127 String fileCompare = RunFileConverter.convertPocketTopoToSurvex( "T_LRUD", CmdlineSplaysOpt.Default, CmdlineOpt.T,
128 RunFileConverter.defaultCharset );
129 //Reset oldJRE flag for subsequent tests
130 RunFileConverter.setOldJRE(false);
131 assertEquals("Comparing T_LRUD survex file from PocketTopo with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
132 }
133
134 @Test
135 public void testPocketTopoToSurvexTripComment() throws ParseException, FileNotFoundException {
136 //Test for older JRE as test result is different due to JRE rounding bug
137 boolean oldJRE = TestHelper.jreRoundingBug();
138 RunFileConverter.setOldJRE(oldJRE);
139 //Convert PocketTopo text export file to Survex format data
140 String fileCompare = RunFileConverter.convertPocketTopoToSurvex( "TripComment", CmdlineSplaysOpt.Default, CmdlineOpt.T,
141 RunFileConverter.defaultCharset );
142 //Reset oldJRE flag for subsequent tests
143 RunFileConverter.setOldJRE(false);
144 assertEquals("Comparing TripComment survex file from PocketTopo with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
145 }
146
147 }