[clutter] conform/color: Check invalid strings



commit e374c2bd8922049ab9c0e285baf21e56641ec974
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Thu Nov 10 14:15:32 2011 +0000

    conform/color: Check invalid strings
    
    We need to make sure to fail consistently for invalid strings.

 tests/conform/test-color.c        |   20 ++++++++++++++++++--
 tests/conform/test-conform-main.c |    3 ++-
 2 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/tests/conform/test-color.c b/tests/conform/test-color.c
index a6f4327..a212e83 100644
--- a/tests/conform/test-color.c
+++ b/tests/conform/test-color.c
@@ -73,8 +73,24 @@ test_color_hls_roundtrip (TestConformSimpleFixture *fixture,
 }
 
 void
-test_color_from_string (TestConformSimpleFixture *fixture,
-                        gconstpointer data)
+test_color_from_string_invalid (TestConformSimpleFixture *fixture,
+                                gconstpointer data)
+{
+  ClutterColor color;
+
+  g_assert (!clutter_color_from_string (&color, "ff0000ff"));
+  g_assert (!clutter_color_from_string (&color, "#decaffbad"));
+  g_assert (!clutter_color_from_string (&color, "ponies"));
+  g_assert (!clutter_color_from_string (&color, "rgb(255, 0, 0, 0)"));
+  g_assert (!clutter_color_from_string (&color, "rgba(1.0, 0, 0)"));
+  g_assert (!clutter_color_from_string (&color, "hsl(100, 0, 0)"));
+  g_assert (!clutter_color_from_string (&color, "hsla(10%, 0%, 50%)"));
+  g_assert (!clutter_color_from_string (&color, "hsla(100%, 0%, 50%, 20%)"));
+}
+
+void
+test_color_from_string_valid (TestConformSimpleFixture *fixture,
+                              gconstpointer data)
 {
   ClutterColor color;
 
diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
index 5055772..3373e94 100644
--- a/tests/conform/test-conform-main.c
+++ b/tests/conform/test-conform-main.c
@@ -182,7 +182,8 @@ main (int argc, char **argv)
   TEST_CONFORM_SIMPLE ("/model", test_list_model_from_script);
   TEST_CONFORM_SIMPLE ("/model", test_list_model_row_changed);
 
-  TEST_CONFORM_SIMPLE ("/color", test_color_from_string);
+  TEST_CONFORM_SIMPLE ("/color", test_color_from_string_valid);
+  TEST_CONFORM_SIMPLE ("/color", test_color_from_string_invalid);
   TEST_CONFORM_SIMPLE ("/color", test_color_to_string);
   TEST_CONFORM_SIMPLE ("/color", test_color_hls_roundtrip);
   TEST_CONFORM_SIMPLE ("/color", test_color_operators);



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