summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-12-19 16:26:22 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-12-19 16:33:46 -0800
commitd03482a0a7f582a3033338e45e6c3ec86f5e56ed (patch)
tree8a96e4ace350dccaab0ba395046e2639f9c9ef8d /src
parent701aa35e6ed7f8e44195913e51ea488ffaf92465 (diff)
eina: use proper logic for comparing double in matrix tests.
Diffstat (limited to 'src')
-rw-r--r--src/tests/eina/eina_test_matrix.c401
1 files changed, 234 insertions, 167 deletions
diff --git a/src/tests/eina/eina_test_matrix.c b/src/tests/eina/eina_test_matrix.c
index a2f6d9c97a..bfdafbf8dd 100644
--- a/src/tests/eina/eina_test_matrix.c
+++ b/src/tests/eina/eina_test_matrix.c
@@ -49,10 +49,10 @@ START_TEST(eina_matrix2)
49 &xx, &xy, 49 &xx, &xy,
50 &yx, &yy); 50 &yx, &yy);
51 51
52 fail_if(xx != yy || 52 fail_if(!EINA_DBL_CMP(xx, yy) ||
53 yy != 1); 53 !EINA_DBL_CMP(yy, 1));
54 fail_if(xy != yx || 54 fail_if(!EINA_DBL_CMP(xy, yx) ||
55 xy != 0); 55 !EINA_DBL_CMP(xy, 0));
56 56
57 eina_shutdown(); 57 eina_shutdown();
58} 58}
@@ -78,26 +78,26 @@ START_TEST(eina_matrix2_operation)
78 eina_matrix2_values_get(&m1, 78 eina_matrix2_values_get(&m1,
79 &xx, &xy, 79 &xx, &xy,
80 &yx, &yy); 80 &yx, &yy);
81 fail_if(xx != yy || 81 fail_if(!EINA_DBL_CMP(xx, yy) ||
82 yy != 1 || 82 !EINA_DBL_CMP(yy, 1));
83 xy != yx || 83 fail_if(!EINA_DBL_CMP(xy, yx) ||
84 xy != 0); 84 !EINA_DBL_CMP(xy, 0));
85 85
86 eina_matrix2_array_set(&m1, arr); 86 eina_matrix2_array_set(&m1, arr);
87 eina_matrix2_values_get(&m1, 87 eina_matrix2_values_get(&m1,
88 &xx, &xy, 88 &xx, &xy,
89 &yx, &yy); 89 &yx, &yy);
90 fail_if(xx != yy || 90 fail_if(!EINA_DBL_CMP(xx, yy) ||
91 yx != xy || 91 !EINA_DBL_CMP(yx, xy) ||
92 xy != 1); 92 !EINA_DBL_CMP(xy, 1));
93 93
94 eina_matrix2_copy(&m2, &m1); 94 eina_matrix2_copy(&m2, &m1);
95 eina_matrix2_values_get(&m2, 95 eina_matrix2_values_get(&m2,
96 &xx, &xy, 96 &xx, &xy,
97 &yx, &yy); 97 &yx, &yy);
98 fail_if(xx != yy || 98 fail_if(!EINA_DBL_CMP(xx, yy) ||
99 yx != xy || 99 !EINA_DBL_CMP(yx, xy) ||
100 xy != 1); 100 !EINA_DBL_CMP(xy, 1));
101 101
102 eina_matrix2_values_set(&m1, 102 eina_matrix2_values_set(&m1,
103 2, 3, 103 2, 3,
@@ -106,17 +106,17 @@ START_TEST(eina_matrix2_operation)
106 eina_matrix2_values_get(&m3, 106 eina_matrix2_values_get(&m3,
107 &xx, &xy, 107 &xx, &xy,
108 &yx, &yy); 108 &yx, &yy);
109 fail_if(xx != yy || 109 fail_if(!EINA_DBL_CMP(xx, yy) ||
110 yx != xy || 110 !EINA_DBL_CMP(yx, xy) ||
111 xy != 5); 111 !EINA_DBL_CMP(xy, 5));
112 112
113 eina_matrix2_multiply(&m3, &m1, &m2); 113 eina_matrix2_multiply(&m3, &m1, &m2);
114 eina_matrix2_values_get(&m3, 114 eina_matrix2_values_get(&m3,
115 &xx, &xy, 115 &xx, &xy,
116 &yx, &yy); 116 &yx, &yy);
117 fail_if(xx != yy || 117 fail_if(!EINA_DBL_CMP(xx, yy) ||
118 yx != xy || 118 !EINA_DBL_CMP(yx, xy) ||
119 xy != 5); 119 !EINA_DBL_CMP(xy, 5));
120 120
121} 121}
122END_TEST 122END_TEST
@@ -151,22 +151,22 @@ START_TEST(eina_matrix4)
151 &zx, &zy, &zz, &zw, 151 &zx, &zy, &zz, &zw,
152 &wx, &wy, &wz, &ww); 152 &wx, &wy, &wz, &ww);
153 153
154 fail_if(xx != yy || 154 fail_if(!EINA_DBL_CMP(xx, yy) ||
155 yy != zz || 155 !EINA_DBL_CMP(yy, zz) ||
156 zz != ww || 156 !EINA_DBL_CMP(zz, ww) ||
157 ww != 1); 157 !EINA_DBL_CMP(ww, 1));
158 fail_if(xy != xz || 158 fail_if(!EINA_DBL_CMP(xy, xz) ||
159 xz != xw || 159 !EINA_DBL_CMP(xz, xw) ||
160 xw != yx || 160 !EINA_DBL_CMP(xw, yx) ||
161 yx != yz || 161 !EINA_DBL_CMP(yx, yz) ||
162 yz != yw || 162 !EINA_DBL_CMP(yz, yw) ||
163 yw != zx || 163 !EINA_DBL_CMP(yw, zx) ||
164 zx != zy || 164 !EINA_DBL_CMP(zx, zy) ||
165 zy != zw || 165 !EINA_DBL_CMP(zy, zw) ||
166 zw != wx || 166 !EINA_DBL_CMP(zw, wx) ||
167 wx != wy || 167 !EINA_DBL_CMP(wx, wy) ||
168 wy != wz || 168 !EINA_DBL_CMP(wy, wz) ||
169 wz != 0); 169 !EINA_DBL_CMP(wz, 0));
170 170
171 eina_matrix4_values_set(&m, 171 eina_matrix4_values_set(&m,
172 1, 2, 3, 4, 172 1, 2, 3, 4,
@@ -175,10 +175,22 @@ START_TEST(eina_matrix4)
175 13, 14, 15, 16); 175 13, 14, 15, 16);
176 176
177 eina_matrix4_transpose(&n, &m); 177 eina_matrix4_transpose(&n, &m);
178 fail_if(n.xx != 1 || n.xy != 5 || n.xz != 9 || n.xw != 13 || 178 fail_if(!EINA_DBL_CMP(n.xx, 1) ||
179 n.yx != 2 || n.yy != 6 || n.yz != 10 || n.yw != 14 || 179 !EINA_DBL_CMP(n.xy, 5) ||
180 n.zx != 3 || n.zy != 7 || n.zz != 11 || n.zw != 15 || 180 !EINA_DBL_CMP(n.xz, 9) ||
181 n.wx != 4 || n.wy != 8 || n.wz != 12 || n.ww != 16); 181 !EINA_DBL_CMP(n.xw, 13) ||
182 !EINA_DBL_CMP(n.yx, 2) ||
183 !EINA_DBL_CMP(n.yy, 6) ||
184 !EINA_DBL_CMP(n.yz, 10) ||
185 !EINA_DBL_CMP(n.yw, 14) ||
186 !EINA_DBL_CMP(n.zx, 3) ||
187 !EINA_DBL_CMP(n.zy, 7) ||
188 !EINA_DBL_CMP(n.zz, 11) ||
189 !EINA_DBL_CMP(n.zw, 15) ||
190 !EINA_DBL_CMP(n.wx, 4) ||
191 !EINA_DBL_CMP(n.wy, 8) ||
192 !EINA_DBL_CMP(n.wz, 12) ||
193 !EINA_DBL_CMP(n.ww, 16));
182 194
183 eina_shutdown(); 195 eina_shutdown();
184} 196}
@@ -201,7 +213,7 @@ START_TEST(eina_matrix4_operation)
201 0, 0, 0, 2, 213 0, 0, 0, 2,
202 0, 2, 0, 0); 214 0, 2, 0, 0);
203 det = eina_matrix4_determinant(&m); 215 det = eina_matrix4_determinant(&m);
204 fail_if(det != -16); 216 fail_if(!EINA_DBL_CMP(det, -16));
205 217
206 eina_matrix4_inverse(&m1, &m); 218 eina_matrix4_inverse(&m1, &m);
207 eina_matrix4_values_get(&m1, 219 eina_matrix4_values_get(&m1,
@@ -209,10 +221,10 @@ START_TEST(eina_matrix4_operation)
209 &yx, &yy, &yz, &yw, 221 &yx, &yy, &yz, &yw,
210 &zx, &zy, &zz, &zw, 222 &zx, &zy, &zz, &zw,
211 &wx, &wy, &wz, &ww); 223 &wx, &wy, &wz, &ww);
212 fail_if (xy != 0.5 || 224 fail_if (!EINA_DBL_CMP(xy, 0.5) ||
213 yw != xy || 225 !EINA_DBL_CMP(yw, xy) ||
214 zx != yw || 226 !EINA_DBL_CMP(zx, yw) ||
215 wz != zx); 227 !EINA_DBL_CMP(wz, zx));
216 228
217 eina_matrix4_identity(&m1); 229 eina_matrix4_identity(&m1);
218 eina_matrix4_values_get(&m1, 230 eina_matrix4_values_get(&m1,
@@ -220,10 +232,10 @@ START_TEST(eina_matrix4_operation)
220 &yx, &yy, &yz, &yw, 232 &yx, &yy, &yz, &yw,
221 &zx, &zy, &zz, &zw, 233 &zx, &zy, &zz, &zw,
222 &wx, &wy, &wz, &ww); 234 &wx, &wy, &wz, &ww);
223 fail_if (xx != 1 || 235 fail_if (!EINA_DBL_CMP(xx, 1) ||
224 yy != xx || 236 !EINA_DBL_CMP(yy, xx) ||
225 zz != yy || 237 !EINA_DBL_CMP(zz, yy) ||
226 ww != zz); 238 !EINA_DBL_CMP(ww, zz));
227 239
228 eina_matrix4_values_set(&m1, 240 eina_matrix4_values_set(&m1,
229 0, 2, 2, 0, 241 0, 2, 2, 0,
@@ -236,14 +248,14 @@ START_TEST(eina_matrix4_operation)
236 &yx, &yy, &yz, &yw, 248 &yx, &yy, &yz, &yw,
237 &zx, &zy, &zz, &zw, 249 &zx, &zy, &zz, &zw,
238 &wx, &wy, &wz, &ww); 250 &wx, &wy, &wz, &ww);
239 fail_if (xx != 4 || 251 fail_if (!EINA_DBL_CMP(xx, 4) ||
240 xw != xx || 252 !EINA_DBL_CMP(xw, xx) ||
241 yy != xw || 253 !EINA_DBL_CMP(yy, xw) ||
242 yz != yy || 254 !EINA_DBL_CMP(yz, yy) ||
243 zy != yz || 255 !EINA_DBL_CMP(zy, yz) ||
244 zz != yy || 256 !EINA_DBL_CMP(zz, yy) ||
245 wx != xx || 257 !EINA_DBL_CMP(wx, xx) ||
246 ww != zy); 258 !EINA_DBL_CMP(ww, zy));
247 259
248 eina_matrix4_multiply(&m2, &m1, &m); 260 eina_matrix4_multiply(&m2, &m1, &m);
249 eina_matrix4_values_get(&m2, 261 eina_matrix4_values_get(&m2,
@@ -251,14 +263,14 @@ START_TEST(eina_matrix4_operation)
251 &yx, &yy, &yz, &yw, 263 &yx, &yy, &yz, &yw,
252 &zx, &zy, &zz, &zw, 264 &zx, &zy, &zz, &zw,
253 &wx, &wy, &wz, &ww); 265 &wx, &wy, &wz, &ww);
254 fail_if (xx != 4 || 266 fail_if (!EINA_DBL_CMP(xx, 4) ||
255 xw != xx || 267 !EINA_DBL_CMP(xw, xx) ||
256 yy != xw || 268 !EINA_DBL_CMP(yy, xw) ||
257 yz != yy || 269 !EINA_DBL_CMP(yz, yy) ||
258 zy != yz || 270 !EINA_DBL_CMP(zy, yz) ||
259 zz != yy || 271 !EINA_DBL_CMP(zz, yy) ||
260 wx != xx || 272 !EINA_DBL_CMP(wx, xx) ||
261 ww != zy); 273 !EINA_DBL_CMP(ww, zy));
262 274
263 eina_matrix4_array_set(&m1, arr); 275 eina_matrix4_array_set(&m1, arr);
264 eina_matrix4_values_get(&m1, 276 eina_matrix4_values_get(&m1,
@@ -266,14 +278,14 @@ START_TEST(eina_matrix4_operation)
266 &yx, &yy, &yz, &yw, 278 &yx, &yy, &yz, &yw,
267 &zx, &zy, &zz, &zw, 279 &zx, &zy, &zz, &zw,
268 &wx, &wy, &wz, &ww); 280 &wx, &wy, &wz, &ww);
269 fail_if (xx != 1 || 281 fail_if (!EINA_DBL_CMP(xx, 1) ||
270 xw != xx || 282 !EINA_DBL_CMP(xw, xx) ||
271 yy != xw || 283 !EINA_DBL_CMP(yy, xw) ||
272 yz != yy || 284 !EINA_DBL_CMP(yz, yy) ||
273 zy != yz || 285 !EINA_DBL_CMP(zy, yz) ||
274 zz != yy || 286 !EINA_DBL_CMP(zz, yy) ||
275 wx != xx || 287 !EINA_DBL_CMP(wx, xx) ||
276 ww != zy); 288 !EINA_DBL_CMP(ww, zy));
277 289
278 eina_matrix4_copy(&m, &m1); 290 eina_matrix4_copy(&m, &m1);
279 eina_matrix4_values_get(&m1, 291 eina_matrix4_values_get(&m1,
@@ -281,14 +293,14 @@ START_TEST(eina_matrix4_operation)
281 &yx, &yy, &yz, &yw, 293 &yx, &yy, &yz, &yw,
282 &zx, &zy, &zz, &zw, 294 &zx, &zy, &zz, &zw,
283 &wx, &wy, &wz, &ww); 295 &wx, &wy, &wz, &ww);
284 fail_if (xx != 1 || 296 fail_if (!EINA_DBL_CMP(xx, 1) ||
285 xw != xx || 297 !EINA_DBL_CMP(xw, xx) ||
286 yy != xw || 298 !EINA_DBL_CMP(yy, xw) ||
287 yz != yy || 299 !EINA_DBL_CMP(yz, yy) ||
288 zy != yz || 300 !EINA_DBL_CMP(zy, yz) ||
289 zz != yy || 301 !EINA_DBL_CMP(zz, yy) ||
290 wx != xx || 302 !EINA_DBL_CMP(wx, xx) ||
291 ww != zy); 303 !EINA_DBL_CMP(ww, zy));
292 304
293 eina_matrix4_ortho_set(&m, l, r, b, t, dn, df); 305 eina_matrix4_ortho_set(&m, l, r, b, t, dn, df);
294 eina_matrix4_values_get(&m, 306 eina_matrix4_values_get(&m,
@@ -296,13 +308,13 @@ START_TEST(eina_matrix4_operation)
296 &yx, &yy, &yz, &yw, 308 &yx, &yy, &yz, &yw,
297 &zx, &zy, &zz, &zw, 309 &zx, &zy, &zz, &zw,
298 &wx, &wy, &wz, &ww); 310 &wx, &wy, &wz, &ww);
299 fail_if (xx != -2 || 311 fail_if (!EINA_DBL_CMP(xx, -2) ||
300 yy != -2 || 312 !EINA_DBL_CMP(yy, -2) ||
301 zz != 2 || 313 !EINA_DBL_CMP(zz, 2) ||
302 wx != 9 || 314 !EINA_DBL_CMP(wx, 9) ||
303 wy != 7 || 315 !EINA_DBL_CMP(wy, 7) ||
304 wz != 5 || 316 !EINA_DBL_CMP(wz, 5) ||
305 ww != 1); 317 !EINA_DBL_CMP(ww, 1));
306} 318}
307END_TEST 319END_TEST
308 320
@@ -358,14 +370,14 @@ START_TEST(eina_matrix3)
358 &yx, &yy, &yz, 370 &yx, &yy, &yz,
359 &zx, &zy, &zz); 371 &zx, &zy, &zz);
360 372
361 fail_if(xx != yy || 373 fail_if(!EINA_DBL_CMP(xx, yy) ||
362 yy != zz || 374 !EINA_DBL_CMP(yy, zz) ||
363 zz != 1); 375 !EINA_DBL_CMP(zz, 1));
364 376
365 fail_if(xy != xz || 377 fail_if(!EINA_DBL_CMP(xy, xz) ||
366 yx != yz || 378 !EINA_DBL_CMP(yx, yz) ||
367 zx != zy || 379 !EINA_DBL_CMP(zx, zy) ||
368 zy != 0); 380 !EINA_DBL_CMP(zy, 0));
369 381
370 ret = eina_matrix3_equal(&m, &m1); 382 ret = eina_matrix3_equal(&m, &m1);
371 fail_if(ret != EINA_TRUE); 383 fail_if(ret != EINA_TRUE);
@@ -377,6 +389,17 @@ START_TEST(eina_matrix3)
377} 389}
378END_TEST 390END_TEST
379 391
392#define MATRIX3_CMP(XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ, AXX, AXY, AXZ, AYX, AYY, AYZ, AZX, AZY, AZZ) \
393 (EINA_DBL_CMP(XX, AXX) && \
394 EINA_DBL_CMP(XY, AXY) && \
395 EINA_DBL_CMP(XZ, AXZ) && \
396 EINA_DBL_CMP(YX, AYX) && \
397 EINA_DBL_CMP(YY, AYY) && \
398 EINA_DBL_CMP(YZ, AYZ) && \
399 EINA_DBL_CMP(ZX, AZX) && \
400 EINA_DBL_CMP(ZY, AZY) && \
401 EINA_DBL_CMP(ZZ, AZZ))
402
380START_TEST(eina_matrix3_operations) 403START_TEST(eina_matrix3_operations)
381{ 404{
382 Eina_Matrix3 m1, m2, m3; 405 Eina_Matrix3 m1, m2, m3;
@@ -402,22 +425,25 @@ START_TEST(eina_matrix3_operations)
402 &xx, &xy, &xz, 425 &xx, &xy, &xz,
403 &yx, &yy, &yz, 426 &yx, &yy, &yz,
404 &zx, &zy, &zz); 427 &zx, &zy, &zz);
405 fail_if (xx != xy || 428 fail_if (!EINA_DBL_CMP(xx, xy) ||
406 xy != xz || 429 !EINA_DBL_CMP(xy, xz) ||
407 yx != yy || 430 !EINA_DBL_CMP(yx, yy) ||
408 yy != yz || 431 !EINA_DBL_CMP(yy, yz) ||
409 zx != zy || 432 !EINA_DBL_CMP(zx, zy) ||
410 zy != zz || 433 !EINA_DBL_CMP(zy, zz) ||
411 zz != 1); 434 !EINA_DBL_CMP(zz, 1));
412 435
413 eina_matrix3_translate(&m1, tx, ty); 436 eina_matrix3_translate(&m1, tx, ty);
414 eina_matrix3_values_get(&m1, 437 eina_matrix3_values_get(&m1,
415 &xx, &xy, &xz, 438 &xx, &xy, &xz,
416 &yx, &yy, &yz, 439 &yx, &yy, &yz,
417 &zx, &zy, &zz); 440 &zx, &zy, &zz);
418 fail_if (xx != 1 || xy != 0 || xz != tx || 441 fail_if(!MATRIX3_CMP(xx, xy, xz,
419 yx != 0 || yy != 1 || yz != ty || 442 yx, yy, yz,
420 zx != 0 || zy != 0 || zz != 1); 443 zx, zy, zz,
444 1, 0, tx,
445 0, 1, ty,
446 0, 0, 1));
421 447
422 eina_matrix3_values_set(&m1, 448 eina_matrix3_values_set(&m1,
423 1, 0, 0, 449 1, 0, 0,
@@ -429,9 +455,12 @@ START_TEST(eina_matrix3_operations)
429 &xx, &xy, &xz, 455 &xx, &xy, &xz,
430 &yx, &yy, &yz, 456 &yx, &yy, &yz,
431 &zx, &zy, &zz); 457 &zx, &zy, &zz);
432 fail_if (xx != tx || xy != 0 || xz != 0 || 458 fail_if(!MATRIX3_CMP(xx, xy, xz,
433 yx != 0 || yy != ty || yz != 0 || 459 yx, yy, yz,
434 zx != 0 || zy != 0 || zz != 1); 460 zx, zy, zz,
461 tx, 0, 0,
462 0, ty, 0,
463 0, 0, 1));
435 464
436 eina_matrix3_values_set(&m1, 465 eina_matrix3_values_set(&m1,
437 1, 0, 0, 466 1, 0, 0,
@@ -439,11 +468,12 @@ START_TEST(eina_matrix3_operations)
439 0, 0, 1); 468 0, 0, 1);
440 eina_matrix3_rotate(&m1, M_PI/2); 469 eina_matrix3_rotate(&m1, M_PI/2);
441 470
442 fail_if (round(m1.xx) != 0 || round(m1.xy) != -1 || 471 fail_if (!MATRIX3_CMP(round(m1.xx), round(m1.xy), round(m1.xz),
443 round(m1.xz) != 0 || round(m1.yx) != 1 || 472 round(m1.yx), round(m1.yy), round(m1.yz),
444 round(m1.yy) != 0 || round(m1.yz) !=0 || 473 round(m1.zx), round(m1.zy), round(m1.zz),
445 round(m1.zx) != 0 || round(m1.zy) != 0|| 474 0, -1, 0,
446 round(m1.zz) != 1); 475 1, 0, 0,
476 0, 0, 1));
447 477
448 eina_matrix3_values_set(&m1, 478 eina_matrix3_values_set(&m1,
449 1, 1, 1, 479 1, 1, 1,
@@ -454,22 +484,21 @@ START_TEST(eina_matrix3_operations)
454 &xx, &xy, &xz, 484 &xx, &xy, &xz,
455 &yx, &yy, &yz, 485 &yx, &yy, &yz,
456 &zx, &zy, &zz); 486 &zx, &zy, &zz);
457 fail_if(xx != yy || 487 fail_if(!EINA_DBL_CMP(xx, yy) ||
458 yy != zz || 488 !EINA_DBL_CMP(yy, zz) ||
459 zz != 1); 489 !EINA_DBL_CMP(zz, 1));
460
461 fail_if(xy != xz ||
462 yx != yz ||
463 zx != zy ||
464 zy != 0);
465 490
491 fail_if(!EINA_DBL_CMP(xy, xz) ||
492 !EINA_DBL_CMP(yx, yz) ||
493 !EINA_DBL_CMP(zx, zy) ||
494 !EINA_DBL_CMP(zy, 0));
466 495
467 eina_matrix3_values_set(&m1, 496 eina_matrix3_values_set(&m1,
468 1, 2, 1, 497 1, 2, 1,
469 2, 1, 1, 498 2, 1, 1,
470 1, 2, 2); 499 1, 2, 2);
471 ret = eina_matrix3_determinant(&m1); 500 ret = eina_matrix3_determinant(&m1);
472 fail_if(ret != -3); 501 fail_if(!EINA_DBL_CMP(ret, -3));
473 502
474 eina_matrix3_values_set(&m1, 503 eina_matrix3_values_set(&m1,
475 3, 3, 3, 504 3, 3, 3,
@@ -480,13 +509,13 @@ START_TEST(eina_matrix3_operations)
480 &xx, &xy, &xz, 509 &xx, &xy, &xz,
481 &yx, &yy, &yz, 510 &yx, &yy, &yz,
482 &zx, &zy, &zz); 511 &zx, &zy, &zz);
483 fail_if (xx != xy || 512 fail_if (!EINA_DBL_CMP(xx, xy) ||
484 xy != xz || 513 !EINA_DBL_CMP(xy, xz) ||
485 yx != yy || 514 !EINA_DBL_CMP(yx, yy) ||
486 yy != yz || 515 !EINA_DBL_CMP(yy, yz) ||
487 zx != zy || 516 !EINA_DBL_CMP(zx, zy) ||
488 zy != zz || 517 !EINA_DBL_CMP(zy, zz) ||
489 zz != 1.5); 518 !EINA_DBL_CMP(zz, 1.5));
490 519
491 eina_matrix3_values_set(&m1, 520 eina_matrix3_values_set(&m1,
492 0, 2, 0, 521 0, 2, 0,
@@ -497,9 +526,12 @@ START_TEST(eina_matrix3_operations)
497 &xx, &xy, &xz, 526 &xx, &xy, &xz,
498 &yx, &yy, &yz, 527 &yx, &yy, &yz,
499 &zx, &zy, &zz); 528 &zx, &zy, &zz);
500 fail_if (xx != -0.5 || xy != 0.5 || xz != 0 || 529 fail_if(!MATRIX3_CMP(xx, xy, xz,
501 yx != 0.5 || yy != 0 || yz != 0 || 530 yx, yy, yz,
502 zx != 0.25 || zy != -0.5 || zz != 0.5); 531 zx, zy, zz,
532 -0.5, 0.5, 0.0,
533 0.5, 0.0, 0.0,
534 0.25, -0.5, 0.5));
503 535
504 eina_matrix3_values_set(&m1, 536 eina_matrix3_values_set(&m1,
505 1, 2, 3, 537 1, 2, 3,
@@ -510,9 +542,12 @@ START_TEST(eina_matrix3_operations)
510 &xx, &xy, &xz, 542 &xx, &xy, &xz,
511 &yx, &yy, &yz, 543 &yx, &yy, &yz,
512 &zx, &zy, &zz); 544 &zx, &zy, &zz);
513 fail_if (xx != 1 || xy != 4 || xz != 7 || 545 fail_if(!MATRIX3_CMP(xx, xy, xz,
514 yx != 2 || yy != 5 || yz != 8 || 546 yx, yy, yz,
515 zx != 3 || zy != 6 || zz != 9); 547 zx, zy, zz,
548 1, 4, 7,
549 2, 5, 8,
550 3, 6, 9));
516 551
517 eina_matrix3_values_set(&m1, 552 eina_matrix3_values_set(&m1,
518 1, 2, 3, 553 1, 2, 3,
@@ -523,18 +558,24 @@ START_TEST(eina_matrix3_operations)
523 &xx, &xy, &xz, 558 &xx, &xy, &xz,
524 &yx, &yy, &yz, 559 &yx, &yy, &yz,
525 &zx, &zy, &zz); 560 &zx, &zy, &zz);
526 fail_if (xx != 24 || xy != 5 || xz != -4 || 561 fail_if(!MATRIX3_CMP(xx, xy, xz,
527 yx != -12 || yy != 3 || yz != 2 || 562 yx, yy, yz,
528 zx != -2 || zy != -5 || zz != 4); 563 zx, zy, zz,
564 24, 5, -4,
565 -12, 3, 2,
566 -2, -5, 4));
529 567
530 eina_matrix3_adjoint(&m1, &m2); 568 eina_matrix3_adjoint(&m1, &m2);
531 eina_matrix3_values_get(&m2, 569 eina_matrix3_values_get(&m2,
532 &xx, &xy, &xz, 570 &xx, &xy, &xz,
533 &yx, &yy, &yz, 571 &yx, &yy, &yz,
534 &zx, &zy, &zz); 572 &zx, &zy, &zz);
535 fail_if (xx != 24 || xy != -12 || xz != -2 || 573 fail_if(!MATRIX3_CMP(xx, xy, xz,
536 yx != 5 || yy != 3 || yz != -5 || 574 yx, yy, yz,
537 zx != -4 || zy != 2 || zz != 4); 575 zx, zy, zz,
576 24, -12, -2,
577 5, 3, -5,
578 -4, 2, 4));
538 579
539 eina_matrix3_values_set(&m2, 580 eina_matrix3_values_set(&m2,
540 2, 2, 2, 581 2, 2, 2,
@@ -549,9 +590,12 @@ START_TEST(eina_matrix3_operations)
549 &xx, &xy, &xz, 590 &xx, &xy, &xz,
550 &yx, &yy, &yz, 591 &yx, &yy, &yz,
551 &zx, &zy, &zz); 592 &zx, &zy, &zz);
552 fail_if (xx != 12 || xy != 12 || xz != 12 || 593 fail_if(!MATRIX3_CMP(xx, xy, xz,
553 yx != 6 || yy != 6 || yz != 6 || 594 yx, yy, yz,
554 zx != 18 || zy != 18 || zz != 18); 595 zx, zy, zz,
596 12, 12, 12,
597 6, 6, 6,
598 18, 18, 18));
555 599
556 eina_matrix3_values_set(&m2, 600 eina_matrix3_values_set(&m2,
557 2, 2, 2, 601 2, 2, 2,
@@ -562,41 +606,52 @@ START_TEST(eina_matrix3_operations)
562 &xx, &xy, &xz, 606 &xx, &xy, &xz,
563 &yx, &yy, &yz, 607 &yx, &yy, &yz,
564 &zx, &zy, &zz); 608 &zx, &zy, &zz);
565 fail_if (xx != 12 || xy != 12 || xz != 12 || 609 fail_if(!MATRIX3_CMP(xx, xy, xz,
566 yx != 6 || yy != 6 || yz != 6 || 610 yx, yy, yz,
567 zx != 0 || zy != 0 || zz != 0); 611 zx, zy, zz,
612 12, 12, 12,
613 6, 6, 6,
614 0, 0, 0));
568 615
569 eina_matrix3_copy(&m1, &m2); 616 eina_matrix3_copy(&m1, &m2);
570 eina_matrix3_values_get(&m1, 617 eina_matrix3_values_get(&m1,
571 &xx, &xy, &xz, 618 &xx, &xy, &xz,
572 &yx, &yy, &yz, 619 &yx, &yy, &yz,
573 &zx, &zy, &zz); 620 &zx, &zy, &zz);
574 fail_if (xx != 2 || xy != 2 || xz != 2 || 621 fail_if(!MATRIX3_CMP(xx, xy, xz,
575 yx != 1 || yy != 1 || yz != 1 || 622 yx, yy, yz,
576 zx != 0 || zy != 0 || zz != 0); 623 zx, zy, zz,
624 2, 2, 2,
625 1, 1, 1,
626 0, 0, 0));
577 627
578 eina_matrix3_array_set(&m1, arr); 628 eina_matrix3_array_set(&m1, arr);
579 eina_matrix3_values_get(&m1, 629 eina_matrix3_values_get(&m1,
580 &xx, &xy, &xz, 630 &xx, &xy, &xz,
581 &yx, &yy, &yz, 631 &yx, &yy, &yz,
582 &zx, &zy, &zz); 632 &zx, &zy, &zz);
583 fail_if (xx != 1 || xy != 1 || xz != 1 || 633 fail_if(!MATRIX3_CMP(xx, xy, xz,
584 yx != 1 || yy != 1 || yz != 1 || 634 yx, yy, yz,
585 zx != 1 || zy != 1 || zz != 1); 635 zx, zy, zz,
636 1, 1, 1,
637 1, 1, 1,
638 1, 1, 1));
586 639
587 eina_matrix3_position_transform_set(&m3, 5, 3); 640 eina_matrix3_position_transform_set(&m3, 5, 3);
588 eina_matrix3_values_get(&m3, 641 eina_matrix3_values_get(&m3,
589 &xx, &xy, &xz, 642 &xx, &xy, &xz,
590 &yx, &yy, &yz, 643 &yx, &yy, &yz,
591 &zx, &zy, &zz); 644 &zx, &zy, &zz);
592 fail_if (xz != 5 || yz != 3); 645 fail_if (!EINA_DBL_CMP(xz, 5) ||
646 !EINA_DBL_CMP(yz, 3));
593 647
594 eina_matrix3_scale_transform_set(&m2, 6, 7); 648 eina_matrix3_scale_transform_set(&m2, 6, 7);
595 eina_matrix3_values_get(&m2, 649 eina_matrix3_values_get(&m2,
596 &xx, &xy, &xz, 650 &xx, &xy, &xz,
597 &yx, &yy, &yz, 651 &yx, &yy, &yz,
598 &zx, &zy, &zz); 652 &zx, &zy, &zz);
599 fail_if (xx != 6 || yy != 7); 653 fail_if (!EINA_DBL_CMP(xx, 6) ||
654 !EINA_DBL_CMP(yy, 7));
600} 655}
601END_TEST 656END_TEST
602 657
@@ -682,15 +737,20 @@ START_TEST(eina_matrix3_map_transform)
682 eina_matrix3_point_transform(&m, 737 eina_matrix3_point_transform(&m,
683 x, y, 738 x, y,
684 &x1, &y1); 739 &x1, &y1);
685 fail_if(x1 != 3 || y1 != 2); 740 fail_if(!EINA_DBL_CMP(x1, 3) ||
741 !EINA_DBL_CMP(y1, 2));
686 742
687 EINA_RECTANGLE_SET(&r, 0, 0, 3, 4); 743 EINA_RECTANGLE_SET(&r, 0, 0, 3, 4);
688 eina_matrix3_rectangle_transform(&m, &r, &q); 744 eina_matrix3_rectangle_transform(&m, &r, &q);
689 745
690 fail_if(q.x0 != 0 || q.y0 != 0 || 746 fail_if(!EINA_DBL_CMP(q.x0, 0) ||
691 q.x1 != 0 || q.y1 != 3 || 747 !EINA_DBL_CMP(q.y0, 0) ||
692 q.x2 != 4 || q.y2 != 3 || 748 !EINA_DBL_CMP(q.x1, 0) ||
693 q.x3 != 4 || q.y3 != 0); 749 !EINA_DBL_CMP(q.y1, 3) ||
750 !EINA_DBL_CMP(q.x2, 4) ||
751 !EINA_DBL_CMP(q.y2, 3) ||
752 !EINA_DBL_CMP(q.x3, 4) ||
753 !EINA_DBL_CMP(q.y3, 0));
694 754
695 eina_quad_coords_set(&q, 755 eina_quad_coords_set(&q,
696 0.0, 0.0, 756 0.0, 0.0,
@@ -700,17 +760,24 @@ START_TEST(eina_matrix3_map_transform)
700 ret = eina_matrix3_square_quad_map(&m, &q); 760 ret = eina_matrix3_square_quad_map(&m, &q);
701 fail_if(ret != EINA_TRUE); 761 fail_if(ret != EINA_TRUE);
702 762
703 fail_if(m.xx != 3 || m.xy != 0 || m.xz != 0 || 763 fail_if(MATRIX3_CMP(m.xx, m.xy, m.xz,
704 m.yx != 0 || m.yy != 3 || m.yz != 0 || 764 m.yx, m.yy, m.yz,
705 m.zx != 0 || m.zy != 0 || m.zz != 1); 765 m.zx, m.zy, m.zz,
766 3, 0, 0,
767 0, 3, 0,
768 0, 0, 1));
706 769
707 ret = eina_matrix3_quad_square_map(&m, &q); 770 ret = eina_matrix3_quad_square_map(&m, &q);
708 fail_if(ret != EINA_TRUE); 771 fail_if(ret != EINA_TRUE);
709 772
710 fail_if(q.x0 != 0 || q.y0 != 0 || 773 fail_if(!EINA_DBL_CMP(q.x0, 0) ||
711 q.x1 != 3 || q.y1 != 0 || 774 !EINA_DBL_CMP(q.y0, 0) ||
712 q.x2 != 3 || q.y2 != 3 || 775 !EINA_DBL_CMP(q.x1, 3) ||
713 q.x3 != 0 || q.y3 != 3); 776 !EINA_DBL_CMP(q.y1, 0) ||
777 !EINA_DBL_CMP(q.x2, 3) ||
778 !EINA_DBL_CMP(q.y2, 3) ||
779 !EINA_DBL_CMP(q.x3, 0) ||
780 !EINA_DBL_CMP(q.y3, 3));
714 781
715 eina_shutdown(); 782 eina_shutdown();
716} 783}