summaryrefslogtreecommitdiff
path: root/src/tests/eina/eina_test_matrix.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-05-28 14:35:55 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-05-29 17:20:28 +0200
commit9a83100a4ac1b040bde8aa63c868be3ad806758a (patch)
treeadb0ca777db9ac4e5bb6a68f21b76d9f806e4946 /src/tests/eina/eina_test_matrix.c
parent5cdf202ee4c81afcd5a18749a09eab9724a76402 (diff)
eina: add the beginning of an Eina_Matrix4 API.
Diffstat (limited to '')
-rw-r--r--src/tests/eina/eina_test_matrix.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/tests/eina/eina_test_matrix.c b/src/tests/eina/eina_test_matrix.c
new file mode 100644
index 0000000000..046876d2c4
--- /dev/null
+++ b/src/tests/eina/eina_test_matrix.c
@@ -0,0 +1,100 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2015 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifdef HAVE_CONFIG_H
20# include "config.h"
21#endif
22
23#include <math.h>
24#include <stdio.h>
25
26#include "eina_suite.h"
27#include "Eina.h"
28
29START_TEST(eina_matrix4)
30{
31 Eina_Matrix4 m;
32 double xx, xy, xz, xw,
33 yx, yy, yz, yw,
34 zx, zy, zz, zw,
35 wx, wy, wz, ww;
36
37 eina_init();
38
39 eina_matrix4_values_set(&m,
40 1, 0, 0, 0,
41 0, 1, 0, 0,
42 0, 0, 1, 0,
43 0, 0, 0, 1);
44 fail_if(eina_matrix4_type_get(&m) != EINA_MATRIX_TYPE_IDENTITY);
45
46 eina_matrix4_values_get(&m,
47 &xx, &xy, &xz, &xw,
48 &yx, &yy, &yz, &yw,
49 &zx, &zy, &zz, &zw,
50 &wx, &wy, &wz, &ww);
51
52 fail_if(xx != yy ||
53 yy != zz ||
54 zz != ww ||
55 ww != 1);
56 fail_if(xy != xz ||
57 xz != xw ||
58 xw != yx ||
59 yx != yz ||
60 yz != yw ||
61 yw != zx ||
62 zx != zy ||
63 zy != zw ||
64 zw != wx ||
65 wx != wy ||
66 wy != wz ||
67 wz != 0);
68
69 eina_shutdown();
70}
71END_TEST
72
73START_TEST(eina_matrix4_2_3)
74{
75 Eina_Matrix4 m4, m4b;
76 Eina_Matrix3 m3;
77
78 eina_init();
79
80 eina_matrix4_values_set(&m4,
81 1, 3, 2, 0,
82 3, 1, 4, 0,
83 2, 4, 1, 0,
84 0, 0, 0, 1);
85
86 eina_matrix4_matrix3_to(&m3, &m4);
87 eina_matrix3_matrix4_to(&m4b, &m3);
88
89 fail_if(memcmp(&m4, &m4b, sizeof (Eina_Matrix4)) != 0);
90
91 eina_shutdown();
92}
93END_TEST
94
95void
96eina_test_matrix(TCase *tc)
97{
98 tcase_add_test(tc, eina_matrix4);
99 tcase_add_test(tc, eina_matrix4_2_3);
100}