Skip to content

Commit 1161243

Browse files
committed
1 parent f0fe7a2 commit 1161243

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

src/main/java/com/github/difflib/text/DiffRowGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ private List<DiffRow> generateInlineDiffs(AbstractDelta<String> delta) throws Di
413413
* @param tag the tag name without angle brackets, just a word
414414
* @param cssClass the optional css class
415415
*/
416-
public static void wrapInTag(List<String> sequence, int startPosition,
416+
private static void wrapInTag(List<String> sequence, int startPosition,
417417
int endPosition, Function<Boolean, String> generator) {
418418
sequence.add(startPosition, generator.apply(true));
419419
sequence.add(endPosition, generator.apply(false));

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,55 @@ public void testGeneratorIssue15() throws DiffException, IOException {
315315
}
316316
}
317317
}
318+
319+
@Test
320+
public void testGeneratorIssue22() throws DiffException {
321+
DiffRowGenerator generator = DiffRowGenerator.create()
322+
.showInlineDiffs(true)
323+
.inlineDiffByWord(true)
324+
.oldTag(f -> "~")
325+
.newTag(f -> "**")
326+
.build();
327+
String aa = "This is a test senctence.";
328+
String bb = "This is a test for diffutils.\nThis is the second line.";
329+
List<DiffRow> rows = generator.generateDiffRows(
330+
Arrays.asList(aa.split("\n")),
331+
Arrays.asList(bb.split("\n")));
332+
333+
System.out.println(rows);
334+
}
335+
336+
@Test
337+
public void testGeneratorIssue22_2() throws DiffException {
338+
DiffRowGenerator generator = DiffRowGenerator.create()
339+
.showInlineDiffs(true)
340+
.inlineDiffByWord(true)
341+
.oldTag(f -> "~")
342+
.newTag(f -> "**")
343+
.build();
344+
String aa = "This is a test for diffutils.\nThis is the second line.";
345+
String bb = "This is a test senctence.";
346+
List<DiffRow> rows = generator.generateDiffRows(
347+
Arrays.asList(aa.split("\n")),
348+
Arrays.asList(bb.split("\n")));
349+
350+
System.out.println(rows);
351+
}
352+
353+
@Test
354+
public void testGeneratorIssue22_3() throws DiffException {
355+
DiffRowGenerator generator = DiffRowGenerator.create()
356+
.showInlineDiffs(true)
357+
.inlineDiffByWord(true)
358+
.oldTag(f -> "~")
359+
.newTag(f -> "**")
360+
.build();
361+
String aa = "This is a test senctence.";
362+
String bb = "This is a test for diffutils.\nThis is the second line.\nAnd one more.";
363+
List<DiffRow> rows = generator.generateDiffRows(
364+
Arrays.asList(aa.split("\n")),
365+
Arrays.asList(bb.split("\n")));
366+
367+
System.out.println(rows);
368+
}
318369
}

0 commit comments

Comments
 (0)