test: Use ARRAY_LENGTH() macro

Some tests hand-code ARRAY_LENGTH(). It is now provided by
cairo-test.h, so it can be reused.
This commit is contained in:
Andrea Canciani 2011-03-16 16:55:50 +01:00
parent 75fea162d9
commit 0ce4face45
13 changed files with 15 additions and 15 deletions

View file

@ -40,7 +40,7 @@ draw (cairo_t *cr, int width, int height)
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_paint (cr);
for (i = 0; i < sizeof (xy) / sizeof (xy[0]); i++)
for (i = 0; i < ARRAY_LENGTH (xy); i++)
cairo_line_to (cr, xy[i].x, xy[i].y);
cairo_set_source_rgb (cr, 1, 0, 0);

View file

@ -45,7 +45,7 @@ paint_curve (cairo_t *cr)
cairo_set_line_width (cr, 2);
cairo_move_to (cr, points[0].x, points[0].y);
for (i = 1; i < sizeof (points) / sizeof (points[0]) - 2; i += 3) {
for (i = 1; i < ARRAY_LENGTH (points) - 2; i += 3) {
cairo_curve_to (cr,
points[i].x, points[i].y,
points[i + 1].x, points[i + 1].y,

View file

@ -129,7 +129,7 @@ draw (cairo_t *cr, void (*shapes)(cairo_t *))
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
for (i = 0; i < sizeof (clip_funcs) / sizeof (clip_funcs[0]); i++) {
for (i = 0; i < ARRAY_LENGTH (clip_funcs); i++) {
cairo_translate (cr, translations[i][0], translations[i][1]);
cairo_save (cr);

View file

@ -64,7 +64,7 @@ draw (cairo_t *cr, int width, int height)
for (i=0; i<2; i++) {
cairo_save (cr);
cairo_set_line_width (cr, LINE_WIDTH);
cairo_set_dash (cr, dash, sizeof(dash)/sizeof(dash[0]), dash_offset);
cairo_set_dash (cr, dash, ARRAY_LENGTH (dash), dash_offset);
cairo_translate (cr, PAD, PAD);

View file

@ -82,7 +82,7 @@ draw (cairo_t *cr, int width, int height)
cairo_translate (cr, PAD, PAD);
cairo_set_dash (cr, dash, sizeof(dash)/sizeof(dash[0]), - 2 * LINE_WIDTH);
cairo_set_dash (cr, dash, ARRAY_LENGTH (dash), - 2 * LINE_WIDTH);
cairo_set_line_width (cr, LINE_WIDTH);
draw_three_shapes (cr);
@ -90,7 +90,7 @@ draw (cairo_t *cr, int width, int height)
cairo_save (cr);
{
cairo_set_dash (cr, dash, sizeof(dash)/sizeof(dash[0]), - 2 * LINE_WIDTH);
cairo_set_dash (cr, dash, ARRAY_LENGTH (dash), - 2 * LINE_WIDTH);
cairo_set_line_width (cr, LINE_WIDTH);
cairo_scale (cr, 1, 2);
draw_three_shapes (cr);
@ -102,7 +102,7 @@ draw (cairo_t *cr, int width, int height)
cairo_save (cr);
{
cairo_scale (cr, 1, 2);
cairo_set_dash (cr, dash, sizeof(dash)/sizeof(dash[0]), - 2 * LINE_WIDTH);
cairo_set_dash (cr, dash, ARRAY_LENGTH (dash), - 2 * LINE_WIDTH);
cairo_set_line_width (cr, LINE_WIDTH);
draw_three_shapes (cr);
}

View file

@ -346,7 +346,7 @@ preamble (cairo_test_context_t *ctx)
int n, num_ppi;
const char *path = _cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
num_ppi = sizeof (ppi) / sizeof (ppi[0]);
num_ppi = ARRAY_LENGTH (ppi);
#if GENERATE_REFERENCE
for (n = 0; n < num_ppi; n++) {

View file

@ -79,7 +79,7 @@ draw (cairo_t *cr, int width, int height)
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
for (k = 0; k < sizeof (transform) / sizeof (transform[0]); k++) {
for (k = 0; k < ARRAY_LENGTH (transform); k++) {
/* draw a "large" section from an image */
cairo_save (cr); {
cairo_set_matrix(cr, &ctx_transform[k]);

View file

@ -42,7 +42,7 @@ make_path (cairo_t *cr)
};
unsigned int i, j;
for (j = 0; j < sizeof (scales) / sizeof (scales[0]); j++) {
for (j = 0; j < ARRAY_LENGTH (scales); j++) {
cairo_save (cr);
/* include reflections to flip the orientation of the join */
cairo_scale (cr, scales[j].x, scales[j].y);

View file

@ -49,7 +49,7 @@ draw (cairo_t *cr, int width, int height)
/* completely invisible rectangle */
cairo_rectangle (cr, -5, -5, 70, 70);
cairo_set_dash (cr, dashes, sizeof (dashes) / sizeof (dashes[0]), 0.);
cairo_set_dash (cr, dashes, ARRAY_LENGTH (dashes), 0.);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);
cairo_set_source_rgb (cr, 0, 0, 0);

View file

@ -128,7 +128,7 @@ _render_image (cairo_t *cr,
cairo_set_font_size (cr, 5);
scaled_font = cairo_get_scaled_font (cr);
for (i = 0; i < sizeof (channel) / sizeof (channel[0]); i++) {
for (i = 0; i < ARRAY_LENGTH (channel); i++) {
cairo_push_group_with_content (cr, CAIRO_CONTENT_ALPHA);
for (n = 0; n < 256; n++) {
cairo_status_t status;

View file

@ -57,7 +57,7 @@ draw (cairo_t *cr, int width, int height)
cairo_test_status_t result = CAIRO_TEST_SUCCESS;
path.status = CAIRO_STATUS_SUCCESS;
path.num_data = sizeof (path_data) / sizeof (path_data[0]);
path.num_data = ARRAY_LENGTH (path_data);
path.data = path_data;
cairo_new_path (cr);

View file

@ -151,7 +151,7 @@ draw (cairo_t *cr, int width, int height)
}
if (!double_buf_equal (ctx, new_buf, expected_values,
sizeof(expected_values)/sizeof(double)) != 0)
ARRAY_LENGTH (expected_values)) != 0)
{
cairo_pattern_destroy (pat);
return CAIRO_TEST_FAILURE;

View file

@ -40,7 +40,7 @@ draw_symbol (cairo_t *cr)
cairo_stroke (cr);
cairo_save (cr);
cairo_set_dash (cr, dash, sizeof (dash) / sizeof (dash[0]), 0.);
cairo_set_dash (cr, dash, ARRAY_LENGTH (dash), 0.);
cairo_move_to (cr, 0, 0);
cairo_arc (cr, 0, 0, 12.5, 0, 3 * M_PI / 2);
cairo_close_path (cr);