From 04eb52d11c40ce2830f2f38ffe604b32a7b16aff Mon Sep 17 00:00:00 2001 From: Codegass Date: Wed, 20 Mar 2024 15:21:55 -0400 Subject: [PATCH] Split `testWriteHtmlSafe` into Two Separate Test Cases for Improved Test Granularity (#2653) * Split testWriteHtmlSafe into two test case to improve the Test Granularity * Style violations fixed --- .../src/test/java/com/google/gson/MixedStreamTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gson/src/test/java/com/google/gson/MixedStreamTest.java b/gson/src/test/java/com/google/gson/MixedStreamTest.java index 42fed49634..23c887d12d 100644 --- a/gson/src/test/java/com/google/gson/MixedStreamTest.java +++ b/gson/src/test/java/com/google/gson/MixedStreamTest.java @@ -197,7 +197,7 @@ public void testReadNulls() { } @Test - public void testWriteHtmlSafe() { + public void testWriteHtmlSafeWithEscaping() { List contents = Arrays.asList("<", ">", "&", "=", "'"); Type type = new TypeToken>() {}.getType(); @@ -205,8 +205,14 @@ public void testWriteHtmlSafe() { new Gson().toJson(contents, type, new JsonWriter(writer)); assertThat(writer.toString()) .isEqualTo("[\"\\u003c\",\"\\u003e\",\"\\u0026\",\"\\u003d\",\"\\u0027\"]"); + } + + @Test + public void testWriteHtmlSafeWithoutEscaping() { + List contents = Arrays.asList("<", ">", "&", "=", "'"); + Type type = new TypeToken>() {}.getType(); - writer = new StringWriter(); + StringWriter writer = new StringWriter(); new GsonBuilder().disableHtmlEscaping().create().toJson(contents, type, new JsonWriter(writer)); assertThat(writer.toString()).isEqualTo("[\"<\",\">\",\"&\",\"=\",\"'\"]"); }