2 * Copyright (c) 2022 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 #include <dali-test-suite-utils.h>
19 #include <dali/devel-api/common/free-list.h>
20 #include <dali/public-api/dali-core.h>
26 void utc_dali_free_list_startuP(void)
28 test_return_value = TET_UNDEF;
31 void utc_dali_free_list_cleanuP(void)
33 test_return_value = TET_PASS;
36 int UtcDaliFreeListConstructor01P(void)
38 TestApplication application;
39 tet_infoline("UtcDaliFreeListConstructor01P simple constructor check");
43 DALI_TEST_CHECK(true);
47 DALI_TEST_CHECK(false);
53 int UtcDaliFreeListAddGetRemove(void)
55 TestApplication application;
56 tet_infoline("UtcDaliFreeListAddGetRemove Add, Get, and Remove test");
60 auto FreeListAddTest = [](FreeList& list, std::uint32_t value, std::uint32_t exceptIndex, const char* location) {
61 std::uint32_t index = list.Add(value);
62 DALI_TEST_EQUALS(index, exceptIndex, location);
64 auto FreeListGetTest = [](const FreeList& list, std::uint32_t exceptValue, std::uint32_t index, const char* location) {
65 std::uint32_t value = list[index];
66 DALI_TEST_EQUALS(value, exceptValue, location);
69 tet_printf("Add some values first\n");
70 FreeListAddTest(list1, 111, 0, TEST_LOCATION);
71 FreeListAddTest(list1, 222, 1, TEST_LOCATION);
72 FreeListAddTest(list1, 333, 2, TEST_LOCATION);
73 FreeListAddTest(list1, 444, 3, TEST_LOCATION);
75 tet_printf("Check input values exist well\n");
76 FreeListGetTest(list1, 111, 0, TEST_LOCATION);
77 FreeListGetTest(list1, 222, 1, TEST_LOCATION);
78 FreeListGetTest(list1, 333, 2, TEST_LOCATION);
79 FreeListGetTest(list1, 444, 3, TEST_LOCATION);
81 tet_printf("Remove 1 and 3 value\n");
85 tet_printf("Check not-removed values exist well\n");
86 FreeListGetTest(list1, 111, 0, TEST_LOCATION);
87 FreeListGetTest(list1, 333, 2, TEST_LOCATION);
89 tet_printf("Copy list. FreeList is not handle. copy whole info\n");
91 FreeListGetTest(list2, 111, 0, TEST_LOCATION);
92 FreeListGetTest(list2, 333, 2, TEST_LOCATION);
94 tet_printf("Add some values after removed\n");
95 FreeListAddTest(list1, 555, 3, TEST_LOCATION);
96 FreeListAddTest(list1, 666, 1, TEST_LOCATION);
97 FreeListAddTest(list1, 777, 4, TEST_LOCATION);
98 FreeListAddTest(list2, 888, 3, TEST_LOCATION);
100 tet_printf("Check input values exist well\n");
101 FreeListGetTest(list1, 111, 0, TEST_LOCATION);
102 FreeListGetTest(list1, 666, 1, TEST_LOCATION);
103 FreeListGetTest(list1, 333, 2, TEST_LOCATION);
104 FreeListGetTest(list1, 555, 3, TEST_LOCATION);
105 FreeListGetTest(list1, 777, 4, TEST_LOCATION);
106 FreeListGetTest(list2, 111, 0, TEST_LOCATION);
107 FreeListGetTest(list2, 333, 2, TEST_LOCATION);
108 FreeListGetTest(list2, 888, 3, TEST_LOCATION);
110 tet_printf("Change value directly\n");
113 FreeListGetTest(list2, 111, 0, TEST_LOCATION);
114 FreeListGetTest(list2, 999, 3, TEST_LOCATION);