[gegl/soc-2013-opecl-ops] introspection: add test cases for gegl_format()



commit 3d9e0d2ed79296c834d3c0310b29ce3b2db44dea
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Fri Sep 20 10:31:41 2013 -0700

    introspection: add test cases for gegl_format()

 tests/python/Makefile.am         |    3 +-
 tests/python/test-gegl-format.py |   50 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 1 deletions(-)
---
diff --git a/tests/python/Makefile.am b/tests/python/Makefile.am
index 54fee77..d1c5fd6 100644
--- a/tests/python/Makefile.am
+++ b/tests/python/Makefile.am
@@ -13,7 +13,8 @@ TESTS = \
        test-gegl.py \
        test-gegl-node.py \
        test-gegl-color.py \
-       test-gegl-buffer.py
+       test-gegl-buffer.py \
+       test-gegl-format.py
 EXTRA_DIST = $(TESTS)
 endif # HAVE_PYGOBJECT
 endif # HAVE_INTROSPECTION
diff --git a/tests/python/test-gegl-format.py b/tests/python/test-gegl-format.py
new file mode 100755
index 0000000..4ddee0b
--- /dev/null
+++ b/tests/python/test-gegl-format.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+""" This file is part of GEGL
+ *
+ * GEGL 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 3 of the License, or (at your option) any later version.
+ *
+ * GEGL 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 GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2013 Daniel Sabo
+"""
+
+import unittest
+
+from gi.repository import Gegl
+
+class TestGeglFormat(unittest.TestCase):
+    def test_format(self):
+      rgb_float = Gegl.format("RGB float")
+      rgba_u8 = Gegl.format("RGBA u8")
+
+      # Just ensure these don't crash
+      str(rgb_float)
+      repr(rgb_float)
+
+      self.assertEqual("RGB float", Gegl.format_get_name(rgb_float))
+      self.assertEqual("RGBA u8", Gegl.format_get_name(rgba_u8))
+
+    def test_buffer(self):
+      rgb_float = Gegl.format("RGB float")
+      rgba_u8 = Gegl.format("RGBA u8")
+
+      buf_float = Gegl.Buffer(format=rgb_float)
+      buf_u8 = Gegl.Buffer(format=rgba_u8)
+
+      self.assertEqual("RGB float", Gegl.format_get_name(buf_float.get_property("format")))
+      self.assertEqual("RGBA u8", Gegl.format_get_name(buf_u8.get_property("format")))
+
+
+if __name__ == '__main__':
+    Gegl.init(None);
+    unittest.main()
+    Gegl.exit()
\ No newline at end of file


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