Skip to content

Commit dbd0b8f

Browse files
committed
fixes #64
1 parent e37a523 commit dbd0b8f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

java-diff-utils/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.List;
1010
import java.util.regex.Pattern;
1111
import static java.util.stream.Collectors.toList;
12+
import static org.assertj.core.api.Assertions.assertThat;
1213
import static org.junit.jupiter.api.Assertions.assertEquals;
1314
import static org.junit.jupiter.api.Assertions.assertTrue;
1415
import org.junit.jupiter.api.Test;
@@ -457,4 +458,26 @@ public void testIgnoreWhitespaceIssue66_2() throws DiffException {
457458

458459
assertEquals("This is a test~.~", rows.get(0).getOldLine());
459460
}
461+
462+
@Test
463+
public void testIgnoreWhitespaceIssue64() throws DiffException {
464+
DiffRowGenerator generator = 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+
}
460483
}

0 commit comments

Comments
 (0)