On Sun, Feb 13, 2011 at 9:23 PM, Peter Hutterer <peter.hutte...@who-t.net>wrote:

> Includes simple test for is_modifier().
>
> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
>

Acked-by: Ping Cheng <pingli...@gmail.com> for the series.

Thank you,

Ping

---
>  tools/Makefile.am |   10 ++++++++++
>  tools/xsetwacom.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 56 insertions(+), 0 deletions(-)
>
> diff --git a/tools/Makefile.am b/tools/Makefile.am
> index 9f70b3d..a0cd127 100644
> --- a/tools/Makefile.am
> +++ b/tools/Makefile.am
> @@ -23,3 +23,13 @@ bin_PROGRAMS = xsetwacom isdv4-serial-debugger
>  AM_CPPFLAGS = -I$(top_srcdir)/include
>  AM_CFLAGS = $(XORG_CFLAGS) $(X11_CFLAGS)
>  AM_LDFLAGS = $(X11_LIBS)
> +
> +
> +if UNITTESTS
> +check_PROGRAMS = xsetwacom-test
> +xsetwacom_test_SOURCES=xsetwacom.c
> +xsetwacom_test_LDADD=$(GLIB_LIBS)
> +xsetwacom_test_CFLAGS=-DBUILD_TEST $(GLIB_CFLAGS)
> +
> +TESTS=$(check_PROGRAMS)
> +endif
> diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
> index 7056e6b..1d0d2f9 100644
> --- a/tools/xsetwacom.c
> +++ b/tools/xsetwacom.c
> @@ -2007,6 +2007,7 @@ static void get_param(Display *dpy, XDevice *dev,
> param_t *param, int argc, char
>  }
>
>
> +#ifndef BUILD_TEST
>  int main (int argc, char **argv)
>  {
>        int c;
> @@ -2121,6 +2122,51 @@ int main (int argc, char **argv)
>        XCloseDisplay(dpy);
>        return 0;
>  }
> +#endif
> +
> +#ifdef BUILD_TEST
> +#include <glib.h>
> +/**
> + * Below are unit-tests to ensure xsetwacom continues to work as expected.
> + */
> +
> +static void test_is_modifier(void)
> +{
> +       char i;
> +       char buff[5];
> +
> +
> +       g_assert(is_modifier("Control_L"));
> +       g_assert(is_modifier("Control_R"));
> +       g_assert(is_modifier("Alt_L"));
> +       g_assert(is_modifier("Alt_R"));
> +       g_assert(is_modifier("Shift_L"));
> +       g_assert(is_modifier("Shift_R"));
> +       g_assert(is_modifier("Meta_L"));
> +       g_assert(is_modifier("Meta_R"));
> +       g_assert(is_modifier("Super_L"));
> +       g_assert(is_modifier("Super_R"));
> +       g_assert(is_modifier("Hyper_L"));
> +       g_assert(is_modifier("Hyper_R"));
> +
> +       g_assert(!is_modifier(""));
> +
> +       /* make sure at least the default keys (ascii 33 - 126) aren't
> +        * modifiers */
> +       for (i = '!'; i <= '~'; i++)
> +       {
> +               sprintf(buff, "%c", i);
> +               g_assert(!is_modifier(buff));
> +       }
> +}
> +
>
> +int main(int argc, char** argv)
> +{
> +       g_test_init(&argc, &argv, NULL);
> +       g_test_add_func("/xsetwacom/is_modifier", test_is_modifier);
> +       return g_test_run();
> +}
>
> +#endif
>  /* vim: set noexpandtab tabstop=8 shiftwidth=8: */
> --
> 1.7.3.5
>
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> Linuxwacom-devel mailing list
> Linuxwacom-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
>
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to