Debian Codegraph @

test/footleg/cavesurvey/regression/SurvexToSurvexTest.java

raw symbols SCIP
1 /**
2 * Copyright (C) 2009-2017 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
31 /**
32 * Regression test class which runs data file conversions and compares the output with reference
33 * files. Tests pass if the output file is identical to the reference file. A file name prefix
34 * is given as the argument for each test conversion. The test will look for an input file with
35 * this prefix and the suffix '_in.svx' and compare the output with a reference file with
36 * this prefix and the suffix '_ref.svx'.
37 *
38 * @author Footleg
39 * @version 2017.01.12 (ISO 8601 YYYY.MM.DD)
40 * @since 1.6 (The Java version used)
41 */
42 public class SurvexToSurvexTest {
43
44 @Test
45 public void testNightMare() throws ParseException, FileNotFoundException {
46 //Read and Write Survex format data
47 String fileCompare = RunFileConverter.convertSurvexToSurvex( "NightMare", CmdlineSplaysOpt.Default, CmdlineOpt.T,
48 RunFileConverter.defaultCharset );
49 assertEquals("Comparing NightMare Survex file from Survex with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
50 }
51
52 @Test
53 public void testCalibrations() throws ParseException, FileNotFoundException {
54 //Read and Write Survex format data
55 String fileCompare = RunFileConverter.convertSurvexToSurvex( "calibrations", CmdlineSplaysOpt.Default, CmdlineOpt.T,
56 RunFileConverter.defaultCharset );
57 assertEquals("Comparing calibrations Survex file from Survex with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
58 }
59
60 @Test
61 public void testDataOrder() throws ParseException, FileNotFoundException {
62 //Read and Write Survex format data
63 String fileCompare = RunFileConverter.convertSurvexToSurvex( "survex_different_data_order", CmdlineSplaysOpt.Default,
64 CmdlineOpt.F, RunFileConverter.defaultCharset );
65 assertEquals("Comparing variations in data order Survex file from Survex with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
66 }
67
68 @Test
69 public void testNestedDataOrder() throws ParseException, FileNotFoundException {
70 //Read and Write Survex format data
71 String fileCompare = RunFileConverter.convertSurvexToSurvex( "survex_data_order_nested", CmdlineSplaysOpt.Default,
72 CmdlineOpt.F, RunFileConverter.defaultCharset );
73 assertEquals("Comparing variations in nested data order Survex file from Survex with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
74 }
75
76 @Test
77 public void testFlags() throws ParseException, FileNotFoundException {
78 //Read and Write Survex format data
79 String fileCompare = RunFileConverter.convertSurvexToSurvex( "flags", CmdlineSplaysOpt.Default, CmdlineOpt.F,
80 RunFileConverter.defaultCharset );
81 assertEquals("Comparing flags Survex file from Survex with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
82 }
83
84 @Test
85 public void testNestedFlags() throws ParseException, FileNotFoundException {
86 //Read and Write Survex format data
87 String fileCompare = RunFileConverter.convertSurvexToSurvex( "nested_series_flags", CmdlineSplaysOpt.Named, CmdlineOpt.F,
88 RunFileConverter.defaultCharset );
89 assertEquals("Comparing nested flags Survex file from Survex with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
90 }
91
92 @Test
93 public void testNosurvey() throws ParseException, FileNotFoundException {
94 //Read and Write Survex format data
95 String fileCompare = RunFileConverter.convertSurvexToSurvex( "nosurvey", CmdlineSplaysOpt.Default, CmdlineOpt.F,
96 RunFileConverter.defaultCharset );
97 assertEquals("Comparing nosurvey Survex file from Survex with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
98 }
99
100 @Test
101 public void testAnonymousBlocks() throws ParseException, FileNotFoundException {
102 //Read and Write Survex format data
103 String fileCompare = RunFileConverter.convertSurvexToSurvex( "anonymous_blocks", CmdlineSplaysOpt.Named, CmdlineOpt.F,
104 RunFileConverter.defaultCharset );
105 assertEquals("Comparing anonymous blocks Survex file from Survex with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
106 }
107
108 @Test
109 public void testUnits() throws ParseException, FileNotFoundException {
110 //Read and Write Survex format data using different units representations
111 String fileCompare = RunFileConverter.convertSurvexToSurvex( "units_test", CmdlineSplaysOpt.Default,
112 CmdlineOpt.F, RunFileConverter.defaultCharset );
113 assertEquals("Comparing all units Survex file from Survex with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
114 }
115
116 @Test
117 public void testSurvexEverything() throws ParseException, FileNotFoundException {
118 //Read and Write Survex format data containing everything a Survex file can contain
119 String fileCompare = RunFileConverter.convertSurvexToSurvex( "survex_everything", CmdlineSplaysOpt.Anon,
120 CmdlineOpt.F, RunFileConverter.defaultCharset );
121 assertEquals("Comparing Survex file from Survex file containing everything survex supports with reference.", DiffFiles.FILES_IDENTICAL, fileCompare);
122 }
123
124 @Test
125 public void testSwilEntNosplays() throws ParseException, FileNotFoundException {
126 //Read and Write Survex format data, removing splays
127 String fileCompare = RunFileConverter.convertUsingCmdLine("SwilEnt", 's', 's', "nosplays lrud");
128 assertEquals("Comparing SwilEnt Survex file from Survex with reference, removing splays.", DiffFiles.FILES_IDENTICAL, fileCompare);
129 }
130
131 @Test
132 public void testSwilEntSplaysLRUD() throws ParseException, FileNotFoundException {
133 //Read and Write Survex format data, removing splays
134 String fileCompare = RunFileConverter.convertUsingCmdLine("SwilEnt", 's', 's', "splays lrud");
135 assertEquals("Comparing SwilEnt Survex file from Survex with reference, removing splays.", DiffFiles.FILES_IDENTICAL, fileCompare);
136 }
137
138 }