diff options
author | Damien Lespiau <damien.lespiau@intel.com> | 2009-10-03 14:08:33 +0100 |
---|---|---|
committer | Damien Lespiau <damien.lespiau@intel.com> | 2009-10-05 13:08:16 +0100 |
commit | a799f6ccec0ea755c7677c5fe20c1bd52b321c05 (patch) | |
tree | 70662c38fb729d6c52347d22589ae8fdb006842b | |
parent | 4d7b8c9d4290c91ea69d992bad396d067e84b15b (diff) | |
download | clutter-a799f6ccec0ea755c7677c5fe20c1bd52b321c05.tar.gz |
Fix string parsing when no unit is given
The check should really be on the character pointed by str. Added the
corresponding test case.
-rw-r--r-- | clutter/clutter-units.c | 2 | ||||
-rw-r--r-- | tests/conform/test-clutter-units.c | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/clutter/clutter-units.c b/clutter/clutter-units.c index 9e6d1f0ad..788bab917 100644 --- a/clutter/clutter-units.c +++ b/clutter/clutter-units.c @@ -428,7 +428,7 @@ clutter_units_from_string (ClutterUnits *units, } /* assume pixels by default, if no unit is specified */ - if (str == '\0') + if (*str == '\0') unit_type = CLUTTER_UNIT_PIXEL; else { diff --git a/tests/conform/test-clutter-units.c b/tests/conform/test-clutter-units.c index b809e88d9..2a8f8ba13 100644 --- a/tests/conform/test-clutter-units.c +++ b/tests/conform/test-clutter-units.c @@ -27,6 +27,10 @@ test_units_string (TestConformSimpleFixture *fixture, ClutterUnits units; gchar *string; + g_assert (clutter_units_from_string (&units, "10") == TRUE); + g_assert (clutter_units_get_unit_type (&units) == CLUTTER_UNIT_PIXEL); + g_assert_cmpfloat (clutter_units_get_unit_value (&units), ==, 10); + g_assert (clutter_units_from_string (&units, "5 em") == TRUE); g_assert (clutter_units_get_unit_type (&units) == CLUTTER_UNIT_EM); g_assert_cmpfloat (clutter_units_get_unit_value (&units), ==, 5); |