Skip to content

Commit 17cfbfd

Browse files
Apply changes from review
1 parent 264bb80 commit 17cfbfd

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

components/json/src/test/java/datadog/json/JsonMapperTest.java

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ void testMappingToMapFromNonObjectJson(String json) {
104104
}
105105

106106
@TableTest({
107-
"Scenario | Input | Expected ",
108-
"null input | | '[]' ",
109-
"empty list | [] | '[]' ",
110-
"single value | [value1] | '[\"value1\"]' ",
111-
"two values | [value1, value2] | '[\"value1\",\"value2\"]' ",
112-
"quoted values | [va\"lu\"e1, value2] | '[\"va\\\"lu\\\"e1\",\"value2\"]'"
107+
"Scenario | Input | Expected ",
108+
"null input | | '[]' ",
109+
"empty list | [] | '[]' ",
110+
"single value | [value1] | '[\"value1\"]' ",
111+
"two values | [value1, value2] | '[\"value1\",\"value2\"]' ",
112+
"quoted values | [va\"lu\"e1, value2] | '[\"va\\\"lu\\\"e1\",\"value2\"]' "
113113
})
114114
@ParameterizedTest(name = "test mapping iterable to JSON array: {0}")
115115
void testMappingIterableToJsonArray(List<String> input, String expected) throws IOException {
@@ -152,29 +152,32 @@ void testMappingToListFromEmptyJsonObject(String json) throws IOException {
152152
}
153153

154154
// Using `@MethodSource` as special chars not supported by `@TableTest` (yet?).
155+
@TableTest({
156+
"Scenario | input | expected ",
157+
" null value | | '' ",
158+
" empty string | '' | '' ",
159+
" \\b | '\b' | '\"\\b\"' ",
160+
" \\t | '\t' | '\"\\t\"' ",
161+
" \\f | '\f' | '\"\\f\"' ",
162+
" a | 'a' | '\"a\"' ",
163+
" / | '/' | '\"\\/\"' ",
164+
})
155165
@ParameterizedTest(name = "test mapping to JSON string: {0}")
156166
@MethodSource("testMappingToJsonStringArguments")
157-
void testMappingToJsonString(String input, String expected) {
167+
void testMappingToJsonString(@Scenario String ignoredScenario, String input, String expected) {
158168
String json = JsonMapper.toJson(input);
159169
assertEquals(expected, json);
160170
}
161171

162172
static Stream<Arguments> testMappingToJsonStringArguments() {
163173
return Stream.of(
164-
arguments(null, ""),
165-
arguments("", ""),
166-
arguments(String.valueOf((char) 4096), "\"\\u1000\""),
167-
arguments(String.valueOf((char) 256), "\"\\u0100\""),
168-
arguments(String.valueOf((char) 128), "\"\\u0080\""),
169-
arguments("\b", "\"\\b\""),
170-
arguments("\t", "\"\\t\""),
171-
arguments("\n", "\"\\n\""),
172-
arguments("\f", "\"\\f\""),
173-
arguments("\r", "\"\\r\""),
174-
arguments("\"", "\"\\\"\""),
175-
arguments("/", "\"\\/\""),
176-
arguments("\\", "\"\\\\\""),
177-
arguments("a", "\"a\""));
174+
arguments("char #4096", String.valueOf((char) 4096), "\"\\u1000\""),
175+
arguments("char #256", String.valueOf((char) 256), "\"\\u0100\""),
176+
arguments("char #128", String.valueOf((char) 128), "\"\\u0080\""),
177+
arguments("\\n", "\n", "\"\\n\""),
178+
arguments("\\r", "\r", "\"\\r\""),
179+
arguments("\"", "\"", "\"\\\"\""),
180+
arguments("\\", "\\", "\"\\\\\""));
178181
}
179182

180183
private static class UnsupportedType {

0 commit comments

Comments
 (0)