summaryrefslogtreecommitdiff
path: root/test/trap-clip.c
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2011-03-16 16:48:18 +0100
committerAndrea Canciani <ranma42@gmail.com>2011-03-17 17:45:57 +0100
commit75fea162d985bea622afa59771fb2d07f5241d1b (patch)
tree5876692cd2ba574481210fae292eaf7f06005028 /test/trap-clip.c
parent4ef32a36ba1e457e8dd6244a6483866d33477aac (diff)
test: Cleanup macros
The ARRAY_LENGTH macro is used by many tests, although sometimes it is named ARRAY_SIZE. Define it just once in cairo-test.h and reuse it. In a similar way, MAX() and MIN() are currently defined in some specific tests, while they could be reused.
Diffstat (limited to 'test/trap-clip.c')
-rw-r--r--test/trap-clip.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/test/trap-clip.c b/test/trap-clip.c
index 0999d9714..acfcafcb7 100644
--- a/test/trap-clip.c
+++ b/test/trap-clip.c
@@ -167,9 +167,8 @@ static void (* const clip_funcs[])(cairo_t *cr, int x, int y) = {
clip_circle,
};
-#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
-#define IMAGE_WIDTH (ARRAY_SIZE (pattern_funcs) * (WIDTH + PAD) + PAD)
-#define IMAGE_HEIGHT (ARRAY_SIZE (draw_funcs) * ARRAY_SIZE (clip_funcs) * (HEIGHT + PAD) + PAD)
+#define IMAGE_WIDTH (ARRAY_LENGTH (pattern_funcs) * (WIDTH + PAD) + PAD)
+#define IMAGE_HEIGHT (ARRAY_LENGTH (draw_funcs) * ARRAY_LENGTH (clip_funcs) * (HEIGHT + PAD) + PAD)
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
@@ -177,11 +176,11 @@ draw (cairo_t *cr, int width, int height)
const cairo_test_context_t *ctx = cairo_test_get_context (cr);
size_t i, j, k, x, y;
- for (k = 0; k < ARRAY_SIZE (clip_funcs); k++) {
- for (j = 0; j < ARRAY_SIZE (draw_funcs); j++) {
- for (i = 0; i < ARRAY_SIZE (pattern_funcs); i++) {
+ for (k = 0; k < ARRAY_LENGTH (clip_funcs); k++) {
+ for (j = 0; j < ARRAY_LENGTH (draw_funcs); j++) {
+ for (i = 0; i < ARRAY_LENGTH (pattern_funcs); i++) {
x = i * (WIDTH + PAD) + PAD;
- y = (ARRAY_SIZE (draw_funcs) * k + j) * (HEIGHT + PAD) + PAD;
+ y = (ARRAY_LENGTH (draw_funcs) * k + j) * (HEIGHT + PAD) + PAD;
cairo_save (cr);