Skip to content

Commit

Permalink
test: add derive tests for fully qualified Static associated type b…
Browse files Browse the repository at this point in the history
…ounds
  • Loading branch information
xkikeg authored and fujiapple852 committed Sep 13, 2024
1 parent f616707 commit cccc9fa
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions bounded-static-derive/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,43 @@ fn test_generic_bound_where_2() {
ensure_static(data.into_static());
}

#[test]
fn test_generic_fully_qualified_named_struct() {
#[derive(ToStatic)]
struct Foo<T: IntoBoundedStatic + ToBoundedStatic> {
value: T,
}
let value = "test";
let owned = Foo { value }.to_static();
ensure_static(owned);
let owned = Foo { value }.into_static();
ensure_static(owned);
}

#[test]
fn test_generic_fully_qualified_unnamed_struct() {
#[derive(ToStatic)]
struct Foo<T: IntoBoundedStatic + ToBoundedStatic>(T);
let value = "test";
let owned = Foo(value).to_static();
ensure_static(owned);
let owned = Foo(value).into_static();
ensure_static(owned);
}

#[test]
fn test_generic_fully_qualified_enum() {
#[derive(ToStatic)]
enum Foo<T: IntoBoundedStatic + ToBoundedStatic> {
First(T),
}
let value = "test";
let owned = Foo::First(value).to_static();
ensure_static(owned);
let owned = Foo::First(value).into_static();
ensure_static(owned);
}

fn ensure_static<S: 'static>(s: S) {
drop(s);
}

0 comments on commit cccc9fa

Please sign in to comment.