Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxbotix committed Apr 7, 2024
1 parent c2f3808 commit 921838a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions crates/serialize_hierarchy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ mod tests {
#[derive(Deserialize, Serialize, SerializeHierarchy)]
struct TupleStruct(bool, f32, Inner, Outer);

#[derive(Deserialize, Serialize, SerializeHierarchy)]
struct NestedTupleStruct(bool, Inner, TupleStruct);

#[test]
fn primitive_fields_are_empty() {
assert_eq!(bool::get_fields(), Default::default());
Expand All @@ -75,4 +78,36 @@ mod tests {
["inner".to_string(), "inner.field".to_string()].into()
);
}

#[test]
fn tuple_struct_fields_contain_fields() {
assert_eq!(
TupleStruct::get_fields(),
["0", "1", "2", "2.field", "3", "3.inner", "3.inner.field"]
.map(|s| s.to_string())
.into()
);
}

#[test]
fn nested_tuple_struct_fields_contain_fields() {
assert_eq!(
NestedTupleStruct::get_fields(),
[
"0",
"1",
"1.field",
"2",
"2.0",
"2.1",
"2.2",
"2.2.field",
"2.3",
"2.3.inner",
"2.3.inner.field"
]
.map(|s| s.to_string())
.into()
);
}
}

0 comments on commit 921838a

Please sign in to comment.