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/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
37 int UtcDaliUint16PairConstructor01P(void)
41 DALI_TEST_EQUALS(v.GetX(), 0u, TEST_LOCATION);
42 DALI_TEST_EQUALS(v.GetY(), 0u, TEST_LOCATION);
47 int UtcDaliUint16PairConstructor02P(void)
49 Uint16Pair v(10u, 10u);
51 DALI_TEST_EQUALS(v.GetX(), 10u, TEST_LOCATION);
52 DALI_TEST_EQUALS(v.GetY(), 10u, TEST_LOCATION);
57 int UtcDaliUint16PairCopyConstructor(void)
61 DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
62 DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
67 int UtcDaliUint16PairMoveConstructor(void)
70 Uint16Pair v = std::move(u);
71 DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
72 DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
77 int UtcDaliUint16PairCopyAssignment(void)
82 DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
83 DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
88 int UtcDaliUint16PairMoveAssignment(void)
93 DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
94 DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
99 int UtcDaliUint16PairGetWidthP(void)
101 Uint16Pair v(5u, 5u);
102 DALI_TEST_EQUALS(v.GetWidth(), 5u, TEST_LOCATION);
107 int UtcDaliUint16PairGetHeightP(void)
109 Uint16Pair v(5u, 5u);
110 DALI_TEST_EQUALS(v.GetHeight(), 5u, TEST_LOCATION);
115 int UtcDaliUint16PairGetXP(void)
117 Uint16Pair v(5u, 5u);
118 DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
123 int UtcDaliUint16PairGetYP(void)
125 Uint16Pair v(5u, 5u);
126 DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
131 int UtcDaliUint16PairSetXP(void)
133 Uint16Pair v(5u, 5u);
134 DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
136 DALI_TEST_EQUALS(v.GetX(), 10u, TEST_LOCATION);
141 int UtcDaliUint16PairSetWidthP(void)
143 Uint16Pair v(5u, 5u);
144 DALI_TEST_EQUALS(v.GetWidth(), 5u, TEST_LOCATION);
146 DALI_TEST_EQUALS(v.GetWidth(), 10u, TEST_LOCATION);
151 int UtcDaliUint16PairSetYP(void)
153 Uint16Pair v(5u, 5u);
154 DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
156 DALI_TEST_EQUALS(v.GetY(), 10u, TEST_LOCATION);
161 int UtcDaliUint16PairSetHeightP(void)
163 Uint16Pair v(5u, 5u);
164 DALI_TEST_EQUALS(v.GetHeight(), 5u, TEST_LOCATION);
166 DALI_TEST_EQUALS(v.GetHeight(), 10u, TEST_LOCATION);
171 int UtcDaliUint16PairEqualsP(void)
173 Uint16Pair v(5u, 5u);
174 Uint16Pair u(5u, 5u);
175 DALI_TEST_EQUALS(v == u, true, TEST_LOCATION);
177 v = Uint16Pair(5u, 4u);
178 u = Uint16Pair(5u, 5u);
179 DALI_TEST_EQUALS(v == u, false, TEST_LOCATION);
184 int UtcDaliUint16PairNotEqualsP(void)
186 Uint16Pair v(5u, 5u);
187 Uint16Pair u(5u, 5u);
188 DALI_TEST_EQUALS(v != u, false, TEST_LOCATION);
190 v = Uint16Pair(5u, 4u);
191 u = Uint16Pair(5u, 5u);
192 DALI_TEST_EQUALS(v != u, true, TEST_LOCATION);
197 int UtcDaliUint16PairLessThanP(void)
199 Uint16Pair u(5u, 5u);
200 Uint16Pair v(6u, 6u);
201 DALI_TEST_EQUALS(u < v, true, TEST_LOCATION);
203 u = Uint16Pair(0u, 1u);
204 v = Uint16Pair(1u, 0u);
205 DALI_TEST_EQUALS(v < u, true, TEST_LOCATION);
207 u = Uint16Pair(1u, 0u);
208 v = Uint16Pair(0u, 1u);
209 DALI_TEST_EQUALS(v < u, false, TEST_LOCATION);
214 int UtcDaliUint16PairGreaterThanP(void)
219 u = Uint16Pair(0u, 1u);
220 v = Uint16Pair(1u, 0u);
221 DALI_TEST_EQUALS(u > v, true, TEST_LOCATION);
223 u = Uint16Pair(1u, 0u);
224 v = Uint16Pair(0u, 1u);
225 DALI_TEST_EQUALS(v > u, true, TEST_LOCATION);
230 int UtcDaliUint16PairFromFloatVecP(void)
232 Dali::Vector2 v2(5.f, 5.f);
234 Uint16Pair u = Uint16Pair::FromFloatVec2(v2);
235 DALI_TEST_EQUALS(u.GetX(), 5u, TEST_LOCATION);
236 DALI_TEST_EQUALS(u.GetY(), 5u, TEST_LOCATION);
238 Dali::Vector3 v3(5.f, 5.f, 5.f);
240 u = Uint16Pair::FromFloatVec2(v3);
241 DALI_TEST_EQUALS(u.GetX(), 5u, TEST_LOCATION);
242 DALI_TEST_EQUALS(u.GetY(), 5u, TEST_LOCATION);
247 int UtcDaliUint16PairFromFloatArrayP(void)
249 float array[] = {5.f, 5.f};
251 Uint16Pair u = Uint16Pair::FromFloatArray(array);
252 DALI_TEST_EQUALS(u.GetX(), 5u, TEST_LOCATION);
253 DALI_TEST_EQUALS(u.GetY(), 5u, TEST_LOCATION);
260 int UtcDaliInt32PairConstructor01P(void)
264 DALI_TEST_EQUALS(v.GetX(), 0, TEST_LOCATION);
265 DALI_TEST_EQUALS(v.GetY(), 0, TEST_LOCATION);
270 int UtcDaliInt32PairConstructor02P(void)
272 Int32Pair v(-10, 20);
274 DALI_TEST_EQUALS(v.GetX(), -10, TEST_LOCATION);
275 DALI_TEST_EQUALS(v.GetY(), 20, TEST_LOCATION);
280 int UtcDaliInt32PairCopyConstructor(void)
282 Int32Pair u(-5, -10);
284 DALI_TEST_EQUALS(v.GetX(), -5, TEST_LOCATION);
285 DALI_TEST_EQUALS(v.GetY(), -10, TEST_LOCATION);
290 int UtcDaliInt32PairMoveConstructor(void)
293 Int32Pair v = std::move(u);
294 DALI_TEST_EQUALS(v.GetX(), 5, TEST_LOCATION);
295 DALI_TEST_EQUALS(v.GetY(), -10, TEST_LOCATION);
300 int UtcDaliInt32PairCopyAssignment(void)
305 DALI_TEST_EQUALS(v.GetX(), 5, TEST_LOCATION);
306 DALI_TEST_EQUALS(v.GetY(), 10, TEST_LOCATION);
311 int UtcDaliInt32PairMoveAssignment(void)
316 DALI_TEST_EQUALS(v.GetX(), 5, TEST_LOCATION);
317 DALI_TEST_EQUALS(v.GetY(), 10, TEST_LOCATION);
322 int UtcDaliInt32PairGetXP(void)
325 DALI_TEST_EQUALS(v.GetX(), 5, TEST_LOCATION);
326 DALI_TEST_EQUALS(v.GetWidth(), 5, TEST_LOCATION);
331 int UtcDaliInt32PairGetYP(void)
334 DALI_TEST_EQUALS(v.GetY(), 10, TEST_LOCATION);
335 DALI_TEST_EQUALS(v.GetHeight(), 10, TEST_LOCATION);
340 int UtcDaliInt32PairSetXP(void)
343 DALI_TEST_EQUALS(v.GetX(), 5, TEST_LOCATION);
345 DALI_TEST_EQUALS(v.GetX(), 10, TEST_LOCATION);
347 DALI_TEST_EQUALS(v.GetWidth(), 65539, TEST_LOCATION);
352 int UtcDaliInt32PairSetYP(void)
355 DALI_TEST_EQUALS(v.GetY(), 10, TEST_LOCATION);
357 DALI_TEST_EQUALS(v.GetY(), -5, TEST_LOCATION);
359 DALI_TEST_EQUALS(v.GetHeight(), 65537, TEST_LOCATION);
364 int UtcDaliInt32PairEqualsP(void)
368 DALI_TEST_EQUALS(v == u, true, TEST_LOCATION);
372 DALI_TEST_EQUALS(v == u, false, TEST_LOCATION);
377 int UtcDaliInt32PairNotEqualsP(void)
381 DALI_TEST_EQUALS(v != u, false, TEST_LOCATION);
385 DALI_TEST_EQUALS(v != u, true, TEST_LOCATION);