Skip to content

Commit c819f96

Browse files
committed
passing through exceptions
1 parent 37556b7 commit c819f96

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

src/test/java/diffutils/DiffUtilsTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import difflib.patch.Patch;
88
import difflib.patch.DeleteDelta;
99
import difflib.*;
10+
import difflib.algorithm.DiffException;
1011
import java.util.ArrayList;
1112
import java.util.Arrays;
1213
import java.util.Collections;
@@ -19,7 +20,7 @@
1920
public class DiffUtilsTest {
2021

2122
@Test
22-
public void testDiff_Insert() {
23+
public void testDiff_Insert() throws DiffException {
2324
final Patch<String> patch = DiffUtils.diff(Arrays.asList("hhh"), Arrays.
2425
asList("hhh", "jjj", "kkk"));
2526
assertNotNull(patch);
@@ -31,7 +32,7 @@ public void testDiff_Insert() {
3132
}
3233

3334
@Test
34-
public void testDiff_Delete() {
35+
public void testDiff_Delete() throws DiffException {
3536
final Patch<String> patch = DiffUtils.diff(Arrays.asList("ddd", "fff", "ggg"), Arrays.
3637
asList("ggg"));
3738
assertNotNull(patch);
@@ -43,7 +44,7 @@ public void testDiff_Delete() {
4344
}
4445

4546
@Test
46-
public void testDiff_Change() {
47+
public void testDiff_Change() throws DiffException {
4748
final List<String> changeTest_from = Arrays.asList("aaa", "bbb", "ccc");
4849
final List<String> changeTest_to = Arrays.asList("aaa", "zzz", "ccc");
4950

@@ -57,14 +58,14 @@ public void testDiff_Change() {
5758
}
5859

5960
@Test
60-
public void testDiff_EmptyList() {
61+
public void testDiff_EmptyList() throws DiffException {
6162
final Patch<String> patch = DiffUtils.diff(new ArrayList<>(), new ArrayList<>());
6263
assertNotNull(patch);
6364
assertEquals(0, patch.getDeltas().size());
6465
}
6566

6667
@Test
67-
public void testDiff_EmptyListWithNonEmpty() {
68+
public void testDiff_EmptyListWithNonEmpty() throws DiffException {
6869
final Patch<String> patch = DiffUtils.diff(new ArrayList<>(), Arrays.asList("aaa"));
6970
assertNotNull(patch);
7071
assertEquals(1, patch.getDeltas().size());
@@ -73,7 +74,7 @@ public void testDiff_EmptyListWithNonEmpty() {
7374
}
7475

7576
@Test
76-
public void testDiffInline() {
77+
public void testDiffInline() throws DiffException {
7778
final Patch<String> patch = DiffUtils.diffInline("", "test");
7879
assertEquals(1, patch.getDeltas().size());
7980
assertTrue(patch.getDeltas().get(0) instanceof InsertDelta);
@@ -83,7 +84,7 @@ public void testDiffInline() {
8384
}
8485

8586
@Test
86-
public void testDiffInline2() {
87+
public void testDiffInline2() throws DiffException {
8788
final Patch<String> patch = DiffUtils.diffInline("es", "fest");
8889
assertEquals(2, patch.getDeltas().size());
8990
assertTrue(patch.getDeltas().get(0) instanceof InsertDelta);

src/test/java/diffutils/GenerateUnifiedDiffTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package diffutils;
22

33
import difflib.DiffUtils;
4+
import difflib.algorithm.DiffException;
45
import difflib.patch.Patch;
56
import difflib.patch.PatchFailedException;
67
import java.io.BufferedReader;
@@ -42,23 +43,23 @@ public List<String> fileToLines(String filename) {
4243
}
4344

4445
@Test
45-
public void testGenerateUnified() {
46+
public void testGenerateUnified() throws DiffException {
4647
List<String> origLines = fileToLines(TestConstants.MOCK_FOLDER + "original.txt");
4748
List<String> revLines = fileToLines(TestConstants.MOCK_FOLDER + "revised.txt");
4849

4950
verify(origLines, revLines, "original.txt", "revised.txt");
5051
}
5152

5253
@Test
53-
public void testGenerateUnifiedWithOneDelta() {
54+
public void testGenerateUnifiedWithOneDelta() throws DiffException {
5455
List<String> origLines = fileToLines(TestConstants.MOCK_FOLDER + "one_delta_test_original.txt");
5556
List<String> revLines = fileToLines(TestConstants.MOCK_FOLDER + "one_delta_test_revised.txt");
5657

5758
verify(origLines, revLines, "one_delta_test_original.txt", "one_delta_test_revised.txt");
5859
}
5960

6061
@Test
61-
public void testGenerateUnifiedDiffWithoutAnyDeltas() {
62+
public void testGenerateUnifiedDiffWithoutAnyDeltas() throws DiffException {
6263
List<String> test = Arrays.asList("abc");
6364
Patch<String> patch = DiffUtils.diff(test, test);
6465
DiffUtils.generateUnifiedDiff("abc", "abc", test, patch, 0);
@@ -80,14 +81,14 @@ public void testDiff_Issue10() {
8081
* Issue 12
8182
*/
8283
@Test
83-
public void testPatchWithNoDeltas() {
84+
public void testPatchWithNoDeltas() throws DiffException {
8485
final List<String> lines1 = fileToLines(TestConstants.MOCK_FOLDER + "issue11_1.txt");
8586
final List<String> lines2 = fileToLines(TestConstants.MOCK_FOLDER + "issue11_2.txt");
8687
verify(lines1, lines2, "issue11_1.txt", "issue11_2.txt");
8788
}
8889

8990
@Test
90-
public void testDiff5() {
91+
public void testDiff5() throws DiffException {
9192
final List<String> lines1 = fileToLines(TestConstants.MOCK_FOLDER + "5A.txt");
9293
final List<String> lines2 = fileToLines(TestConstants.MOCK_FOLDER + "5B.txt");
9394
verify(lines1, lines2, "5A.txt", "5B.txt");
@@ -97,7 +98,7 @@ public void testDiff5() {
9798
* Issue 19
9899
*/
99100
@Test
100-
public void testDiffWithHeaderLineInText() {
101+
public void testDiffWithHeaderLineInText() throws DiffException {
101102
List<String> original = new ArrayList<>();
102103
List<String> revised = new ArrayList<>();
103104

@@ -119,7 +120,7 @@ public void testDiffWithHeaderLineInText() {
119120
}
120121

121122
private void verify(List<String> origLines, List<String> revLines,
122-
String originalFile, String revisedFile) {
123+
String originalFile, String revisedFile) throws DiffException {
123124
Patch<String> patch = DiffUtils.diff(origLines, revLines);
124125
List<String> unifiedDiff = DiffUtils.generateUnifiedDiff(originalFile, revisedFile,
125126
origLines, patch, 10);

src/test/java/diffutils/patch/PatchTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package diffutils.patch;
22

33
import difflib.DiffUtils;
4+
import difflib.algorithm.DiffException;
45
import difflib.patch.Patch;
56
import difflib.patch.PatchFailedException;
67
import java.util.Arrays;
@@ -12,7 +13,7 @@
1213
public class PatchTest {
1314

1415
@Test
15-
public void testPatch_Insert() {
16+
public void testPatch_Insert() throws DiffException {
1617
final List<String> insertTest_from = Arrays.asList("hhh");
1718
final List<String> insertTest_to = Arrays.asList("hhh", "jjj", "kkk", "lll");
1819

@@ -25,7 +26,7 @@ public void testPatch_Insert() {
2526
}
2627

2728
@Test
28-
public void testPatch_Delete() {
29+
public void testPatch_Delete() throws DiffException {
2930
final List<String> deleteTest_from = Arrays.asList("ddd", "fff", "ggg", "hhh");
3031
final List<String> deleteTest_to = Arrays.asList("ggg");
3132

@@ -38,7 +39,7 @@ public void testPatch_Delete() {
3839
}
3940

4041
@Test
41-
public void testPatch_Change() {
42+
public void testPatch_Change() throws DiffException {
4243
final List<String> changeTest_from = Arrays.asList("aaa", "bbb", "ccc", "ddd");
4344
final List<String> changeTest_to = Arrays.asList("aaa", "bxb", "cxc", "ddd");
4445

src/test/java/diffutils/rows/DiffRowGeneratorTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package diffutils.rows;
22

3+
import difflib.algorithm.DiffException;
34
import difflib.text.DiffRow;
45
import difflib.text.DiffRowGenerator;
56
import java.util.Arrays;
@@ -11,7 +12,7 @@
1112
public class DiffRowGeneratorTest {
1213

1314
@Test
14-
public void testGenerator_Default() {
15+
public void testGenerator_Default() throws DiffException {
1516
String first = "anything \n \nother";
1617
String second = "anything\n\nother";
1718

@@ -25,7 +26,7 @@ public void testGenerator_Default() {
2526
}
2627

2728
@Test
28-
public void testGenerator_InlineDiff() {
29+
public void testGenerator_InlineDiff() throws DiffException {
2930
String first = "anything \n \nother";
3031
String second = "anything\n\nother";
3132

@@ -41,7 +42,7 @@ public void testGenerator_InlineDiff() {
4142
}
4243

4344
@Test
44-
public void testGenerator_IgnoreWhitespaces() {
45+
public void testGenerator_IgnoreWhitespaces() throws DiffException {
4546
String first = "anything \n \nother\nmore lines";
4647
String second = "anything\n\nother\nsome more lines";
4748

0 commit comments

Comments
 (0)