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 #include <dali-test-suite-utils.h>
19 #include <dali/public-api/dali-core.h>
28 /// Compare a uint16_t value with an unsigned int
29 void DALI_TEST_EQUALS(uint16_t value1, unsigned int value2, const char* location)
31 ::DALI_TEST_EQUALS<uint16_t>(value1, static_cast<uint16_t>(value2), location);
33 } // unnamed namespace
35 int UtcDaliUint16PairConstructor01P(void)
39 DALI_TEST_EQUALS(v.GetX(), 0u, TEST_LOCATION);
40 DALI_TEST_EQUALS(v.GetY(), 0u, TEST_LOCATION);
45 int UtcDaliUint16PairConstructor02P(void)
47 Uint16Pair v(10u, 10u);
49 DALI_TEST_EQUALS(v.GetX(), 10u, TEST_LOCATION);
50 DALI_TEST_EQUALS(v.GetY(), 10u, TEST_LOCATION);
55 int UtcDaliUint16PairCopyConstructor(void)
59 DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
60 DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
65 int UtcDaliUint16PairMoveConstructor(void)
68 Uint16Pair v = std::move(u);
69 DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
70 DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
75 int UtcDaliUint16PairCopyAssignment(void)
80 DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
81 DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
86 int UtcDaliUint16PairMoveAssignment(void)
91 DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
92 DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
97 int UtcDaliUint16PairGetWidthP(void)
100 DALI_TEST_EQUALS(v.GetWidth(), 5u, TEST_LOCATION);
105 int UtcDaliUint16PairGetHeightP(void)
107 Uint16Pair v(5u, 5u);
108 DALI_TEST_EQUALS(v.GetHeight(), 5u, TEST_LOCATION);
113 int UtcDaliUint16PairGetXP(void)
115 Uint16Pair v(5u, 5u);
116 DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
121 int UtcDaliUint16PairGetYP(void)
123 Uint16Pair v(5u, 5u);
124 DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
129 int UtcDaliUint16PairSetXP(void)
131 Uint16Pair v(5u, 5u);
132 DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
134 DALI_TEST_EQUALS(v.GetX(), 10u, TEST_LOCATION);
139 int UtcDaliUint16PairSetWidthP(void)
141 Uint16Pair v(5u, 5u);
142 DALI_TEST_EQUALS(v.GetWidth(), 5u, TEST_LOCATION);
144 DALI_TEST_EQUALS(v.GetWidth(), 10u, TEST_LOCATION);
149 int UtcDaliUint16PairSetYP(void)
151 Uint16Pair v(5u, 5u);
152 DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
154 DALI_TEST_EQUALS(v.GetY(), 10u, TEST_LOCATION);
159 int UtcDaliUint16PairSetHeightP(void)
161 Uint16Pair v(5u, 5u);
162 DALI_TEST_EQUALS(v.GetHeight(), 5u, TEST_LOCATION);
164 DALI_TEST_EQUALS(v.GetHeight(), 10u, TEST_LOCATION);
169 int UtcDaliUint16PairEqualsP(void)
171 Uint16Pair v(5u, 5u);
172 Uint16Pair u(5u, 5u);
173 DALI_TEST_EQUALS(v == u, true, TEST_LOCATION);
175 v = Uint16Pair(5u, 4u);
176 u = Uint16Pair(5u, 5u);
177 DALI_TEST_EQUALS(v == u, false, TEST_LOCATION);
182 int UtcDaliUint16PairNotEqualsP(void)
184 Uint16Pair v(5u, 5u);
185 Uint16Pair u(5u, 5u);
186 DALI_TEST_EQUALS(v != u, false, TEST_LOCATION);
188 v = Uint16Pair(5u, 4u);
189 u = Uint16Pair(5u, 5u);
190 DALI_TEST_EQUALS(v != u, true, TEST_LOCATION);
195 int UtcDaliUint16PairLessThanP(void)
197 Uint16Pair u(5u, 5u);
198 Uint16Pair v(6u, 6u);
199 DALI_TEST_EQUALS(u < v, true, TEST_LOCATION);
201 u = Uint16Pair(0u, 1u);
202 v = Uint16Pair(1u, 0u);
203 DALI_TEST_EQUALS(v < u, true, TEST_LOCATION);
205 u = Uint16Pair(1u, 0u);
206 v = Uint16Pair(0u, 1u);
207 DALI_TEST_EQUALS(v < u, false, TEST_LOCATION);
212 int UtcDaliUint16PairGreaterThanP(void)
217 u = Uint16Pair(0u, 1u);
218 v = Uint16Pair(1u, 0u);
219 DALI_TEST_EQUALS(u > v, true, TEST_LOCATION);
221 u = Uint16Pair(1u, 0u);
222 v = Uint16Pair(0u, 1u);
223 DALI_TEST_EQUALS(v > u, true, TEST_LOCATION);
228 int UtcDaliUint16PairFromFloatVecP(void)
230 Dali::Vector2 v2(5.f, 5.f);
232 Uint16Pair u = Uint16Pair::FromFloatVec2(v2);
233 DALI_TEST_EQUALS(u.GetX(), 5u, TEST_LOCATION);
234 DALI_TEST_EQUALS(u.GetY(), 5u, TEST_LOCATION);
236 Dali::Vector3 v3(5.f, 5.f, 5.f);
238 u = Uint16Pair::FromFloatVec2(v3);
239 DALI_TEST_EQUALS(u.GetX(), 5u, TEST_LOCATION);
240 DALI_TEST_EQUALS(u.GetY(), 5u, TEST_LOCATION);
245 int UtcDaliUint16PairFromFloatArrayP(void)
247 float array[] = {5.f, 5.f};
249 Uint16Pair u = Uint16Pair::FromFloatArray(array);
250 DALI_TEST_EQUALS(u.GetX(), 5u, TEST_LOCATION);
251 DALI_TEST_EQUALS(u.GetY(), 5u, TEST_LOCATION);