Skip to content

Commit 6e47314

Browse files
committed
fix: normalize line endings in IndentationHelperTest
1 parent f5c3037 commit 6e47314

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/test/java/net/discordjug/javabot/util/IndentationHelperTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ public void testFormatIndentation() throws IOException {
2222
formatted = StringResourceCache.load("/Formatted Strings.txt").split("----");
2323

2424
for (int i = 0, k = 0; i < unformatted.length; i++) {
25-
assertEquals(formatted[k++], IndentationHelper.formatIndentation(unformatted[i], IndentationHelper.IndentationType.FOUR_SPACES), "Method failed to format a text with four spaces correctly");
26-
assertEquals(formatted[k++], IndentationHelper.formatIndentation(unformatted[i], IndentationHelper.IndentationType.TWO_SPACES), "Method failed to format a text with two spaces correctly");
27-
assertEquals(formatted[k++], IndentationHelper.formatIndentation(unformatted[i], IndentationHelper.IndentationType.TABS), "Method failed to format a text with tabs correctly.");
28-
assertEquals(formatted[k++], IndentationHelper.formatIndentation(unformatted[i], IndentationHelper.IndentationType.NULL), "Method returned a String not matching the input");
25+
assertEquals(normalizeLineEndings(formatted[k++]), normalizeLineEndings(IndentationHelper.formatIndentation(unformatted[i], IndentationHelper.IndentationType.FOUR_SPACES)), "Method failed to format a text with four spaces correctly");
26+
assertEquals(normalizeLineEndings(formatted[k++]), normalizeLineEndings(IndentationHelper.formatIndentation(unformatted[i], IndentationHelper.IndentationType.TWO_SPACES)), "Method failed to format a text with two spaces correctly");
27+
assertEquals(normalizeLineEndings(formatted[k++]), normalizeLineEndings(IndentationHelper.formatIndentation(unformatted[i], IndentationHelper.IndentationType.TABS)), "Method failed to format a text with tabs correctly.");
28+
assertEquals(normalizeLineEndings(formatted[k++]), normalizeLineEndings(IndentationHelper.formatIndentation(unformatted[i], IndentationHelper.IndentationType.NULL)), "Method returned a String not matching the input");
2929
}
3030
}
31+
32+
private static String normalizeLineEndings(String text) {
33+
return text.replace("\r\n", "\n")
34+
.replace("\r", "\n");
35+
}
3136
}

0 commit comments

Comments
 (0)