tests: add rust test
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_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");
+}