mirror of
https://github.com/xazukx/ts-rs.git
synced 2026-11-19 22:40:25 +00:00
Add tests for all impl_shadow! types
This commit is contained in:
+34
-1
@@ -1,5 +1,6 @@
|
||||
#![allow(dead_code)]
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
|
||||
use ts_rs::TS;
|
||||
|
||||
@@ -37,3 +38,35 @@ fn hashmap_with_custom_hasher() {
|
||||
"type HashesHasher = { map: Record<string, string>, set: Array<string>, };"
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(TS, Eq, PartialEq, Hash)]
|
||||
#[ts(export, export_to = "tests-out/hashmap/")]
|
||||
struct CustomKey;
|
||||
|
||||
#[derive(TS)]
|
||||
#[ts(export, export_to = "tests-out/hashmap/")]
|
||||
struct CustomValue;
|
||||
|
||||
#[derive(TS)]
|
||||
#[ts(export, export_to = "tests-out/hashmap/")]
|
||||
struct HashMapWithCustomTypes {
|
||||
map: HashMap<CustomKey, CustomValue>,
|
||||
}
|
||||
|
||||
#[derive(TS)]
|
||||
#[ts(export, export_to = "tests-out/hashmap/")]
|
||||
struct BTreeMapWithCustomTypes {
|
||||
map: BTreeMap<CustomKey, CustomValue>,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_custom_types() {
|
||||
assert_eq!(
|
||||
HashMapWithCustomTypes::inline(),
|
||||
BTreeMapWithCustomTypes::inline()
|
||||
);
|
||||
assert_eq!(
|
||||
HashMapWithCustomTypes::decl(),
|
||||
"type HashMapWithCustomTypes = { map: Record<CustomKey, CustomValue>, };"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::collections::{BTreeSet, HashSet};
|
||||
|
||||
use ts_rs::TS;
|
||||
|
||||
#[derive(TS, Eq, PartialEq, Hash)]
|
||||
#[ts(export, export_to = "tests-out/hashset/")]
|
||||
struct CustomValue;
|
||||
|
||||
#[derive(TS)]
|
||||
#[ts(export, export_to = "tests-out/hashset/")]
|
||||
struct HashSetWithCustomType {
|
||||
set: HashSet<CustomValue>,
|
||||
}
|
||||
|
||||
#[derive(TS)]
|
||||
#[ts(export, export_to = "tests-out/hashset/")]
|
||||
struct BTreeSetWithCustomType {
|
||||
set: BTreeSet<CustomValue>,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_custom_types() {
|
||||
assert_eq!(
|
||||
HashSetWithCustomType::inline(),
|
||||
BTreeSetWithCustomType::inline()
|
||||
);
|
||||
assert_eq!(
|
||||
HashSetWithCustomType::decl(),
|
||||
"type HashSetWithCustomType = { set: Array<CustomValue>, };"
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(unused)]
|
||||
|
||||
use ts_rs::TS;
|
||||
|
||||
#[test]
|
||||
@@ -66,3 +68,11 @@ struct NewtypeBoxed(#[allow(dead_code)] Box<[i32]>);
|
||||
fn boxed_newtype() {
|
||||
assert_eq!(NewtypeBoxed::inline(), "Array<number>")
|
||||
}
|
||||
|
||||
#[derive(TS)]
|
||||
#[ts(export, export_to = "tests-out/slices/nested/")]
|
||||
struct InnerMost;
|
||||
|
||||
#[derive(TS)]
|
||||
#[ts(export, export_to = "tests-out/slices/nested/")]
|
||||
struct Nested<'a>(&'a [InnerMost]);
|
||||
|
||||
Reference in New Issue
Block a user