From dec2155064331019f719b536b039946f337b96a6 Mon Sep 17 00:00:00 2001 From: Darkforge317 Date: Fri, 19 Jun 2026 23:40:12 -0600 Subject: [PATCH] Normalize line endings in GoalSerializerTest Add a normalizeLineEndings helper to GoalSerializerTest to convert CRLF/CR to LF and handle null, and update assertions to compare normalized expected and actual serialized JSON. This prevents platform-specific line-ending differences from causing test failures. --- .../goaltracker/GoalSerializerTest.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/toofifty/goaltracker/GoalSerializerTest.java b/src/test/java/com/toofifty/goaltracker/GoalSerializerTest.java index 403b64d..de41b7b 100644 --- a/src/test/java/com/toofifty/goaltracker/GoalSerializerTest.java +++ b/src/test/java/com/toofifty/goaltracker/GoalSerializerTest.java @@ -28,6 +28,19 @@ //noinspection UnstableApiUsage @SuppressWarnings("null") public class GoalSerializerTest { + /** + * Normalizes all line endings to LF (\n) for consistent string comparisons across platforms. + * + * @param dirtyString The string whose line-endings you want to normalize. + * @return The normalized string with the requested line endings. + */ + private String normalizeLineEndings(String dirtyString) { + if (dirtyString == null) return null; + + // Replace and return LF line endings + return dirtyString.replace("\r\n", "\n").replace("\r", "\n"); + } + GoalSerializer serializer; @BeforeEach @@ -127,8 +140,10 @@ public void serialize_should_convert_goals_to_json() throws IOException { .build() ); - assertEquals(expectedJson, serializer.serialize(goals, true)); - + assertEquals( + normalizeLineEndings(expectedJson), + normalizeLineEndings(serializer.serialize(goals, true)) + ); } @Test @@ -178,6 +193,9 @@ public void serialize_should_support_other_task_types() throws IOException { ))).build() ); - assertEquals(expectedJson, serializer.serialize(goals, true)); + assertEquals( + normalizeLineEndings(expectedJson), + normalizeLineEndings(serializer.serialize(goals, true)) + ); } } \ No newline at end of file