|
9 | 9 | importjava.util.List; |
10 | 10 | importjava.util.regex.Pattern; |
11 | 11 | importstaticjava.util.stream.Collectors.toList; |
| 12 | +importstaticorg.assertj.core.api.Assertions.assertThat; |
12 | 13 | importstaticorg.junit.jupiter.api.Assertions.assertEquals; |
13 | 14 | importstaticorg.junit.jupiter.api.Assertions.assertTrue; |
14 | 15 | importorg.junit.jupiter.api.Test; |
@@ -457,4 +458,26 @@ public void testIgnoreWhitespaceIssue66_2() throws DiffException { |
457 | 458 |
|
458 | 459 | assertEquals("This is a test~.~",rows.get(0).getOldLine()); |
459 | 460 | } |
| 461 | + |
| 462 | +@Test |
| 463 | +publicvoidtestIgnoreWhitespaceIssue64()throwsDiffException { |
| 464 | +DiffRowGeneratorgenerator =DiffRowGenerator.create() |
| 465 | + .showInlineDiffs(true) |
| 466 | + .inlineDiffByWord(true) |
| 467 | + .ignoreWhiteSpaces(true) |
| 468 | + .mergeOriginalRevised(true) |
| 469 | + .oldTag(f ->"~")//introduce markdown style for strikethrough |
| 470 | + .newTag(f ->"**")//introduce markdown style for bold |
| 471 | + .build(); |
| 472 | + |
| 473 | +//compute the differences for two test texts. |
| 474 | +List<DiffRow>rows =generator.generateDiffRows( |
| 475 | +Arrays.asList("test\n\ntestline".split("\n")), |
| 476 | +Arrays.asList("A new text line\n\nanother one".split("\n"))); |
| 477 | + |
| 478 | +assertThat(rows).extracting(item ->item.getOldLine()) |
| 479 | + .containsExactly("~test~**A new text line**", |
| 480 | +"", |
| 481 | +"~testline~**another one**"); |
| 482 | + } |
460 | 483 | } |