Skip to content

Commit

Permalink
Add test of integer128 to_value
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Feb 8, 2023
1 parent a9c984f commit f77ad47
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test.rs
Expand Up @@ -2180,6 +2180,27 @@ fn test_integer128() {
]);
}

#[test]
fn test_integer128_to_value() {
let signed = &[i128::from(i64::min_value()), i128::from(u64::max_value())];
let unsigned = &[0, u128::from(u64::max_value())];

for integer128 in signed {
let expected = integer128.to_string();
assert_eq!(to_value(integer128).unwrap().to_string(), expected);
}

for integer128 in unsigned {
let expected = integer128.to_string();
assert_eq!(to_value(integer128).unwrap().to_string(), expected);
}

if !cfg!(feature = "arbitrary_precision") {
let err = to_value(u128::from(u64::max_value()) + 1).unwrap_err();
assert_eq!(err.to_string(), "number out of range");
}
}

#[cfg(feature = "raw_value")]
#[test]
fn test_borrowed_raw_value() {
Expand Down

0 comments on commit f77ad47

Please sign in to comment.