@@ -24,15 +24,10 @@ public class VariationUnparserTest {
2424
2525 private final static String testCaseSuffixDiff = ".diff" ;
2626
27- protected static Stream <Path > findTestCases (Path dir , String testCaseSuffix ) {
28- try {
29- return Files
30- .list (dir )
31- .filter (filename -> filename .getFileName ().toString ().endsWith (testCaseSuffix ));
32- } catch (Exception e ) {
33- e .printStackTrace ();
34- }
35- return null ;
27+ protected static Stream <Path > findTestCases (Path dir , String testCaseSuffix ) throws IOException {
28+ return Files
29+ .list (dir )
30+ .filter (filename -> filename .getFileName ().toString ().endsWith (testCaseSuffix ));
3631 }
3732
3833 public static Stream <Path > testsTree () throws IOException {
@@ -56,56 +51,38 @@ public void testDiffDir(Path basename) throws IOException, DiffParseException {
5651 }
5752
5853 @ Test
59- public void testTree () {
60- String source = "" ;
61- String temp = "" ;
62- try {
63- source = Files .readString (Path .of ("src" , "test" , "resources" , "unparser" , "test8.txt" ));
64- VariationTree <DiffLinesLabel > tree = VariationTree .fromText (source , VariationTreeSource .Unknown ,
65- VariationDiffParseOptions .Default );
66- temp = VariationUnparser .variationTreeUnparser (tree );
67- System .out .println (removeWhitespace (source , false ).equals (removeWhitespace (temp , false )));
68- // System.out.println(removeWhitespace(source));
69- // System.out.println("Ende");
70- // System.out.println(removeWhitespace(temp));
71- // System.out.println("Ende");
72- } catch (Exception e ) {
73- e .printStackTrace ();
74- }
54+ public void testTree () throws IOException , DiffParseException {
55+ String source = Files .readString (Path .of ("src" , "test" , "resources" , "unparser" , "test8.txt" ));
56+ VariationTree <DiffLinesLabel > tree = VariationTree .fromText (source , VariationTreeSource .Unknown ,
57+ VariationDiffParseOptions .Default );
58+ String temp = VariationUnparser .variationTreeUnparser (tree );
59+ System .out .println (removeWhitespace (source , false ).equals (removeWhitespace (temp , false )));
60+ // System.out.println(removeWhitespace(source));
61+ // System.out.println("Ende");
62+ // System.out.println(removeWhitespace(temp));
63+ // System.out.println("Ende");
7564 }
7665
7766 @ Test
78- public void testDiffSemEq () {
79- String source = "" ;
80- String temp = "" ;
81- try {
82-
83- source = Files
84- .readString (Path .of ("src" , "test" , "resources" , "unparser" , "diff" , "diff.diff" ));
85- VariationDiff <DiffLinesLabel > diff = VariationDiff .fromDiff (source , VariationDiffParseOptions .Default );
86- temp = VariationUnparser .variationDiffUnparser (diff );
87- System .out .println (removeWhitespace (source , true ).equals (removeWhitespace (temp , true )));
88- System .out .println (removeWhitespace (VariationUnparser .undiff (source , Time .BEFORE ), false )
89- .equals (removeWhitespace (VariationUnparser .undiff (temp , Time .BEFORE ), false )));
90- System .out .println (removeWhitespace (VariationUnparser .undiff (source , Time .AFTER ), false )
91- .equals (removeWhitespace (VariationUnparser .undiff (temp , Time .AFTER ), false )));
92-
93- // System.out.println(removeWhitespace(source));
94- // System.out.println("Ende");
95- // System.out.println(removeWhitespace(temp));
96- // System.out.println("Ende");
97- } catch (Exception e ) {
98- e .printStackTrace ();
99- }
67+ public void testDiffSemEq () throws IOException , DiffParseException {
68+ String source = Files
69+ .readString (Path .of ("src" , "test" , "resources" , "unparser" , "diff" , "diff.diff" ));
70+ VariationDiff <DiffLinesLabel > diff = VariationDiff .fromDiff (source , VariationDiffParseOptions .Default );
71+ String temp = VariationUnparser .variationDiffUnparser (diff );
72+ System .out .println (removeWhitespace (source , true ).equals (removeWhitespace (temp , true )));
73+ System .out .println (removeWhitespace (VariationUnparser .undiff (source , Time .BEFORE ), false )
74+ .equals (removeWhitespace (VariationUnparser .undiff (temp , Time .BEFORE ), false )));
75+ System .out .println (removeWhitespace (VariationUnparser .undiff (source , Time .AFTER ), false )
76+ .equals (removeWhitespace (VariationUnparser .undiff (temp , Time .AFTER ), false )));
77+
78+ // System.out.println(removeWhitespace(source));
79+ // System.out.println("Ende");
80+ // System.out.println(removeWhitespace(temp));
81+ // System.out.println("Ende");
10082 }
10183
102- public static void testCaseTree (Path testCasePath ) {
103- String temp = "" ;
104- try {
105- temp = Files .readString (testCasePath );
106- } catch (Exception e ) {
107- e .printStackTrace ();
108- }
84+ public static void testCaseTree (Path testCasePath ) throws IOException , DiffParseException {
85+ String temp = Files .readString (testCasePath );
10986 System .out .println (testCasePath );
11087 temp = temp .replaceAll ("\\ r\\ n" , "\n " );
11188 String unparse1 = parseUnparseTree (testCasePath , new VariationDiffParseOptions (false , false ));
@@ -123,13 +100,8 @@ public static void testCaseTree(Path testCasePath) {
123100 + temp .equals (unparse4 ));
124101 }
125102
126- public static void testCaseDiff (Path testCasePath ) {
127- String temp = "" ;
128- try {
129- temp = Files .readString (testCasePath );
130- } catch (Exception e ) {
131- e .printStackTrace ();
132- }
103+ public static void testCaseDiff (Path testCasePath ) throws IOException , DiffParseException {
104+ String temp = Files .readString (testCasePath );
133105 System .out .println (testCasePath );
134106 temp = temp .replaceAll ("\\ r\\ n" , "\n " );
135107 String unparse1 = parseUnparseDiff (testCasePath , new VariationDiffParseOptions (false , false ));
@@ -168,25 +140,13 @@ public static void testCaseDiff(Path testCasePath) {
168140 + temp .equals (unparse4 ));
169141 }
170142
171- public static String parseUnparseTree (Path path , VariationDiffParseOptions option ) {
172- String temp = "b" ;
173- try {
174- VariationTree <DiffLinesLabel > tree = VariationTree .fromFile (path , option );
175- temp = VariationUnparser .variationTreeUnparser (tree );
176- } catch (Exception e ) {
177- e .printStackTrace ();
178- }
179- return temp ;
143+ public static String parseUnparseTree (Path path , VariationDiffParseOptions option ) throws IOException , DiffParseException {
144+ VariationTree <DiffLinesLabel > tree = VariationTree .fromFile (path , option );
145+ return VariationUnparser .variationTreeUnparser (tree );
180146 }
181147
182- public static String parseUnparseDiff (Path path , VariationDiffParseOptions option ) {
183- String temp = "b" ;
184- try {
185- VariationDiff <DiffLinesLabel > diff = VariationDiff .fromFile (path , option );
186- temp = VariationUnparser .variationDiffUnparser (diff );
187- } catch (Exception e ) {
188- e .printStackTrace ();
189- }
190- return temp ;
148+ public static String parseUnparseDiff (Path path , VariationDiffParseOptions option ) throws IOException , DiffParseException {
149+ VariationDiff <DiffLinesLabel > diff = VariationDiff .fromFile (path , option );
150+ return VariationUnparser .variationDiffUnparser (diff );
191151 }
192152}
0 commit comments