Skip to content

Commit 7b2bfd5

Browse files
committed
integer list test
1 parent b62a120 commit 7b2bfd5

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/test/java/difflib/DiffUtilsTest.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void testDiff_EmptyListWithNonEmpty() throws DiffException {
7171
final Delta<String> delta = patch.getDeltas().get(0);
7272
assertTrue(delta instanceof InsertDelta);
7373
}
74-
74+
7575
@Test
7676
public void testDiffInline() throws DiffException {
7777
final Patch<String> patch = DiffUtils.diffInline("", "test");
@@ -81,7 +81,7 @@ public void testDiffInline() throws DiffException {
8181
assertEquals(0, patch.getDeltas().get(0).getOriginal().getLines().size());
8282
assertEquals("test", patch.getDeltas().get(0).getRevised().getLines().get(0));
8383
}
84-
84+
8585
@Test
8686
public void testDiffInline2() throws DiffException {
8787
final Patch<String> patch = DiffUtils.diffInline("es", "fest");
@@ -94,4 +94,20 @@ public void testDiffInline2() throws DiffException {
9494
assertEquals("f", patch.getDeltas().get(0).getRevised().getLines().get(0));
9595
assertEquals("t", patch.getDeltas().get(1).getRevised().getLines().get(0));
9696
}
97+
98+
@Test
99+
public void testDiffIntegerList() throws DiffException {
100+
List<Integer> original = Arrays.asList(1, 2, 3, 4, 5);
101+
List<Integer> revised = Arrays.asList(2, 3, 4, 6);
102+
103+
final Patch<Integer> patch = DiffUtils.diff(original, revised);
104+
105+
for (Delta delta : patch.getDeltas()) {
106+
System.out.println(delta);
107+
}
108+
109+
assertEquals(2, patch.getDeltas().size());
110+
assertEquals("[DeleteDelta, position: 0, lines: [1]]", patch.getDeltas().get(0).toString());
111+
assertEquals("[ChangeDelta, position: 4, lines: [5] to [6]]", patch.getDeltas().get(1).toString());
112+
}
97113
}

0 commit comments

Comments
 (0)