On Fri, Mar 11, 2011 at 03:13:55PM -0800, 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>
> ---
>  tools/xsetwacom.c |   43 +++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 43 insertions(+), 0 deletions(-)
> 
> diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
> index d867982..f7b2e58 100644
> --- a/tools/xsetwacom.c
> +++ b/tools/xsetwacom.c
> @@ -2238,6 +2238,48 @@ 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 *retval = calloc(1, sizeof(int));
> +     if (!retval)
> +     {
> +             fprintf(stderr, "calloc failed\n");
> +             exit(EXIT_FAILURE);
> +     }

hehe, Java coming though?  same as with the first patch, we can just use a
normal integer and then use &retval;

Reviewed-by: Peter Hutterer <peter.hutte...@who-t.net> otherwise

Cheers,
  Peter

> +
> +     g_assert(convert_value_from_user(&test_nonbool, "1", retval) == True);
> +     g_assert(convert_value_from_user(&test_nonbool, "-8", retval) == True);
> +     g_assert(convert_value_from_user(&test_nonbool, "+314", retval) == 
> True);
> +     g_assert(convert_value_from_user(&test_nonbool, "36893488147419103232", 
> retval) == False); //2^65 > MAX_INT
> +     g_assert(convert_value_from_user(&test_nonbool, "123abc", retval) == 
> False);
> +     g_assert(convert_value_from_user(&test_nonbool, "123 abc", retval) == 
> False);
> +
> +     g_assert(convert_value_from_user(&test_bool, "true", retval) == True);
> +     g_assert(convert_value_from_user(&test_bool, "On", retval) == True);
> +     g_assert(convert_value_from_user(&test_bool, "oFf", retval) == True);
> +     g_assert(convert_value_from_user(&test_bool, "FALSE", retval) == True);
> +     g_assert(convert_value_from_user(&test_bool, "0", retval) == False);
> +     g_assert(convert_value_from_user(&test_bool, "1", retval) == False);
> +     g_assert(convert_value_from_user(&test_bool, " on", retval) == False);
> +     g_assert(convert_value_from_user(&test_bool, "off ", retval) == False);
> +
> +     free(retval);
> +}
> +
>  
>  int main(int argc, char** argv)
>  {
> @@ -2245,6 +2287,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

Reply via email to