Skip to content

Commit

Permalink
Fixed the assertion failure caused by different line break characters…
Browse files Browse the repository at this point in the history
… in various operating system environments.
  • Loading branch information
xianrenzw committed Jan 24, 2025
1 parent 20a431c commit c42ff51
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ void testIndentWriteAsString() {

String jsonString = JsonUtils.indentWriteAsString(testData);
assertNotNull(jsonString);
assertEquals("{\r\n \"name\" : \"test\",\r\n \"value\" : 123\r\n}", jsonString);
String linedSeparator = System.lineSeparator();
String expectedJsonString = "{\n \"name\" : \"test\",\n \"value\" : 123\n}".replace("\n", linedSeparator);

assertEquals(expectedJsonString, jsonString);
}

// Test edge case: object is null
Expand Down

0 comments on commit c42ff51

Please sign in to comment.