diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/eina/src/tests/eina_test_rectangle.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/eina/src/tests/eina_test_rectangle.c')
-rw-r--r-- | libraries/eina/src/tests/eina_test_rectangle.c | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/libraries/eina/src/tests/eina_test_rectangle.c b/libraries/eina/src/tests/eina_test_rectangle.c new file mode 100644 index 0000000..581ab76 --- /dev/null +++ b/libraries/eina/src/tests/eina_test_rectangle.c | |||
@@ -0,0 +1,115 @@ | |||
1 | /* EINA - EFL data type library | ||
2 | * Copyright (C) 2007-2008 Cedric BAIL, Carsten Haitzler | ||
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 <stdio.h> | ||
24 | |||
25 | #include "eina_suite.h" | ||
26 | #include "Eina.h" | ||
27 | |||
28 | START_TEST(eina_rectangle_pool) | ||
29 | { | ||
30 | Eina_Rectangle_Pool *pool; | ||
31 | Eina_Rectangle *rects[8][8]; | ||
32 | int x; | ||
33 | int y; | ||
34 | int w; | ||
35 | int h; | ||
36 | |||
37 | fail_if(!eina_init()); | ||
38 | |||
39 | pool = eina_rectangle_pool_new(256, 256); | ||
40 | fail_if(pool == NULL); | ||
41 | |||
42 | eina_rectangle_pool_data_set(pool, rects); | ||
43 | fail_if(eina_rectangle_pool_data_get(pool) != rects); | ||
44 | |||
45 | fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL); | ||
46 | |||
47 | for (x = 0; x < 8; x++) | ||
48 | for (y = 0; y < 8; y++) | ||
49 | { | ||
50 | rects[x][y] = eina_rectangle_pool_request(pool, 32, 32); | ||
51 | fail_if(rects[x][y] == NULL); | ||
52 | } | ||
53 | |||
54 | fail_if(eina_rectangle_pool_count(pool) != 64); | ||
55 | |||
56 | fail_if(eina_rectangle_pool_get(rects[0][0]) != pool); | ||
57 | |||
58 | fail_if(eina_rectangle_pool_geometry_get(pool, &w, &h) != EINA_TRUE); | ||
59 | fail_if(w != 256 || h != 256); | ||
60 | |||
61 | fail_if(eina_rectangle_pool_request(pool, 32, 32) != NULL); | ||
62 | fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL); | ||
63 | |||
64 | for (x = 0; x < 8; x++) | ||
65 | eina_rectangle_pool_release(rects[0][x]); | ||
66 | |||
67 | fail_if(eina_rectangle_pool_request(pool, 16, 16) == NULL); | ||
68 | |||
69 | eina_rectangle_pool_free(pool); | ||
70 | |||
71 | eina_shutdown(); | ||
72 | } | ||
73 | END_TEST | ||
74 | |||
75 | START_TEST(eina_rectangle_intersect) | ||
76 | { | ||
77 | Eina_Rectangle r1, r2, r3, r4, rd; | ||
78 | |||
79 | fail_if(!eina_init()); | ||
80 | |||
81 | EINA_RECTANGLE_SET(&r1, 10, 10, 50, 50); | ||
82 | EINA_RECTANGLE_SET(&r2, 20, 20, 20, 20); | ||
83 | EINA_RECTANGLE_SET(&r3, 0, 0, 10, 10); | ||
84 | EINA_RECTANGLE_SET(&r4, 30, 30, 50, 50); | ||
85 | |||
86 | rd = r1; | ||
87 | |||
88 | fail_if(eina_rectangle_intersection(&rd, &r3)); | ||
89 | fail_if(!eina_rectangle_intersection(&rd, &r2)); | ||
90 | |||
91 | fail_if(rd.x != r2.x | ||
92 | || rd.y != r2.y | ||
93 | || rd.w != r2.w | ||
94 | || rd.h != r2.h); | ||
95 | |||
96 | rd = r1; | ||
97 | |||
98 | fail_if(!eina_rectangle_intersection(&rd, &r4)); | ||
99 | |||
100 | fail_if(rd.x != 30 | ||
101 | || rd.y != 30 | ||
102 | || rd.w != 30 | ||
103 | || rd.h != 30); | ||
104 | |||
105 | eina_shutdown(); | ||
106 | } | ||
107 | END_TEST | ||
108 | |||
109 | void | ||
110 | eina_test_rectangle(TCase *tc) | ||
111 | { | ||
112 | tcase_add_test(tc, eina_rectangle_pool); | ||
113 | tcase_add_test(tc, eina_rectangle_intersect); | ||
114 | } | ||
115 | |||