Skip to content

Commit

Permalink
add tests for all impl primitive types
Browse files Browse the repository at this point in the history
  • Loading branch information
corvusrabus committed Sep 7, 2024
1 parent 2f2d32a commit 7072841
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
106 changes: 106 additions & 0 deletions ts-rs/tests/integration/impl_primitive.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#[cfg(feature = "bigdecimal-impl")]
#[test]
fn impl_primitive_bigdecimal() {
assert_eq!(
<bigdecimal::BigDecimal as ts_rs::TS>::name(),
<String as ts_rs::TS>::name()
);
assert_eq!(
<bigdecimal::BigDecimal as ts_rs::TS>::inline(),
<String as ts_rs::TS>::inline()
)
}

#[cfg(feature = "smolstr-impl")]
#[test]
fn impl_primitive_smolstr() {
assert_eq!(
<smol_str::SmolStr as ts_rs::TS>::name(),
<String as ts_rs::TS>::name()
);
assert_eq!(
<smol_str::SmolStr as ts_rs::TS>::inline(),
<String as ts_rs::TS>::inline()
)
}

#[cfg(feature = "uuid-impl")]
#[test]
fn impl_primitive_uuid() {
assert_eq!(
<uuid::Uuid as ts_rs::TS>::name(),
<String as ts_rs::TS>::name()
);
assert_eq!(
<uuid::Uuid as ts_rs::TS>::inline(),
<String as ts_rs::TS>::inline()
)
}

#[cfg(feature = "url-impl")]
#[test]
fn impl_primitive_url() {
assert_eq!(
<url::Url as ts_rs::TS>::name(),
<String as ts_rs::TS>::name()
);
assert_eq!(
<url::Url as ts_rs::TS>::inline(),
<String as ts_rs::TS>::inline()
)
}

#[cfg(feature = "ordered-float-impl")]
#[test]
fn impl_primitive_order_float() {
assert_eq!(
<ordered_float::OrderedFloat<f64> as ts_rs::TS>::name(),
<f64 as ts_rs::TS>::name()
);
assert_eq!(
<ordered_float::OrderedFloat<f64> as ts_rs::TS>::inline(),
<f64 as ts_rs::TS>::inline()
);
assert_eq!(
<ordered_float::OrderedFloat<f32> as ts_rs::TS>::name(),
<f32 as ts_rs::TS>::name()
);
assert_eq!(
<ordered_float::OrderedFloat<f32> as ts_rs::TS>::inline(),
<f32 as ts_rs::TS>::inline()
)
}

#[cfg(feature = "bson-uuid-impl")]
#[test]
fn impl_primitive_bson_uuid() {
assert_eq!(
<bson::oid::ObjectId as ts_rs::TS>::name(),
<String as ts_rs::TS>::name()
);
assert_eq!(
<bson::oid::ObjectId as ts_rs::TS>::inline(),
<String as ts_rs::TS>::inline()
);
assert_eq!(
<bson::Uuid as ts_rs::TS>::name(),
<String as ts_rs::TS>::name()
);
assert_eq!(
<bson::Uuid as ts_rs::TS>::inline(),
<String as ts_rs::TS>::inline()
)
}

#[cfg(feature = "semver-impl")]
#[test]
fn impl_primitive_semver() {
assert_eq!(
<semver::Version as ts_rs::TS>::name(),
<String as ts_rs::TS>::name()
);
assert_eq!(
<semver::Version as ts_rs::TS>::inline(),
<String as ts_rs::TS>::inline()
)
}
1 change: 1 addition & 0 deletions ts-rs/tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod generics;
mod generics_flatten;
mod hashmap;
mod hashset;
mod impl_primitive;
mod imports;
mod indexmap;
mod infer_as;
Expand Down

0 comments on commit 7072841

Please sign in to comment.