gegl r3025 - trunk/tests
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r3025 - trunk/tests
- Date: Sat, 11 Apr 2009 12:57:41 +0000 (UTC)
Author: martinn
Date: Sat Apr 11 12:57:41 2009
New Revision: 3025
URL: http://svn.gnome.org/viewvc/gegl?rev=3025&view=rev
Log:
Add a test case for the gegl:color op
Add a test case for the gegl:color op that tests processing at an
extreme coordinates, at the edges of the representation of an
infinite plane.
Added:
trunk/tests/test-color-op.c
Modified:
trunk/tests/.gitignore
trunk/tests/Makefile.am
Modified: trunk/tests/.gitignore
==============================================================================
--- trunk/tests/.gitignore (original)
+++ trunk/tests/.gitignore Sat Apr 11 12:57:41 2009
@@ -4,5 +4,6 @@
/.libs
/Makefile
/Makefile.in
-/test-gegl-rectangle
+/test-gegl-rectangle*
/test-proxynop-processing*
+/test-color-op*
Modified: trunk/tests/Makefile.am
==============================================================================
--- trunk/tests/Makefile.am (original)
+++ trunk/tests/Makefile.am Sat Apr 11 12:57:41 2009
@@ -6,7 +6,8 @@
# The tests
TESTS = \
- test-proxynop-processing \
+ test-proxynop-processing \
+ test-color-op \
test-gegl-rectangle
noinst_PROGRAMS = $(TESTS)
@@ -27,4 +28,3 @@
# Common libs
LIBS = $(top_builddir)/gegl/libgegl-$(GEGL_API_VERSION).la \
$(DEP_LIBS) $(BABL_LIBS)
-
Added: trunk/tests/test-color-op.c
==============================================================================
--- (empty file)
+++ trunk/tests/test-color-op.c Sat Apr 11 12:57:41 2009
@@ -0,0 +1,88 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (C) 2009 Martin Nordholts
+ */
+
+#include <string.h>
+
+#include "gegl.h"
+
+#define RED 0
+#define GREEN 1
+#define BLUE 2
+
+#define SUCCESS 0
+#define FAILURE -1
+
+#define RUNS 3
+
+
+int main(int argc, char *argv[])
+{
+ int result = SUCCESS;
+ guchar result_buffer[3] = { 0, 0, 0 };
+ int i = 0;
+ GeglNode *color = NULL;
+ GeglColor *colors[RUNS] = { 0, 0, 0 };
+ guchar expected_results[RUNS][3] = { { 255, 0, 0 },
+ { 0, 255, 0 },
+ { 0, 0, 255 } };
+ GeglRectangle rois[RUNS] = { { 0, 0, 1, 1 },
+ { G_MININT / 2, G_MININT / 2, 1, 1 },
+ { G_MAXINT / 2 - 1, G_MAXINT / 2 - 1, 1, 1 } };
+
+ /* Init */
+ gegl_init (&argc, &argv);
+ colors[0] = gegl_color_new ("rgb(1.0, 0.0, 0.0)");
+ colors[1] = gegl_color_new ("rgb(0.0, 1.0, 0.0)");
+ colors[2] = gegl_color_new ("rgb(0.0, 0.0, 1.0)");
+
+ /* Construct graph */
+ color = gegl_node_new_child (NULL,
+ "operation", "gegl:color",
+ NULL);
+
+ /* Run tests */
+ for (i = 0; i < RUNS; i++)
+ {
+ gegl_node_set (color,
+ "value", colors[i],
+ NULL);
+ memset (result_buffer, 0, sizeof (result_buffer));
+ gegl_node_blit (color,
+ 1.0,
+ &rois[i],
+ babl_format ("RGB u8"),
+ result_buffer,
+ GEGL_AUTO_ROWSTRIDE,
+ GEGL_BLIT_DEFAULT);
+ if (!(result_buffer[RED] == expected_results[i][RED] &&
+ result_buffer[GREEN] == expected_results[i][GREEN] &&
+ result_buffer[BLUE] == expected_results[i][BLUE]))
+ {
+ result = FAILURE;
+ g_printerr ("Processing #%d of gegl:color failed", i + 1);
+ break;
+ }
+ }
+
+ /* Cleanup */
+ g_object_unref (color);
+ for (i = 0; i < RUNS; i++)
+ g_object_unref (colors[i]);
+ gegl_exit ();
+
+ return result;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]