On Mon, Mar 14, 2011 at 04:10:59PM -0700, Jason Gerecke wrote: > Some basic tests to ensure booleans and non-booleans act like we > want them to. > > Signed-off-by: Jason Gerecke <killert...@gmail.com> > --- > Changes from v2: > > * Use &val instead of allocating memory > > tools/xsetwacom.c | 38 ++++++++++++++++++++++++++++++++++++++ > 1 files changed, 38 insertions(+), 0 deletions(-) > > diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c > index c9db2e7..8cc7292 100644 > --- a/tools/xsetwacom.c > +++ b/tools/xsetwacom.c > @@ -2227,6 +2227,43 @@ static void test_parameter_number(void) > g_assert(ArrayLength(deprecated_parameters) == 16); > } > > +static void test_convert_value_from_user(void) > +{ > + param_t test_nonbool = > + { > + .name = "Test", > + .desc = "NOT A REAL PARAMETER", > + .prop_flags = 0, > + }; > + > + param_t test_bool = > + { > + .name = "Test", > + .desc = "NOT A REAL PARAMETER", > + .prop_flags = PROP_FLAG_BOOLEAN, > + }; > + > + int val; > + > + g_assert(convert_value_from_user(&test_nonbool, "1", &val) == True); > + g_assert(convert_value_from_user(&test_nonbool, "-8", &val) == True); > + g_assert(convert_value_from_user(&test_nonbool, "+314", &val) == True); > + g_assert(convert_value_from_user(&test_nonbool, "36893488147419103232", > &val) == False); //2^65 > MAX_INT > + g_assert(convert_value_from_user(&test_nonbool, "123abc", &val) == > False); > + g_assert(convert_value_from_user(&test_nonbool, "123 abc", &val) == > False); > + > + g_assert(convert_value_from_user(&test_bool, "true", &val) == True); > + g_assert(convert_value_from_user(&test_bool, "On", &val) == True); > + g_assert(convert_value_from_user(&test_bool, "oFf", &val) == True); > + g_assert(convert_value_from_user(&test_bool, "FALSE", &val) == True); > + g_assert(convert_value_from_user(&test_bool, "0", &val) == False); > + g_assert(convert_value_from_user(&test_bool, "1", &val) == False); > + g_assert(convert_value_from_user(&test_bool, " on", &val) == False); > + g_assert(convert_value_from_user(&test_bool, "off ", &val) == False); > + > + free(retval); > +}
hmm, did you compile this? Cheers, Peter > + > > int main(int argc, char** argv) > { > @@ -2234,6 +2271,7 @@ int main(int argc, char** argv) > g_test_add_func("/xsetwacom/parameter_number", test_parameter_number); > g_test_add_func("/xsetwacom/is_modifier", test_is_modifier); > g_test_add_func("/xsetwacom/convert_specialkey", > test_convert_specialkey); > + g_test_add_func("/xsetwacom/convert_value_from_user", > test_convert_value_from_user); > return g_test_run(); > } > > -- > 1.7.1 ------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel