conform/color: Check invalid strings

We need to make sure to fail consistently for invalid strings.
This commit is contained in:
Emmanuele Bassi 2011-11-10 14:15:32 +00:00
parent 0550a8b99d
commit e374c2bd89
2 changed files with 20 additions and 3 deletions

View File

@ -73,8 +73,24 @@ test_color_hls_roundtrip (TestConformSimpleFixture *fixture,
} }
void void
test_color_from_string (TestConformSimpleFixture *fixture, test_color_from_string_invalid (TestConformSimpleFixture *fixture,
gconstpointer data) 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; ClutterColor color;

View File

@ -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_from_script);
TEST_CONFORM_SIMPLE ("/model", test_list_model_row_changed); 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_to_string);
TEST_CONFORM_SIMPLE ("/color", test_color_hls_roundtrip); TEST_CONFORM_SIMPLE ("/color", test_color_hls_roundtrip);
TEST_CONFORM_SIMPLE ("/color", test_color_operators); TEST_CONFORM_SIMPLE ("/color", test_color_operators);