From 0668444fab911d0a1b9f275854e1c33a0fc33f25 Mon Sep 17 00:00:00 2001 From: "shaojin.wensj" Date: Sat, 7 May 2022 19:21:47 +0800 Subject: [PATCH] fix testcase --- .../test/java/com/alibaba/fastjson2/JSON_test_validate.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/test/java/com/alibaba/fastjson2/JSON_test_validate.java b/core/src/test/java/com/alibaba/fastjson2/JSON_test_validate.java index 7ed0360a60..1c142e30a6 100644 --- a/core/src/test/java/com/alibaba/fastjson2/JSON_test_validate.java +++ b/core/src/test/java/com/alibaba/fastjson2/JSON_test_validate.java @@ -62,12 +62,16 @@ public void test_isValidArray_bytes() { @Test public void test_isValidObject() { + assertFalse(JSON.isValidObject((String) null)); + assertFalse(JSON.isValidObject("")); assertFalse(JSON.isValidObject("123")); assertFalse(JSON.isValidObject("1}")); assertFalse(JSON.isValidObject("\"aaa\"")); assertFalse(JSON.isValidObject("\"aaa\"}")); assertTrue(JSON.isValidObject("{}")); assertFalse(JSON.isValidObject("{}]")); + assertFalse(JSON.isValidObject("{]")); + assertFalse(JSON.isValidObject("{")); assertFalse(JSON.isValidObject("[]")); assertFalse(JSON.isValidObject("[]]")); } @@ -83,6 +87,8 @@ public void test_isValidObject_bytes() { assertFalse(JSON.isValidObject("\"aaa\"}".getBytes(StandardCharsets.UTF_8))); assertTrue(JSON.isValidObject("{}".getBytes(StandardCharsets.UTF_8))); assertFalse(JSON.isValidObject("{}]".getBytes(StandardCharsets.UTF_8))); + assertFalse(JSON.isValidObject("{]".getBytes(StandardCharsets.UTF_8))); + assertFalse(JSON.isValidObject("{".getBytes(StandardCharsets.UTF_8))); assertFalse(JSON.isValidObject("[]".getBytes(StandardCharsets.UTF_8))); assertFalse(JSON.isValidObject("[]]".getBytes(StandardCharsets.UTF_8))); }