test: Add convenience functions for xkey.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/test/xkey.sh b/test/xkey.sh
index b201822..a409302 100755
--- a/test/xkey.sh
+++ b/test/xkey.sh
@@ -13,18 +13,21 @@ check_error()
fi
}
-val=`${builddir}/xkey -s Undo` && \
- check_error Undo 0xff65 $val || \
- exit $?
-
-val=`${builddir}/xkey -k 0x1008ff56` && \
- check_error 0x1008FF56 XF86Close $val || \
- exit $?
+check_string()
+{
+ val=`${builddir}/xkey -s "$1"` &&
+ check_error "$1" "$2" "$val" ||
+ exit $?
+}
-val=`${builddir}/xkey -s ThisKeyShouldNotExist` && \
- check_error ThisKeyShouldNotExist NoSymbol $val || \
- exit $?
+check_key()
+{
+ val=`${builddir}/xkey -k "$1"` && \
+ check_error "$1" "$2" "$val" || \
+ exit $?
+}
-val=`${builddir}/xkey -k 0x0` && \
- check_error 0x0 NULL $val || \
- exit $?
+check_string Undo 0xff65
+check_key 0x1008FF56 XF86Close
+check_string ThisKeyShouldNotExist NoSymbol
+check_key 0x0 NULL