This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via d0453af494e305191b9d85f6f35fbc06b828d61d (commit) from a74fce450b62265d5dc4b80f43a89bfeb570e271 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/d0453af494e305191b9d85f6f35fbc06b828d...
commit d0453af494e305191b9d85f6f35fbc06b828d61d Author: Cyril Hrubis metan@ucw.cz Date: Wed Oct 31 18:13:50 2012 +0100
tests: gfx: Basic tests for a circle.
diff --git a/tests/gfx/Circle.c b/tests/gfx/Circle.c new file mode 100644 index 0000000..0482e99 --- /dev/null +++ b/tests/gfx/Circle.c @@ -0,0 +1,216 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <string.h> +#include <errno.h> +#include <sys/stat.h> + +#include <core/GP_Context.h> +#include <gfx/GP_Circle.h> + +#include "tst_test.h" + +static const char circle_r_0_11x11[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 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circle_r_3_11x11[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char circle_r_5_half_11x11[] = { + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static void dump_buffer(const char *pattern, int x, int y) +{ + int i, j; + + for (i = 0; i < y; i++) { + for (j = 0; j < x; j++) + printf("%2x ", pattern[j + i * y]); + printf("n"); + } +} + +static void dump_buffers(const char *pattern, const GP_Context *c) +{ + printf("Expected patternn"); + dump_buffer(pattern, c->w, c->h); + printf("Rendered patternn"); + dump_buffer((char*)c->pixels, c->w, c->h); +} + +static int compare_buffers(const char *pattern, const GP_Context *c) +{ + GP_Size x, y; + int err = 0; + + for (x = 0; x < c->w; x++) { + for (y = 0; y < c->h; y++) { + if (pattern[x + y * c->h] != + ((char*)c->pixels)[x + y * c->h]) { + err++; + } + } + } + + if (err) + dump_buffers(pattern, c); + + return err; +} + +static int test_circle(const char *pattern, GP_Size w, GP_Size h, + GP_Coord x, GP_Coord y, const int r) +{ + GP_Context *c; + int err; + + c = GP_ContextAlloc(w, h, GP_PIXEL_G8); + + if (c == NULL) { + tst_report(0, "Failed to allocate context"); + return TST_UNTESTED; + } + + /* zero the pixels buffer */ + memset(c->pixels, 0, c->w * c->h); + + GP_Circle(c, x, y, r, 1); + + err = compare_buffers(pattern, c); + + if (err) { + tst_report(0, "Patterns are different"); + return TST_FAILED; + } + + return TST_SUCCESS; +} + +static int test_circle_r_0(void) +{ + return test_circle(circle_r_0_11x11, 11, 11, 5, 5, 0); +} + +static int test_circle_r_1(void) +{ + return test_circle(circle_r_1_11x11, 11, 11, 5, 5, 1); +} + +static int test_circle_r_2(void) +{ + return test_circle(circle_r_2_11x11, 11, 11, 5, 5, 2); +} + +static int test_circle_r_3(void) +{ + return test_circle(circle_r_3_11x11, 11, 11, 5, 5, 3); +} + +static int test_circle_r__1(void) +{ + return test_circle(circle_r_1_11x11, 11, 11, 5, 5, -1); +} + +static int test_circle_r__2(void) +{ + return test_circle(circle_r_2_11x11, 11, 11, 5, 5, -2); +} + +static int test_circle_r_5_half(void) +{ + return test_circle(circle_r_5_half_11x11, 11, 11, 0, 5, 5); +} + +const struct tst_suite tst_suite = { + .suite_name = "GFX Circle Testsuite", + .tests = { + {.name = "Circle r=0", .tst_fn = test_circle_r_0}, + {.name = "Circle r=1", .tst_fn = test_circle_r_1}, + {.name = "Circle r=2", .tst_fn = test_circle_r_2}, + {.name = "Circle r=3", .tst_fn = test_circle_r_3}, + {.name = "Circle r=5 half", .tst_fn = test_circle_r_5_half}, + {.name = "Circle r=-1", .tst_fn = test_circle_r__1}, + {.name = "Circle r=-2", .tst_fn = test_circle_r__2}, + {.name = NULL} + } +}; diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile index 71e9223..15c1984 100644 --- a/tests/gfx/Makefile +++ b/tests/gfx/Makefile @@ -3,7 +3,7 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-APPS=gfx_benchmark +APPS=gfx_benchmark Circle
include ../tests.mk
diff --git a/tests/gfx/runtest.sh b/tests/gfx/runtest.sh index 71a411b..6761955 100755 --- a/tests/gfx/runtest.sh +++ b/tests/gfx/runtest.sh @@ -9,4 +9,5 @@ # export LIBC_FATAL_STDERR_=1
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@" +#LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@" +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Circle "$@"
-----------------------------------------------------------------------
Summary of changes: tests/gfx/Circle.c | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/gfx/Makefile | 2 +- tests/gfx/runtest.sh | 3 +- 3 files changed, 219 insertions(+), 2 deletions(-) create mode 100644 tests/gfx/Circle.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.