Skip to content

Commit 386f715

Browse files
committed
Unit test for ascii control character
1 parent ef579d1 commit 386f715

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/src/test/kotlin/org/evomaster/core/output/formatter/OutputFormatterTest.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,19 @@ class OutputFormatterTest {
151151
assertFalse(isValid)
152152
}
153153

154+
@Test
155+
fun testInvalidJsonWithAsciiControlCharacter() {
156+
val json = " {\"s0\":\"This is a long string\", \"s1\":\"This isa long string\", \"s2\":\"_EM_3149_XYZ_\"} "
157+
val isValid = OutputFormatter.JSON_FORMATTER.isValid(json)
158+
assertFalse(isValid)
159+
}
160+
161+
@Test
162+
fun testValidJsonWithEscapedAsciiControlCharacter() {
163+
val json = " {\"s0\":\"This is a long string\", \"s1\":\"This is\\u001Fa long string\", \"s2\":\"_EM_3149_XYZ_\"} "
164+
val isValid = OutputFormatter.JSON_FORMATTER.isValid(json)
165+
assertTrue(isValid)
166+
}
167+
154168

155169
}

0 commit comments

Comments
 (0)