Merge "Remove some redundant&dead code from node" into devel/master
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Uint16Pair.cpp
1 /*
2  * Copyright (c) 2014 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 <iostream>
19
20 #include <stdlib.h>
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
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   Dali::TestApplication testApp;
38
39   Uint16Pair v;
40
41   DALI_TEST_EQUALS(v.GetX(), 0u, TEST_LOCATION);
42   DALI_TEST_EQUALS(v.GetY(), 0u, TEST_LOCATION);
43
44   END_TEST;
45 }
46
47 int UtcDaliUint16PairConstructor02P(void)
48 {
49   Dali::TestApplication testApp;
50
51   Uint16Pair v(10,10);
52
53   DALI_TEST_EQUALS(v.GetX(), 10u, TEST_LOCATION);
54   DALI_TEST_EQUALS(v.GetY(), 10u, TEST_LOCATION);
55
56   END_TEST;
57 }
58
59 int UtcDaliUint16PairCopyConstructor01P(void)
60 {
61   Dali::TestApplication testApp;
62
63   Uint16Pair u(5,5);
64   Uint16Pair v(u);
65   DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
66   DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
67
68   END_TEST;
69 }
70
71 int UtcDaliUint16PairGetWidthP(void)
72 {
73   Dali::TestApplication testApp;
74
75   Uint16Pair v(5,5);
76   DALI_TEST_EQUALS(v.GetWidth(), 5u, TEST_LOCATION);
77
78   END_TEST;
79 }
80
81 int UtcDaliUint16PairGetHeightP(void)
82 {
83   Dali::TestApplication testApp;
84
85   Uint16Pair v(5,5);
86   DALI_TEST_EQUALS(v.GetHeight(), 5u, TEST_LOCATION);
87
88   END_TEST;
89 }
90
91 int UtcDaliUint16PairGetXP(void)
92 {
93   Dali::TestApplication testApp;
94
95   Uint16Pair v(5,5);
96   DALI_TEST_EQUALS(v.GetX(), 5u, TEST_LOCATION);
97
98   END_TEST;
99 }
100
101 int UtcDaliUint16PairGetYP(void)
102 {
103   Dali::TestApplication testApp;
104
105   Uint16Pair v(5,5);
106   DALI_TEST_EQUALS(v.GetY(), 5u, TEST_LOCATION);
107
108   END_TEST;
109 }
110
111 int UtcDaliUint16PairSetXP(void)
112 {
113   Dali::TestApplication testApp;
114
115   Uint16Pair v( 5, 5 );
116   DALI_TEST_EQUALS( v.GetX(), 5u, TEST_LOCATION );
117   v.SetX( 10 );
118   DALI_TEST_EQUALS( v.GetX(), 10u, TEST_LOCATION );
119
120   END_TEST;
121 }
122
123 int UtcDaliUint16PairSetWidthP(void)
124 {
125   Dali::TestApplication testApp;
126
127   Uint16Pair v( 5, 5 );
128   DALI_TEST_EQUALS( v.GetWidth(), 5u, TEST_LOCATION );
129   v.SetWidth( 10 );
130   DALI_TEST_EQUALS( v.GetWidth(), 10u, TEST_LOCATION );
131
132   END_TEST;
133 }
134
135 int UtcDaliUint16PairSetYP(void)
136 {
137   Dali::TestApplication testApp;
138
139   Uint16Pair v( 5, 5 );
140   DALI_TEST_EQUALS( v.GetY(), 5u, TEST_LOCATION );
141   v.SetY( 10 );
142   DALI_TEST_EQUALS( v.GetY(), 10u, TEST_LOCATION );
143
144   END_TEST;
145 }
146
147 int UtcDaliUint16PairSetHeightP(void)
148 {
149   Dali::TestApplication testApp;
150
151   Uint16Pair v( 5, 5 );
152   DALI_TEST_EQUALS( v.GetHeight(), 5u, TEST_LOCATION );
153   v.SetHeight( 10 );
154   DALI_TEST_EQUALS( v.GetHeight(), 10u, TEST_LOCATION );
155
156   END_TEST;
157 }
158
159 int UtcDaliUint16PairEqualsP(void)
160 {
161   Dali::TestApplication testApp;
162
163   Uint16Pair v(5,5);
164   Uint16Pair u(5,5);
165   DALI_TEST_EQUALS(v == u, true, TEST_LOCATION);
166
167   v = Uint16Pair(5,4);
168   u = Uint16Pair(5,5);
169   DALI_TEST_EQUALS(v == u, false, TEST_LOCATION);
170
171   END_TEST;
172 }
173
174 int UtcDaliUint16PairNotEqualsP(void)
175 {
176   Dali::TestApplication testApp;
177
178   Uint16Pair v(5,5);
179   Uint16Pair u(5,5);
180   DALI_TEST_EQUALS(v != u, false, TEST_LOCATION);
181
182   v = Uint16Pair(5,4);
183   u = Uint16Pair(5,5);
184   DALI_TEST_EQUALS(v != u, true, TEST_LOCATION);
185
186   END_TEST;
187 }
188
189 int UtcDaliUint16PairLessThanP(void)
190 {
191   Dali::TestApplication testApp;
192
193   Uint16Pair u(5,5);
194   Uint16Pair v(6,6);
195   DALI_TEST_EQUALS(u < v, true, TEST_LOCATION);
196
197   u = Uint16Pair(0,1);
198   v = Uint16Pair(1,0);
199   DALI_TEST_EQUALS(v < u, true, TEST_LOCATION);
200
201   u = Uint16Pair(1,0);
202   v = Uint16Pair(0,1);
203   DALI_TEST_EQUALS(v < u, false, TEST_LOCATION);
204
205   END_TEST;
206 }
207
208 int UtcDaliUint16PairGreaterThanP(void)
209 {
210   Dali::TestApplication testApp;
211
212   Uint16Pair u;
213   Uint16Pair v;
214
215   u = Uint16Pair(0,1);
216   v = Uint16Pair(1,0);
217   DALI_TEST_EQUALS(u > v, true, TEST_LOCATION);
218
219   u = Uint16Pair(1,0);
220   v = Uint16Pair(0,1);
221   DALI_TEST_EQUALS(v > u, true, TEST_LOCATION);
222
223   END_TEST;
224 }
225
226 int UtcDaliUint16PairFromFloatVecP(void)
227 {
228   Dali::TestApplication testApp;
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   Dali::TestApplication testApp;
248
249   float array[] = {5.f, 5.f};
250
251   Uint16Pair u = Uint16Pair::FromFloatArray(array);
252   DALI_TEST_EQUALS(u.GetX(), 5u, TEST_LOCATION);
253   DALI_TEST_EQUALS(u.GetY(), 5u, TEST_LOCATION);
254
255   END_TEST;
256 }