Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 33a0b58

Browse files
committed
introduces test for issue #15
1 parent 4933ca5 commit 33a0b58

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package com.github.difflib.text;
22

33
import com.github.difflib.algorithm.DiffException;
4+
import java.io.File;
5+
import java.io.IOException;
6+
import java.nio.file.Files;
47
import java.util.Arrays;
58
import java.util.List;
69
import java.util.regex.Pattern;
10+
import static java.util.stream.Collectors.toList;
711
import static org.junit.Assert.assertEquals;
812
import static org.junit.Assert.assertTrue;
913
import org.junit.Test;
@@ -263,7 +267,7 @@ public void testGeneratorUnchanged() throws DiffException {
263267
assertEquals("[CHANGE, ,]", rows.get(1).toString());
264268
assertEquals("[EQUAL,other,other]", rows.get(2).toString());
265269
}
266-
270+
267271
@Test
268272
public void testGeneratorIssue14() throws DiffException {
269273
DiffRowGenerator generator = DiffRowGenerator.create()
@@ -282,4 +286,33 @@ public void testGeneratorIssue14() throws DiffException {
282286
assertEquals(1, rows.size());
283287
assertEquals("~J. G. Feldstein~**T. P. Pastor**, Chair", rows.get(0).getOldLine());
284288
}
289+
290+
@Test
291+
public void testGeneratorIssue15() throws DiffException, IOException {
292+
DiffRowGenerator generator = DiffRowGenerator.create()
293+
.showInlineDiffs(true) //show the ~ ~ and ** ** symbols on each difference
294+
.inlineDiffByWord(true) //show the ~ ~ and ** ** around each different word instead of each letter
295+
//.reportLinesUnchanged(true) //experiment
296+
.oldTag(f -> "~")
297+
.newTag(f -> "**")
298+
.build();
299+
300+
List<String> listOne = Files.lines(new File("target/test-classes/mocks/issue15_1.txt").toPath())
301+
.collect(toList());
302+
303+
List<String> listTwo = Files.lines(new File("target/test-classes/mocks/issue15_2.txt").toPath())
304+
.collect(toList());
305+
306+
List<DiffRow> rows = generator.generateDiffRows(listOne, listTwo);
307+
308+
assertEquals(9, rows.size());
309+
310+
for (DiffRow row : rows) {
311+
System.out.println("|" + row.getOldLine() + "| " + row.getNewLine() + " |");
312+
if (!row.getOldLine().startsWith("TABLE_NAME")) {
313+
assertTrue(row.getNewLine().startsWith("**ACTIONS_C16913**"));
314+
assertTrue(row.getOldLine().startsWith("~ACTIONS_C1700"));
315+
}
316+
}
317+
}
285318
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_LENGTH, DATA_PRECISION, NULLABLE,
2+
ACTIONS_C17005, ID, NUMBER, 22, 19, N,
3+
ACTIONS_C17005, ISSUEID, NUMBER, 22, 19, Y,
4+
ACTIONS_C17005, MODIFIED, NUMBER, 22, 10, Y,
5+
ACTIONS_C17005, TABLE, VARCHAR2, 1020, null, Y,
6+
ACTIONS_C17005, S_NAME, CLOB, 4000, null, Y,
7+
ACTIONS_C17008, ID, NUMBER, 22, 19, N,
8+
ACTIONS_C17008, ISSUEID, NUMBER, 22, 19, Y,
9+
ACTIONS_C17008, MODIFIED, NUMBER, 22, 10, Y,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_LENGTH, DATA_PRECISION, NULLABLE,
2+
ACTIONS_C16913, ID, NUMBER, 22, 19, N,
3+
ACTIONS_C16913, ISSUEID, NUMBER, 22, 19, Y,
4+
ACTIONS_C16913, MODIFIED, NUMBER, 22, 10, Y,
5+
ACTIONS_C16913, VRS, NUMBER, 22, 1, Y,
6+
ACTIONS_C16913, ZTABS, VARCHAR2, 255, null, Y,
7+
ACTIONS_C16913, ZTABS_S, VARCHAR2, 255, null, Y,
8+
ACTIONS_C16913, TASK, VARCHAR2, 255, null, Y,
9+
ACTIONS_C16913, HOURS_SPENT, VARCHAR2, 255, null, Y,

0 commit comments

Comments
 (0)