From 30e4ee9588fc68b2f96d4cf05deb2908e4a16a6e Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 14 Jul 2017 11:13:03 +0200 Subject: Add basic tests Signed-off-by: Pierre Ossman --- tests/.gitignore | 3 +++ tests/Makefile | 32 ++++++++++++++++++++++++++++++++ tests/python2 | 3 +++ tests/python3 | 3 +++ tests/stdc++.cc | 18 ++++++++++++++++++ tests/stdc.c | 18 ++++++++++++++++++ tests/test.py | 10 ++++++++++ 7 files changed, 87 insertions(+) create mode 100644 tests/.gitignore create mode 100644 tests/Makefile create mode 100755 tests/python2 create mode 100755 tests/python3 create mode 100644 tests/stdc++.cc create mode 100644 tests/stdc.c create mode 100644 tests/test.py 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 +#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 +#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 -- cgit v1.1