1 /* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Cedric BAIL, Carsten Haitzler
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.
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.
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/>.
25 #include "eina_suite.h"
28 START_TEST(eina_rectangle_pool)
30 Eina_Rectangle_Pool *pool;
31 Eina_Rectangle *rects[8][8];
37 fail_if(!eina_init());
39 pool = eina_rectangle_pool_new(256, 256);
40 fail_if(pool == NULL);
42 eina_rectangle_pool_data_set(pool, rects);
43 fail_if(eina_rectangle_pool_data_get(pool) != rects);
45 fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
47 for (x = 0; x < 8; x++)
48 for (y = 0; y < 8; y++)
50 rects[x][y] = eina_rectangle_pool_request(pool, 32, 32);
51 fail_if(rects[x][y] == NULL);
54 fail_if(eina_rectangle_pool_count(pool) != 64);
56 fail_if(eina_rectangle_pool_get(rects[0][0]) != pool);
58 fail_if(eina_rectangle_pool_geometry_get(pool, &w, &h) != EINA_TRUE);
59 fail_if(w != 256 || h != 256);
61 fail_if(eina_rectangle_pool_request(pool, 32, 32) != NULL);
62 fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
64 for (x = 0; x < 8; x++)
65 eina_rectangle_pool_release(rects[0][x]);
67 fail_if(eina_rectangle_pool_request(pool, 16, 16) == NULL);
69 eina_rectangle_pool_free(pool);
75 START_TEST(eina_rectangle_intersect)
77 Eina_Rectangle r1, r2, r3, r4, rd;
79 fail_if(!eina_init());
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);
88 fail_if(eina_rectangle_intersection(&rd, &r3));
89 fail_if(!eina_rectangle_intersection(&rd, &r2));
98 fail_if(!eina_rectangle_intersection(&rd, &r4));
110 eina_test_rectangle(TCase *tc)
112 tcase_add_test(tc, eina_rectangle_pool);
113 tcase_add_test(tc, eina_rectangle_intersect);