mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
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 */
|
||||
if (str == '\0')
|
||||
if (*str == '\0')
|
||||
unit_type = CLUTTER_UNIT_PIXEL;
|
||||
else
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user