cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=6090073dee6b8a283a2d404efde8ec9205e485d9

commit 6090073dee6b8a283a2d404efde8ec9205e485d9
Author: Vivek Ellur <vivek.el...@samsung.com>
Date:   Fri Oct 30 03:59:21 2015 +0100

    eina_quaternion: add test cases for quaternion rotation functions
    
    Summary:
    Added test cases for eina_quaternion_f16p16_rotate and
    eina_quaternion_f16p16_rotation_matrix3_get functions
    
    Signed-off-by: Vivek Ellur <vivek.el...@samsung.com>
    
    Reviewers: cedric
    
    Subscribers: cedric
    
    Differential Revision: https://phab.enlightenment.org/D3247
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/tests/eina/eina_test_quaternion.c | 40 +++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/src/tests/eina/eina_test_quaternion.c 
b/src/tests/eina/eina_test_quaternion.c
index 058ca3c..e1b876b 100644
--- a/src/tests/eina/eina_test_quaternion.c
+++ b/src/tests/eina/eina_test_quaternion.c
@@ -57,6 +57,22 @@ eina_matrix3_cmp(const Eina_Matrix3 *a, const Eina_Matrix3 
*b)
 }
 
 static inline Eina_Bool
+eina_matrix3_f16p16_cmp(const Eina_Matrix3_F16p16 *a, const 
Eina_Matrix3_F16p16 *b)
+{
+   if ((a->xx == b->xx) &&
+       (a->xy == b->xy) &&
+       (a->xz == b->xz) &&
+       (a->yx == b->yx) &&
+       (a->yy == b->yy) &&
+       (a->yz == b->yz) &&
+       (a->zx == b->zx) &&
+       (a->zy == b->zy) &&
+       (a->zz == b->zz))
+     return EINA_TRUE;
+   return EINA_FALSE;
+}
+
+static inline Eina_Bool
 eina_point_3d_cmp(const Eina_Point_3D *a, const Eina_Point_3D *b)
 {
    if (FLOAT_CMP(a->x, b->x) &&
@@ -414,6 +430,29 @@ START_TEST(eina_test_quaternion_lerp)
 }
 END_TEST
 
+START_TEST(eina_test_quaternion_f16p16_rotate_matrix)
+{
+   Eina_Quaternion_F16p16 q = {65536, 65536, 65536, 0};
+   Eina_Point_3D_F16p16 r = { 65536, 65536, 65536 };
+   Eina_Point_3D_F16p16 c = { 0, 0, 0 }, res = {65536, 65536, 65536};
+   Eina_Matrix3_F16p16 m, mres = {-262144, 131072, 131072,
+                                  131072, -262144, 131072,
+                                  131072, 131072, -262144 };
+
+   eina_init();
+
+   eina_quaternion_f16p16_rotate(&r, &c, &q);
+   fail_if(r.x != res.x ||
+           r.y != res.y ||
+           r.z != res.z);
+
+   eina_quaternion_f16p16_rotation_matrix3_get(&m, &q);
+   fail_if(!eina_matrix3_f16p16_cmp(&m, &mres));
+
+   eina_shutdown();
+}
+END_TEST
+
 void
 eina_test_quaternion(TCase *tc)
 {
@@ -431,4 +470,5 @@ eina_test_quaternion(TCase *tc)
    tcase_add_test(tc, eina_test_matrix_recompose);
    tcase_add_test(tc, eina_test_quaternion_f16p16_lerp);
    tcase_add_test(tc, eina_test_quaternion_lerp);
+   tcase_add_test(tc, eina_test_quaternion_f16p16_rotate_matrix);
 }

-- 


Reply via email to