From 457addb60f102f4664d8229249ae14f733b8e60a Mon Sep 17 00:00:00 2001 From: Victor Koenders Date: Sat, 14 Oct 2023 20:50:53 +0200 Subject: [PATCH] Added hashmap tests --- ts-rs/tests/hashmap.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 ts-rs/tests/hashmap.rs diff --git a/ts-rs/tests/hashmap.rs b/ts-rs/tests/hashmap.rs new file mode 100644 index 000000000..f03f56519 --- /dev/null +++ b/ts-rs/tests/hashmap.rs @@ -0,0 +1,37 @@ +use std::collections::{HashMap, HashSet}; +use ts_rs::TS; + +#[test] +fn hashmap() { + #[derive(TS)] + #[allow(dead_code)] + struct Hashes { + map: HashMap, + set: HashSet, + } + + assert_eq!( + Hashes::decl(), + "interface Hashes { map: Record, set: Array, }" + ) +} + +#[test] +fn hashmap_with_custom_hasher() { + struct CustomHasher {} + + type CustomHashMap = HashMap; + type CustomHashSet = HashSet; + + #[derive(TS)] + #[allow(dead_code)] + struct Hashes { + map: CustomHashMap, + set: CustomHashSet, + } + + assert_eq!( + Hashes::decl(), + "interface Hashes { map: Record, set: Array, }" + ) +}