aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2017-07-14 11:13:03 +0200
committerPierre Ossman <ossman@cendio.se>2017-08-02 10:20:29 +0200
commit30e4ee9588fc68b2f96d4cf05deb2908e4a16a6e (patch)
tree32268870273b5fc378b36848787b707967c31735
parent5486fb9191e849ab84b52c5c2b0782c14d8046f1 (diff)
downloadkeycodemapdb-30e4ee9588fc68b2f96d4cf05deb2908e4a16a6e.zip
keycodemapdb-30e4ee9588fc68b2f96d4cf05deb2908e4a16a6e.tar.gz
keycodemapdb-30e4ee9588fc68b2f96d4cf05deb2908e4a16a6e.tar.bz2
Add basic tests
Signed-off-by: Pierre Ossman <ossman@cendio.se>
-rw-r--r--tests/.gitignore3
-rw-r--r--tests/Makefile32
-rwxr-xr-xtests/python23
-rwxr-xr-xtests/python33
-rw-r--r--tests/stdc++.cc18
-rw-r--r--tests/stdc.c18
-rw-r--r--tests/test.py10
7 files changed, 87 insertions, 0 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644
index 0000000..bda4ab4
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1,3 @@
+osx2win32.*
+stdc
+stdc++
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..b396b4d
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,32 @@
+TESTS := stdc stdc++ python2 python3
+
+check: $(TESTS)
+ @set -e; for fn in $(TESTS); do \
+ ./$$fn; \
+ echo $$fn: OK; \
+ done
+ @echo Done.
+
+GEN := ../tools/keymap-gen
+DATA := ../data/keymaps.csv
+SOURCES := $(GEN) $(DATA)
+
+.DELETE_ON_ERROR:
+
+stdc: stdc.c osx2win32.h
+ $(CC) -o $@ $^
+osx2win32.h: $(SOURCES)
+ $(GEN) --lang stdc code-map $(DATA) osx win32 > $@
+
+stdc++: stdc++.cc osx2win32.hh
+ $(CC) -o $@ $^
+osx2win32.hh: $(SOURCES)
+ $(GEN) --lang stdc++ code-map $(DATA) osx win32 > $@
+
+python2: osx2win32.py
+osx2win32.py: $(SOURCES)
+ $(GEN) --lang python2 code-map $(DATA) osx win32 > $@
+
+clean:
+ rm -f osx2win32.*
+ rm -f stdc stdc++
diff --git a/tests/python2 b/tests/python2
new file mode 100755
index 0000000..28a5b03
--- /dev/null
+++ b/tests/python2
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+python ./test.py
diff --git a/tests/python3 b/tests/python3
new file mode 100755
index 0000000..ded1f68
--- /dev/null
+++ b/tests/python3
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+python3 ./test.py
diff --git a/tests/stdc++.cc b/tests/stdc++.cc
new file mode 100644
index 0000000..51727cf
--- /dev/null
+++ b/tests/stdc++.cc
@@ -0,0 +1,18 @@
+/*
+ * Keycode Map Generator C++ Tests
+ *
+ * Copyright 2017 Pierre Ossman for Cendio AB
+ *
+ * This file is dual license under the terms of the GPLv2 or later
+ * and 3-clause BSD licenses.
+ */
+
+#include <assert.h>
+#include "osx2win32.hh"
+
+int main(int argc, char** argv)
+{
+ assert(code_map_osx_to_win32[0x1d] == 0x30);
+
+ return 0;
+}
diff --git a/tests/stdc.c b/tests/stdc.c
new file mode 100644
index 0000000..152357d
--- /dev/null
+++ b/tests/stdc.c
@@ -0,0 +1,18 @@
+/*
+ * Keycode Map Generator C Tests
+ *
+ * Copyright 2017 Pierre Ossman for Cendio AB
+ *
+ * This file is dual license under the terms of the GPLv2 or later
+ * and 3-clause BSD licenses.
+ */
+
+#include <assert.h>
+#include "osx2win32.h"
+
+int main(int argc, char** argv)
+{
+ assert(code_map_osx_to_win32[0x1d] == 0x30);
+
+ return 0;
+}
diff --git a/tests/test.py b/tests/test.py
new file mode 100644
index 0000000..0efdafa
--- /dev/null
+++ b/tests/test.py
@@ -0,0 +1,10 @@
+# Keycode Map Generator Python Tests
+#
+# Copyright 2017 Pierre Ossman for Cendio AB
+#
+# This file is dual license under the terms of the GPLv2 or later
+# and 3-clause BSD licenses.
+
+import osx2win32
+
+assert osx2win32.code_map_osx_to_win32[0x1d] == 0x30