[gegl] Add tests for gegl_node_set/get



commit db8745d64d521b4fe543b0c01db515c9e0e5a9b3
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Thu Jun 6 04:30:02 2013 -0700

    Add tests for gegl_node_set/get

 tests/simple/.gitignore             |   21 ++--
 tests/simple/Makefile.am            |    1 +
 tests/simple/test-node-properties.c |  175 +++++++++++++++++++++++++++++++++++
 3 files changed, 187 insertions(+), 10 deletions(-)
---
diff --git a/tests/simple/.gitignore b/tests/simple/.gitignore
index 900bef1..18c49de 100644
--- a/tests/simple/.gitignore
+++ b/tests/simple/.gitignore
@@ -5,14 +5,15 @@
 /.libs
 /Makefile
 /Makefile.in
-/test-change-processor-rect*
-/test-color-op*
+/test-change-processor-rect
+/test-color-op
 /test-exp-combine.sh
-/test-gegl-rectangle*
-/test-gegl-tile*
-/test-misc*
-/test-path*
-/test-proxynop-processing*
-/test-buffer-cast*
-/test-buffer-extract*
-/test-buffer-changes*
+/test-gegl-rectangle
+/test-gegl-tile
+/test-misc
+/test-node-properties
+/test-path
+/test-proxynop-processing
+/test-buffer-cast
+/test-buffer-extract
+/test-buffer-changes
diff --git a/tests/simple/Makefile.am b/tests/simple/Makefile.am
index 264a068..0763cc6 100644
--- a/tests/simple/Makefile.am
+++ b/tests/simple/Makefile.am
@@ -11,6 +11,7 @@ noinst_PROGRAMS = \
        test-color-op                   \
        test-gegl-rectangle             \
        test-misc                       \
+       test-node-properties            \
        test-path                       \
        test-buffer-extract \
        test-buffer-cast  \
diff --git a/tests/simple/test-node-properties.c b/tests/simple/test-node-properties.c
new file mode 100644
index 0000000..fd27413
--- /dev/null
+++ b/tests/simple/test-node-properties.c
@@ -0,0 +1,175 @@
+/*
+ * 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) 2013 Daniel Sabo
+ */
+
+#include "config.h"
+#include <string.h>
+#include <stdio.h>
+
+#include "gegl.h"
+
+#define SUCCESS  0
+#define FAILURE -1
+
+int main(int argc, char *argv[])
+{
+  int           result = SUCCESS;
+  GeglNode     *graph  = NULL;
+  GeglNode     *node   = NULL;
+  GeglColor    *color  = gegl_color_new ("rgb(0.0, 1.0, 0.0)");
+  double        x      = -5;
+  double        y      = -5;
+  char         *name   = NULL;
+  gboolean      cache  = TRUE;
+
+  /* Init */
+  gegl_init (&argc, &argv);
+  
+  graph = gegl_node_new ();
+  node  = gegl_node_new_child (graph,
+                               "operation", "gegl:color",
+                               "value",     color,
+                               NULL);
+
+  gegl_node_get (node, "operation", &name, NULL);
+  
+  if (!(!strcmp (name, "gegl:color")))
+    {
+      result = FAILURE;
+      printf ("operation: %s\n", name); 
+      goto abort;
+    }
+
+  gegl_node_set (node,
+                 "operation", "gegl:translate",
+                 "x", 50.0,
+                 "y", 100.0,
+                 NULL);
+  
+  gegl_node_get (node,
+                 "operation", &name,
+                 "x", &x,
+                 "y", &y,
+                 NULL);
+
+  if (!(!strcmp (name, "gegl:translate") &&
+        (int)x == 50 && (int)y == 100))
+    {
+      result = FAILURE;
+      printf ("operation: %s\n", name); 
+      printf ("x, y: %f, %f\n", x, y);
+      goto abort;
+    }
+
+  gegl_node_set (node,
+                 "x", 5.0,
+                 "y", 10.0,
+                 NULL);
+  
+  gegl_node_get (node,
+                 "y", &y,
+                 "operation", &name,
+                 "x", &x,
+                 NULL);
+  
+  if (!(!strcmp (name, "gegl:translate") &&
+        (int)x == 5 && (int)y == 10))
+    {
+      result = FAILURE;
+      printf ("operation: %s\n", name); 
+      printf ("x, y: %f, %f\n", x, y);
+      goto abort;
+    }
+  
+  gegl_node_set (node,
+                 "operation", "gegl:nop",
+                 NULL);
+
+  gegl_node_get (node, "operation", &name, NULL);
+  
+  if (!(!strcmp (name, "gegl:nop")))
+    {
+      result = FAILURE;
+      printf ("operation: %s\n", name); 
+      goto abort;
+    }
+
+  gegl_node_set (node,
+                 "operation", "gegl:translate",
+                 NULL);
+  
+  gegl_node_get (node,
+                 "operation", &name,
+                 "x", &x,
+                 "y", &y,
+                 NULL);
+
+  if (!(!strcmp (name, "gegl:translate") &&
+        (int)x == 0 && (int)y == 0))
+    {
+      result = FAILURE;
+      printf ("operation: %s\n", name); 
+      printf ("x, y: %f, %f\n", x, y);
+      goto abort;
+    }
+  
+  gegl_node_set (node,
+                 "operation", "gegl:translate",
+                 "name", "Brian",
+                 "dont-cache", FALSE,
+                 NULL);
+  
+  gegl_node_get (node,
+                 "name", &name,
+                 "dont-cache", &cache,
+                 NULL);
+
+  if (!(!strcmp (name, "Brian") &&
+        cache == FALSE))
+    {
+      result = FAILURE;
+      printf ("name:  %s\n", name); 
+      printf ("cache: %d\n", cache); 
+      goto abort;
+    }
+  
+  gegl_node_set (node,
+                 "dont-cache", TRUE,
+                 "name", "Steve",
+                 NULL);
+  
+  gegl_node_get (node,
+                 "name", &name,
+                 "dont-cache", &cache,
+                 NULL);
+
+  if (!(!strcmp (name, "Steve") &&
+        cache == TRUE))
+    {
+      result = FAILURE;
+      printf ("name: %s\n", name); 
+      printf ("cache: %d\n", cache); 
+      goto abort;
+    }
+
+abort:
+  /* Cleanup */
+  g_object_unref (graph);
+  g_object_unref (color);
+  gegl_exit ();
+
+  return result;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]