Skip to content

Commit

Permalink
Add a test for tafia#280
Browse files Browse the repository at this point in the history
  • Loading branch information
dralley committed Aug 22, 2021
1 parent aa6ec2d commit 71ef20f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 21 additions & 0 deletions tests/serde_roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,27 @@ fn round_trip_list_of_enums() {
assert_eq!(deserialized_nodes, nodes);
}

#[test]
#[ignore]
fn roundtrip_struct_containing_list_strings() {
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub struct NamesList {
pub names: Vec<String>,
}

let names = NamesList {
names: ["pickaxe", "torch", "bow"]
.iter()
.map(|s| s.to_string())
.collect(),
};

let serialized = to_string(&names).unwrap();
let deserialized: NamesList = from_str(&serialized).unwrap();

assert_eq!(names, deserialized);
}

#[test]
fn no_contiguous_fields() {
#[derive(Serialize, Deserialize, PartialEq, Debug)]
Expand Down
5 changes: 4 additions & 1 deletion tests/unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,10 @@ fn test_write_attrs() -> Result<()> {
}

let result = writer.into_inner().into_inner();
assert_eq!(result, expected.as_bytes());
assert_eq!(
std::str::from_utf8(&result).unwrap(),
std::str::from_utf8(expected.as_bytes()).unwrap()
);

Ok(())
}
Expand Down

0 comments on commit 71ef20f

Please sign in to comment.