summaryrefslogtreecommitdiff
path: root/src/wcmUSB.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wcmUSB.c')
-rw-r--r--src/wcmUSB.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/wcmUSB.c b/src/wcmUSB.c
index dd38f35..5b10ee3 100644
--- a/src/wcmUSB.c
+++ b/src/wcmUSB.c
@@ -21,6 +21,10 @@
#include "xf86Wacom.h"
+#if ENABLE_TESTS
+#include "wacom-test-suite.h"
+#endif
+
#include <math.h>
#include <asm/types.h>
#include <linux/input.h>
@@ -1347,7 +1351,7 @@ static void usbParseAbsEvent(WacomCommonPtr common,
*
* @return The new button mask
*/
-TEST_NON_STATIC int
+static int
mod_buttons(WacomCommonPtr common, int buttons, int btn, int state)
{
int mask;
@@ -2066,4 +2070,24 @@ static int usbProbeKeys(WacomDevicePtr priv)
}
+#ifdef ENABLE_TESTS
+
+TEST_CASE(test_mod_buttons)
+{
+ WacomCommonRec common = {0};
+ int i;
+ for (i = 0; i < sizeof(int) * 8; i++)
+ {
+ int buttons = mod_buttons(&common, 0, i, 1);
+ assert(buttons == (1 << i));
+ buttons = mod_buttons(&common, 0, i, 0);
+ assert(buttons == 0);
+ }
+
+ assert(mod_buttons(&common, 0, sizeof(int) * 8, 1) == 0);
+}
+
+
+#endif
+
/* vim: set noexpandtab tabstop=8 shiftwidth=8: */