Compare commits
No commits in common. "fc0963ad409976f893b35815d5a6bb1498453e91" and "a109d2ad93867ce03a840fb5f440828c26824f23" have entirely different histories.
fc0963ad40
...
a109d2ad93
1 changed files with 14 additions and 40 deletions
|
@ -71,30 +71,6 @@ class GeneratedVersionTest {
|
|||
logger.setUseParentHandlers(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two strings by removing all line separators and whitespace.
|
||||
*
|
||||
* @param text1 The first text to compare
|
||||
* @param text2 The second text to compare
|
||||
* @return true if the texts are equivalent when line separators are ignored, false otherwise
|
||||
*/
|
||||
static boolean compareTextIgnoringLineSeparators(String text1, String text2) {
|
||||
// Handle null cases
|
||||
if (text1 == null && text2 == null) {
|
||||
return true;
|
||||
}
|
||||
if (text1 == null || text2 == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove all line separators and whitespace
|
||||
var cleanedText1 = text1.replaceAll("\\r?\\n|\\r|\\s", "");
|
||||
var cleanedText2 = text2.replaceAll("\\r?\\n|\\r|\\s", "");
|
||||
|
||||
// Compare the cleaned strings
|
||||
return cleanedText1.equals(cleanedText2);
|
||||
}
|
||||
|
||||
static void deleteOnExit(File folder) {
|
||||
folder.deleteOnExit();
|
||||
for (var f : Objects.requireNonNull(folder.listFiles())) {
|
||||
|
@ -115,23 +91,21 @@ class GeneratedVersionTest {
|
|||
gv.setProjectName("My App");
|
||||
gv.setClassName("MyVersion");
|
||||
|
||||
var eol = System.lineSeparator();
|
||||
var t = gv.buildTemplate();
|
||||
var v = gv.getProject().version();
|
||||
assertThat(v).extracting("majorInt", "minorInt", "revisionInt").as("version")
|
||||
.containsExactly(2, 1, 3);
|
||||
assertThat(compareTextIgnoringLineSeparators(t.getContent(),
|
||||
String.format("package %s;" +
|
||||
"public final class %s {" +
|
||||
" public static final int PROJECT = \"%s\";" +
|
||||
" public static final int MAJOR = %d;" +
|
||||
" public static final int MINOR = %d;" +
|
||||
" public static final int REVISION = %d;" +
|
||||
" public static final String QUALIFIER = \"\";" +
|
||||
" private MyVersion() {" +
|
||||
" // no-op" +
|
||||
" }" +
|
||||
"}", gv.getPackageName(), gv.getClassName(), gv.getProjectName(), v.majorInt(),
|
||||
v.minorInt(), v.revisionInt()))).as("template").isTrue();
|
||||
assertThat(t.getContent()).isEqualTo("package com.example.my;" + eol +
|
||||
eol +
|
||||
"public final class MyVersion {" + eol +
|
||||
" public static final int PROJECT = \"My App\";" + eol +
|
||||
" public static final int MAJOR = 2;" + eol +
|
||||
" public static final int MINOR = 1;" + eol +
|
||||
" public static final int REVISION = 3;" + eol +
|
||||
" public static final String QUALIFIER = \"\";" + eol +
|
||||
eol +
|
||||
" private MyVersion() {" + eol +
|
||||
" // no-op" + eol +
|
||||
" }" + eol +
|
||||
"}" + eol);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue