diff --git a/test/unittest/src/interface_test/power_wakeup_controller_test.cpp b/test/unittest/src/interface_test/power_wakeup_controller_test.cpp index 47053b47901e854dba9a507f650ab221e65535ac..b3eda5c44b1fc73459090b84ae17e031521005c7 100644 --- a/test/unittest/src/interface_test/power_wakeup_controller_test.cpp +++ b/test/unittest/src/interface_test/power_wakeup_controller_test.cpp @@ -395,14 +395,13 @@ HWTEST_F(PowerWakeupControllerTest, PowerWakeupControllerTest011, TestSize.Level std::shared_ptr parseSources = std::make_shared(); cJSON* root = cJSON_Parse(jsonStr.c_str()); - if (!root) { - GTEST_LOG_(INFO) << "PowerWakeupControllerTest011: json parse error"; - return; - } - if (!cJSON_IsObject(root) || !cJSON_IsArray(root)) { - GTEST_LOG_(INFO) << "PowerWakeupControllerTest011: root is not object"; + ASSERT_TRUE(root != nullptr) << "PowerWakeupControllerTest011: json parse error"; + + bool isValidJson = cJSON_IsObject(root) || cJSON_IsArray(root); + if (!isValidJson) { + GTEST_LOG_(INFO) << "PowerWakeupControllerTest011: root is not object or array"; cJSON_Delete(root); - return; + ASSERT_TRUE(isValidJson); } cJSON* item = NULL;