mirror of
https://github.com/java-diff-utils/java-diff-utils.git
synced 2026-03-13 10:11:17 +08:00
fixes #64
This commit is contained in:
@@ -9,6 +9,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -457,4 +458,26 @@ public class DiffRowGeneratorTest {
|
||||
|
||||
assertEquals("This is a test~.~", rows.get(0).getOldLine());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreWhitespaceIssue64() throws DiffException {
|
||||
DiffRowGenerator generator = DiffRowGenerator.create()
|
||||
.showInlineDiffs(true)
|
||||
.inlineDiffByWord(true)
|
||||
.ignoreWhiteSpaces(true)
|
||||
.mergeOriginalRevised(true)
|
||||
.oldTag(f -> "~") //introduce markdown style for strikethrough
|
||||
.newTag(f -> "**") //introduce markdown style for bold
|
||||
.build();
|
||||
|
||||
//compute the differences for two test texts.
|
||||
List<DiffRow> rows = generator.generateDiffRows(
|
||||
Arrays.asList("test\n\ntestline".split("\n")),
|
||||
Arrays.asList("A new text line\n\nanother one".split("\n")));
|
||||
|
||||
assertThat(rows).extracting(item -> item.getOldLine())
|
||||
.containsExactly("~test~**A new text line**",
|
||||
"",
|
||||
"~testline~**another one**");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user