summaryrefslogtreecommitdiff
path: root/src/tests/eina/eina_test_quad.c
blob: 60cb6537c41626dbb4162387345d381196b5a2c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdio.h>
#include <assert.h>

#include <Eina.h>

#include "eina_suite.h"

START_TEST(eina_quad_simple)
{
   Eina_Rectangle r1;
   Eina_Quad r2;
   double x0, x1, x2, x3;
   double y0, y1, y2, y3;

   fail_if(!eina_init());

   eina_quad_coords_set(&r2,
                        0.0, 5.0,
                        5.0, 0.0,
                       10.0, 5.0,
                        5.0, 10.0);

   eina_quad_coords_get(&r2,
                        &x0, &y0,
                        &x1, &y1,
                        &x2, &y2,
                        &x3, &y3);
   fail_if (!EINA_FLT_CMP(r2.x0, 0.0) ||
            !EINA_FLT_CMP(r2.y0, 5.0) ||
            !EINA_FLT_CMP(r2.x1, 5.0) ||
            !EINA_FLT_CMP(r2.y1, 0.0) ||
            !EINA_FLT_CMP(r2.x2, 10.0) ||
            !EINA_FLT_CMP(r2.y2, 5.0) ||
            !EINA_FLT_CMP(r2.x3, 5.0) ||
            !EINA_FLT_CMP(r2.y3, 10.0));

   eina_quad_rectangle_to(&r2, &r1);
   fail_if (!EINA_FLT_CMP(r1.x, 0) ||
            !EINA_FLT_CMP(r1.y, 0) ||
            !EINA_FLT_CMP(r1.w, 10) ||
            !EINA_FLT_CMP(r1.h, 10));

   eina_quad_coords_set(&r2,
                        0.0, 0.0,
                        0.0, 0.0,
                        0.0, 0.0,
                        0.0, 0.0);
   eina_quad_rectangle_to(&r2, &r1);
   fail_if (!EINA_FLT_CMP(r1.x, 0) ||
            !EINA_FLT_CMP(r1.y, 0) ||
            !EINA_FLT_CMP(r1.w, 0) ||
            !EINA_FLT_CMP(r1.h, 0));

   EINA_RECTANGLE_SET(&r1, 5, 10, 20, 30);
   eina_quad_rectangle_from(&r2, &r1);
   fail_if (!EINA_FLT_CMP(r2.x0, 5.0) ||
            !EINA_FLT_CMP(r2.y0, 10.0) ||
            !EINA_FLT_CMP(r2.x1, 25.0) ||
            !EINA_FLT_CMP(r2.y1, 10.0) ||
            !EINA_FLT_CMP(r2.x2, 25.0) ||
            !EINA_FLT_CMP(r2.y2, 40.0) ||
            !EINA_FLT_CMP(r2.x3, 5.0) ||
            !EINA_FLT_CMP(r2.y3, 40.0));

   eina_shutdown();
}
END_TEST

void
eina_test_quad(TCase *tc)
{
   tcase_add_test(tc, eina_quad_simple);
}