(fix): broken connections
Some checks failed
CI / checks (push) Failing after 5m37s

This commit is contained in:
Alois 2026-07-27 21:37:41 +02:00
commit 10c862de59
Signed by: alois
SSH key fingerprint: SHA256:GBzT2DXvAuGV9XIV5W3WrzVpjU54FThmxHXdbz95J24
3 changed files with 15 additions and 7 deletions

View file

@ -289,7 +289,7 @@ impl DataValue {
pub fn as_number(&self) -> Option<i128> {
match self {
DataValue::SignedNumber(n) => Some(*n),
DataValue::UnsignedNumber(n) => Some(*n as i128),
DataValue::UnsignedNumber(n) => i128::try_from(*n).ok(),
_ => None,
}
}
@ -1232,6 +1232,18 @@ mod tests {
Ok(())
}
#[test]
fn unsigned_number_conversion_rejects_i128_overflow() {
assert_eq!(
DataValue::UnsignedNumber(i128::MAX as u128).as_number(),
Some(i128::MAX)
);
assert_eq!(
DataValue::UnsignedNumber(i128::MAX as u128 + 1).as_number(),
None
);
}
#[test]
fn test_empty_container_and_array_have_distinct_framing() {
let container = DataValue::Container(vec![])