stefan pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=5e0c1b7cc6bc85545f0a96d7fd302c5d071d9c78

commit 5e0c1b7cc6bc85545f0a96d7fd302c5d071d9c78
Author: se.osadchy <se.osad...@samsung.com>
Date:   Wed Jan 13 15:43:23 2016 +0100

    eina: add all test cases for eina_vector2.
    
    Summary: All tests passes for eina_vector2 functions.
    
    Reviewers: cedric, stefan_schmidt
    
    Subscribers: jpeg
    
    Differential Revision: https://phab.enlightenment.org/D3565
---
 src/tests/eina/eina_test_vector.c | 70 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 65 insertions(+), 5 deletions(-)

diff --git a/src/tests/eina/eina_test_vector.c 
b/src/tests/eina/eina_test_vector.c
index a45d1b5..57bc4bb 100644
--- a/src/tests/eina/eina_test_vector.c
+++ b/src/tests/eina/eina_test_vector.c
@@ -27,16 +27,76 @@
 #include "eina_suite.h"
 #include "Eina.h"
 
-START_TEST(eina_test_vector_operations)
+START_TEST(eina_test_vector2_operations)
 {
-   Eina_Vector2 out;;
+   Eina_Vector2 v1;
+   Eina_Vector2 v2;
+   Eina_Vector2 v3;
+   Eina_Matrix2 m2;
+   Eina_Matrix3 m3;
    double x = 1;
    double y = 2;
+   double res = 0;
+   const double arr[] = {5, 5};
 
    eina_init();
 
-   eina_vector2_set(&out, x, y);
-   fail_if((out.x != 1) || (out.y != 2));
+   eina_vector2_set(&v1, x, y);
+   fail_if((v1.x != 1) || (v1.y != 2));
+
+   eina_vector2_array_set(&v2, &arr);
+   fail_if((v2.x != 5) || (v2.y != 5));
+
+   eina_vector2_copy(&v1, &v2);
+   fail_if((v1.x != 5) || (v1.y != 5));
+
+   eina_vector2_negate(&v1, &v2);
+   fail_if((v1.x != -5) || (v1.y != -5));
+
+   eina_vector2_set(&v1, x, y);
+   eina_vector2_add(&v3, &v1, &v2);
+   fail_if((v3.x != 6) || (v3.y != 7));
+
+   eina_vector2_subtract(&v3, &v2, &v1);
+   fail_if((v3.x != 4) || (v3.y != 3));
+
+   eina_vector2_scale(&v3, &v1, y);
+   fail_if((v3.x != 2) || (v3.y != 4));
+
+   res = eina_vector2_dot_product(&v1, &v2);
+   fail_if(res != 15);
+
+   res = eina_vector2_length_get(&v2);
+   fail_if((res - sqrt(50)) > DBL_EPSILON);
+
+   res = eina_vector2_length_square_get(&v2);
+   fail_if(res != 50);
+
+   res = eina_vector2_distance_get(&v2, &v1);
+   fail_if((res - sqrt(25)) > DBL_EPSILON);
+
+   res = eina_vector2_distance_square_get(&v2, &v1);
+   fail_if(res != 25);
+
+   eina_vector2_normalize(&v3, &v2);
+   fail_if((v3.x - v2.x / sqrt(50)) > DBL_EPSILON ||
+           (v3.y - v2.y / sqrt(50)) > DBL_EPSILON);
+
+   eina_matrix2_values_set(&m2,
+                          2, 2,
+                          2, 2);
+   eina_vector2_transform(&v3, &m2, &v1);
+   fail_if((v3.x != 6) || (v3.y != 6));
+
+   eina_matrix3_values_set(&m3,
+                          2, 2, 2,
+                          2, 2, 2,
+                          2, 2, 2);
+   eina_vector2_homogeneous_position_transform(&v3, &m3, &v1);
+   fail_if((v3.x != 1) || (v3.y != 1));
+
+   eina_vector2_homogeneous_direction_transform(&v3, &m3, &v1);
+   fail_if((v3.x != 6) || (v3.y != 6));
 
    eina_shutdown();
 }
@@ -45,5 +105,5 @@ END_TEST
 void
 eina_test_vector(TCase *tc)
 {
-   tcase_add_test(tc, eina_test_vector_operations);
+   tcase_add_test(tc, eina_test_vector2_operations);
 }

-- 


Reply via email to