aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2021-02-12 12:57:44 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2021-02-12 15:05:57 +0400
commite62d42f0fd76f7bb8bf78385a83c060e66ff52b0 (patch)
tree10fb897d19f8f60cbc5f87a5de1647c069a130bd
parent3e25e1ca1772fc3f2039f739f8f920450dc68e50 (diff)
downloadkeycodemapdb-e62d42f0fd76f7bb8bf78385a83c060e66ff52b0.zip
keycodemapdb-e62d42f0fd76f7bb8bf78385a83c060e66ff52b0.tar.gz
keycodemapdb-e62d42f0fd76f7bb8bf78385a83c060e66ff52b0.tar.bz2
tests: add rust test
-rw-r--r--tests/Makefile23
-rwxr-xr-xtests/rust4
-rw-r--r--tests/rust-test/Cargo.toml10
-rw-r--r--tests/rust-test/src/main.rs23
4 files changed, 59 insertions, 1 deletions
diff --git a/tests/Makefile b/tests/Makefile
index ff23373..3ac7a21 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,4 +1,4 @@
-TESTS := stdc stdc++ python2 python3 javascript
+TESTS := stdc stdc++ python2 python3 javascript rust
check: $(TESTS)
@set -e; for fn in $(TESTS); do \
@@ -137,6 +137,27 @@ osx.js: $(SOURCES)
osx_name.js: $(SOURCES)
$(GEN) name-table --lang js $(DATA) osx > $@
+rust: osx2win32.rs osx2win32_name.rs \
+ osx2xkb.rs osx2xkb_name.rs \
+ html2win32.rs html2win32_name.rs \
+ osx.rs osx_name.rs
+osx2win32.rs: $(SOURCES)
+ $(GEN) code-map --lang rust $(DATA) osx win32 > $@
+osx2win32_name.rs: $(SOURCES)
+ $(GEN) name-map --lang rust $(DATA) osx win32 > $@
+osx2xkb.rs: $(SOURCES)
+ $(GEN) code-map --lang rust $(DATA) osx xkb > $@
+osx2xkb_name.rs: $(SOURCES)
+ $(GEN) name-map --lang rust $(DATA) osx xkb > $@
+html2win32.rs: $(SOURCES)
+ $(GEN) code-map --lang rust $(DATA) html win32 > $@
+html2win32_name.rs: $(SOURCES)
+ $(GEN) name-map --lang rust $(DATA) html win32 > $@
+osx.rs: $(SOURCES)
+ $(GEN) code-table --lang rust $(DATA) osx > $@
+osx_name.rs: $(SOURCES)
+ $(GEN) name-table --lang rust $(DATA) osx > $@
+
clean:
rm -rf node_modules
rm -f osx2win32.*
diff --git a/tests/rust b/tests/rust
new file mode 100755
index 0000000..33bd5fa
--- /dev/null
+++ b/tests/rust
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cd rust-test
+cargo test
diff --git a/tests/rust-test/Cargo.toml b/tests/rust-test/Cargo.toml
new file mode 100644
index 0000000..832ac37
--- /dev/null
+++ b/tests/rust-test/Cargo.toml
@@ -0,0 +1,10 @@
+[package]
+name = "rust-test"
+version = "0.1.0"
+authors = ["Marc-André Lureau <marcandre.lureau@redhat.com>"]
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+phf = { version = "0.8", features = ["macros"] }
diff --git a/tests/rust-test/src/main.rs b/tests/rust-test/src/main.rs
new file mode 100644
index 0000000..019c3d4
--- /dev/null
+++ b/tests/rust-test/src/main.rs
@@ -0,0 +1,23 @@
+include!("../../html2win32_name.rs");
+include!("../../html2win32.rs");
+include!("../../osx2win32_name.rs");
+include!("../../osx2win32.rs");
+include!("../../osx2xkb_name.rs");
+include!("../../osx2xkb.rs");
+include!("../../osx_name.rs");
+include!("../../osx.rs");
+
+#[test]
+fn main() {
+ assert_eq!(CODE_MAP_OSX_TO_WIN32[0x1d], 0x30);
+ assert_eq!(NAME_MAP_OSX_TO_WIN32[0x1d], "VK_0");
+
+ assert_eq!(CODE_MAP_OSX_TO_XKB[0x1d], "AE10");
+ assert_eq!(NAME_MAP_OSX_TO_XKB[0x1d], "AE10");
+
+ assert_eq!(CODE_MAP_HTML_TO_WIN32["ControlLeft"], 0x11);
+ assert_eq!(NAME_MAP_HTML_TO_WIN32["ControlLeft"], "VK_CONTROL");
+
+ assert_eq!(CODE_TABLE_OSX[0x1d], 0x3b);
+ assert_eq!(NAME_TABLE_OSX[0x1d], "Control");
+}