From a57fe42f335dfe12e3c272f2d18037c2708a9c00 Mon Sep 17 00:00:00 2001 From: zhang-quanchao Date: Wed, 27 Aug 2025 16:25:51 +0800 Subject: [PATCH] fix: fix UT Signed-off-by: zhang-quanchao --- .../interface_test/power_wakeup_controller_test.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 47053b47..b3eda5c4 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; -- Gitee