MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / exception_handling

Function exception_handling

nodedb-codec/src/alp.rs:500–520  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

498
499 #[test]
500 fn exception_handling() {
501 // Mix of ALP-encodable and non-encodable values.
502 let mut values = vec![23.5, 99.9, 100.1, 50.0];
503 values.push(f64::NAN);
504 values.push(f64::INFINITY);
505 values.push(f64::NEG_INFINITY);
506 values.push(std::f64::consts::PI); // Irrational — likely exception.
507
508 let encoded = encode(&values);
509 let decoded = decode(&encoded).unwrap();
510
511 for (i, (a, b)) in values.iter().zip(decoded.iter()).enumerate() {
512 assert_eq!(
513 a.to_bits(),
514 b.to_bits(),
515 "mismatch at {i}: {a} ({:016x}) vs {b} ({:016x})",
516 a.to_bits(),
517 b.to_bits()
518 );
519 }
520 }
521
522 #[test]
523 fn all_exceptions() {

Callers

nothing calls this directly

Calls 4

encodeFunction · 0.70
decodeFunction · 0.70
pushMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected