summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2009-10-03 14:08:33 +0100
committerDamien Lespiau <damien.lespiau@intel.com>2009-10-05 13:08:16 +0100
commita799f6ccec0ea755c7677c5fe20c1bd52b321c05 (patch)
tree70662c38fb729d6c52347d22589ae8fdb006842b
parent4d7b8c9d4290c91ea69d992bad396d067e84b15b (diff)
downloadclutter-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.c2
-rw-r--r--tests/conform/test-clutter-units.c4
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);