Skip to content

Commit

Permalink
test(serde): Demonstrate u64::MAX bug
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Feb 7, 2023
1 parent c8e6d3d commit cd4139f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/toml/tests/testsuite/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,20 @@ fn integer_min() {
}
}

#[test]
fn integer_too_big() {
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
struct Foo {
a_b: u64,
}

let native = Foo { a_b: u64::MAX };
let err = Table::try_from(native.clone()).unwrap_err();
snapbox::assert_eq("u64 value was too large", err.to_string());
let err = toml::to_string(&native).unwrap();
snapbox::assert_eq("a_b = -1\n", err.to_string());
}

#[test]
fn integer_max() {
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
Expand Down

0 comments on commit cd4139f

Please sign in to comment.