Merge "Add SwitchParent api in actor-devel" into devel/master
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Uint16Pair.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <dali-test-suite-utils.h>
19 #include <dali/public-api/dali-core.h>
20 #include <stdlib.h>
21
22 #include <iostream>
23
24 using namespace Dali;
25
26 namespace
27 {
28 /// Compare a uint16_t value with an unsigned int
29 void DALI_TEST_EQUALS(uint16_t value1, unsigned int value2, const char* location)
30 {
31   ::DALI_TEST_EQUALS<uint16_t>(value1, static_cast<uint16_t>(value2), location);
32 }
33 } // unnamed namespace
34
35 int UtcDaliUint16PairConstructor01P(void)
36 {
37   Uint16Pair v;
38
39   DALI_TEST_EQUALS(v.GetX(), 0u, TEST_LOCATION);
40   DALI_TEST_EQUALS(v.GetY(), 0u, TEST_LOCATION);
41
42   END_TEST;
43 }
44
45 int UtcDaliUint16PairConstructor02P(void)
46 {
47   Uint16Pair v(10u, 10u);
48
49   DALI_TEST_EQUALS(v.GetX(), 10u, TEST_LOCATION);
50   DALI_TEST_EQUALS(v.GetY(), 10u, TEST_LOCATION);
51
52   END_TEST;
53 }
54
55 int UtcDaliUint16PairCopyConstructor(void)
56 {
57   Uint16Pair u(5u, 5u);
58   Uint16Pair v(u);
59   DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
60   DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
61
62   END_TEST;
63 }
64
65 int UtcDaliUint16PairMoveConstructor(void)
66 {
67   Uint16Pair u(5u, 5u);
68   Uint16Pair v = std::move(u);
69   DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
70   DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
71
72   END_TEST;
73 }
74
75 int UtcDaliUint16PairCopyAssignment(void)
76 {
77   Uint16Pair u(5u, 5u);
78   Uint16Pair v;
79   v = u;
80   DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
81   DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
82
83   END_TEST;
84 }
85
86 int UtcDaliUint16PairMoveAssignment(void)
87 {
88   Uint16Pair u(5u, 5u);
89   Uint16Pair v;
90   v = std::move(u);
91   DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
92   DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
93
94   END_TEST;
95 }
96
97 int UtcDaliUint16PairGetWidthP(void)
98 {
99   Uint16Pair v(5u, 5u);
100   DALI_TEST_EQUALS(v.GetWidth(), 5u, TEST_LOCATION);
101
102   END_TEST;
103 }
104
105 int UtcDaliUint16PairGetHeightP(void)
106 {
107   Uint16Pair v(5u, 5u);
108   DALI_TEST_EQUALS(v.GetHeight(), 5u, TEST_LOCATION);
109
110   END_TEST;
111 }
112
113 int UtcDaliUint16PairGetXP(void)
114 {
115   Uint16Pair v(5u, 5u);
116   DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
117
118   END_TEST;
119 }
120
121 int UtcDaliUint16PairGetYP(void)
122 {
123   Uint16Pair v(5u, 5u);
124   DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
125
126   END_TEST;
127 }
128
129 int UtcDaliUint16PairSetXP(void)
130 {
131   Uint16Pair v(5u, 5u);
132   DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
133   v.SetX(10u);
134   DALI_TEST_EQUALS(v.GetX(), 10u, TEST_LOCATION);
135
136   END_TEST;
137 }
138
139 int UtcDaliUint16PairSetWidthP(void)
140 {
141   Uint16Pair v(5u, 5u);
142   DALI_TEST_EQUALS(v.GetWidth(), 5u, TEST_LOCATION);
143   v.SetWidth(10u);
144   DALI_TEST_EQUALS(v.GetWidth(), 10u, TEST_LOCATION);
145
146   END_TEST;
147 }
148
149 int UtcDaliUint16PairSetYP(void)
150 {
151   Uint16Pair v(5u, 5u);
152   DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
153   v.SetY(10u);
154   DALI_TEST_EQUALS(v.GetY(), 10u, TEST_LOCATION);
155
156   END_TEST;
157 }
158
159 int UtcDaliUint16PairSetHeightP(void)
160 {
161   Uint16Pair v(5u, 5u);
162   DALI_TEST_EQUALS(v.GetHeight(), 5u, TEST_LOCATION);
163   v.SetHeight(10u);
164   DALI_TEST_EQUALS(v.GetHeight(), 10u, TEST_LOCATION);
165
166   END_TEST;
167 }
168
169 int UtcDaliUint16PairEqualsP(void)
170 {
171   Uint16Pair v(5u, 5u);
172   Uint16Pair u(5u, 5u);
173   DALI_TEST_EQUALS(v == u, true, TEST_LOCATION);
174
175   v = Uint16Pair(5u, 4u);
176   u = Uint16Pair(5u, 5u);
177   DALI_TEST_EQUALS(v == u, false, TEST_LOCATION);
178
179   END_TEST;
180 }
181
182 int UtcDaliUint16PairNotEqualsP(void)
183 {
184   Uint16Pair v(5u, 5u);
185   Uint16Pair u(5u, 5u);
186   DALI_TEST_EQUALS(v != u, false, TEST_LOCATION);
187
188   v = Uint16Pair(5u, 4u);
189   u = Uint16Pair(5u, 5u);
190   DALI_TEST_EQUALS(v != u, true, TEST_LOCATION);
191
192   END_TEST;
193 }
194
195 int UtcDaliUint16PairLessThanP(void)
196 {
197   Uint16Pair u(5u, 5u);
198   Uint16Pair v(6u, 6u);
199   DALI_TEST_EQUALS(u < v, true, TEST_LOCATION);
200
201   u = Uint16Pair(0u, 1u);
202   v = Uint16Pair(1u, 0u);
203   DALI_TEST_EQUALS(v < u, true, TEST_LOCATION);
204
205   u = Uint16Pair(1u, 0u);
206   v = Uint16Pair(0u, 1u);
207   DALI_TEST_EQUALS(v < u, false, TEST_LOCATION);
208
209   END_TEST;
210 }
211
212 int UtcDaliUint16PairGreaterThanP(void)
213 {
214   Uint16Pair u;
215   Uint16Pair v;
216
217   u = Uint16Pair(0u, 1u);
218   v = Uint16Pair(1u, 0u);
219   DALI_TEST_EQUALS(u > v, true, TEST_LOCATION);
220
221   u = Uint16Pair(1u, 0u);
222   v = Uint16Pair(0u, 1u);
223   DALI_TEST_EQUALS(v > u, true, TEST_LOCATION);
224
225   END_TEST;
226 }
227
228 int UtcDaliUint16PairFromFloatVecP(void)
229 {
230   Dali::Vector2 v2(5.f, 5.f);
231
232   Uint16Pair u = Uint16Pair::FromFloatVec2(v2);
233   DALI_TEST_EQUALS(u.GetX(), 5u, TEST_LOCATION);
234   DALI_TEST_EQUALS(u.GetY(), 5u, TEST_LOCATION);
235
236   Dali::Vector3 v3(5.f, 5.f, 5.f);
237
238   u = Uint16Pair::FromFloatVec2(v3);
239   DALI_TEST_EQUALS(u.GetX(), 5u, TEST_LOCATION);
240   DALI_TEST_EQUALS(u.GetY(), 5u, TEST_LOCATION);
241
242   END_TEST;
243 }
244
245 int UtcDaliUint16PairFromFloatArrayP(void)
246 {
247   float array[] = {5.f, 5.f};
248
249   Uint16Pair u = Uint16Pair::FromFloatArray(array);
250   DALI_TEST_EQUALS(u.GetX(), 5u, TEST_LOCATION);
251   DALI_TEST_EQUALS(u.GetY(), 5u, TEST_LOCATION);
252
253   END_TEST;
254 }