Add basic tests Signed-off-by: Pierre Ossman <ossman@cendio.se>
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