2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 // Enable debug log for test coverage
19 #define DEBUG_ENABLED 1
21 #include "dali-scene-loader/internal/json-reader.h"
22 #include <dali-test-suite-utils.h>
27 #define JSON_STRING(x) #x, strlen(#x)
29 int UtcDaliJsonReaderStrCmp(void)
31 json_string_s jstr[] {
32 { JSON_STRING(hello) },
33 { JSON_STRING(hellew) },
35 DALI_TEST_EQUAL(json::StrCmp(jstr[0], "hello"), 0);
36 DALI_TEST_EQUAL(json::StrCmp(jstr[1], "hello"), 'e' - 'o');
41 int UtcDaliJsonReaderValidateThrow(void)
43 json_value_s jval { nullptr, json_type_array };
44 DALI_TEST_THROWS(json::Validate(jval, json_type_object), std::runtime_error);
45 json::Validate(jval, json_type_array);
50 int UtcDaliJsonReaderFindObjectChild(void)
52 json_string_s jkey{ JSON_STRING(fudgeFactor) };
53 json_number_s jActualValue{ JSON_STRING(5.2) };
54 json_value_s jvalue { &jActualValue, json_type_number };
55 json_object_element_s jobjelem { &jkey, &jvalue, nullptr };
57 json_object_s jobj{ &jobjelem, 1 };
59 DALI_TEST_EQUAL(json::FindObjectChild(jkey.string, jobj), &jvalue);
60 DALI_TEST_EQUAL(json::FindObjectChild("fudgeFactory", jobj), static_cast<json_value_s*>(nullptr));