Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test to check that LabelledGeneric works with keyword fields #238

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ pub struct SuperLongField {
pub abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789: i32,
}

#[derive(LabelledGeneric)]
pub struct HasKeyword1 {
pub r#type: i32,
}

#[derive(LabelledGeneric)]
pub struct HasKeyword2 {
pub r#type: i32,
}

#[derive(LabelledGeneric)]
pub struct HasKeyword1Embedder {
pub r#true: HasKeyword1,
}

#[derive(LabelledGeneric)]
pub struct HasKeyword2Embedder {
pub r#true: HasKeyword2,
}

#[derive(Generic, Debug, PartialEq, Eq)]
pub struct TupleStruct<'a>(pub &'a str, pub i32);

Expand Down
17 changes: 17 additions & 0 deletions tests/labelled_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,20 @@ fn test_sculpt_enum() {
}
);
}

#[test]
fn test_transmogrify_keyword_field_structs() {
let value = HasKeyword1 { r#type: 3 };
let result: HasKeyword2 = value.transmogrify();
assert_eq!(3, result.r#type);
}

#[test]
fn test_transmogrify_keyword_field_embedder_structs() {
let value = {
let embedded = HasKeyword1 { r#type: 3 };
HasKeyword1Embedder { r#true: embedded }
};
let result: HasKeyword2Embedder = value.transmogrify();
assert_eq!(3, result.r#true.r#type);
}
Loading