-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve rendering of big unified diffs by leaving out unchanged parts. For text-only comparison this must be explicitly configured using `TextSnapshot.text().withContextLines(10)`. Unified diffs that are automatically generated by the framework during structure comparison will use a default value of `5` context lines. For now this value is not configurable. Closes #37
- Loading branch information
Showing
17 changed files
with
501 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
snapshot-tests-core/src/test/resources/de/skuzzle/test/snapshots/impl/FailingSnapshotTests$FailBecauseSnapshotMismatchWithWhitespaces_snapshots/testWithSnapshot_0.snapshot eol=crlf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
snapshot-tests-core/src/main/java/de/skuzzle/test/snapshots/data/text/LineSeparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package de.skuzzle.test.snapshots.data.text; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Used to represent a file's line separator. | ||
* | ||
* @since 1.5.0 | ||
* @author Simon Taddiken | ||
*/ | ||
enum LineSeparator { | ||
// note: don't reorder! | ||
CRLF("\r\n", "\\r\\n"), | ||
LF("\n", "\\n"), | ||
CR("\r", "\\r"), | ||
DEFAULT("\n", "\\n"), | ||
SYSTEM(System.lineSeparator(), System.lineSeparator().replace("\r", "\\r").replace("\n", "\\n")); | ||
|
||
private final String characters; | ||
private final String displayName; | ||
|
||
private LineSeparator(String characters, String displayName) { | ||
this.characters = characters; | ||
this.displayName = displayName; | ||
} | ||
|
||
public static LineSeparator determineFrom(String s) { | ||
for (final LineSeparator lineSeparator : LineSeparator.values()) { | ||
if (lineSeparator.existsIn(s)) { | ||
return lineSeparator; | ||
} | ||
} | ||
return DEFAULT; | ||
} | ||
|
||
private boolean existsIn(String s) { | ||
return s.indexOf(characters) >= 0; | ||
} | ||
|
||
public String displayName() { | ||
return name() + "(" + displayName + ")"; | ||
} | ||
|
||
public boolean endsWith(String s) { | ||
return s.endsWith(this.characters); | ||
} | ||
|
||
public boolean startsWith(String s) { | ||
return s.startsWith(this.characters); | ||
} | ||
|
||
/** | ||
* Converts all line separators in the given String to the line separator represented | ||
* by the enum constant on which this method is called. | ||
* | ||
* @param s The string in which to convert the line separators. | ||
* @return The string with converted line separators. | ||
*/ | ||
public String convert(String s) { | ||
return s.lines().collect(Collectors.joining(characters)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return characters; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.