Fix string parsing when no unit is given
The check should really be on the character pointed by str. Added the corresponding test case.
This commit is contained in:
parent
4d7b8c9d42
commit
a799f6ccec
@ -428,7 +428,7 @@ clutter_units_from_string (ClutterUnits *units,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* assume pixels by default, if no unit is specified */
|
/* assume pixels by default, if no unit is specified */
|
||||||
if (str == '\0')
|
if (*str == '\0')
|
||||||
unit_type = CLUTTER_UNIT_PIXEL;
|
unit_type = CLUTTER_UNIT_PIXEL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,10 @@ test_units_string (TestConformSimpleFixture *fixture,
|
|||||||
ClutterUnits units;
|
ClutterUnits units;
|
||||||
gchar *string;
|
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_from_string (&units, "5 em") == TRUE);
|
||||||
g_assert (clutter_units_get_unit_type (&units) == CLUTTER_UNIT_EM);
|
g_assert (clutter_units_get_unit_type (&units) == CLUTTER_UNIT_EM);
|
||||||
g_assert_cmpfloat (clutter_units_get_unit_value (&units), ==, 5);
|
g_assert_cmpfloat (clutter_units_get_unit_value (&units), ==, 5);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user