MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / assert_canonical

Function assert_canonical

atomic-canonical/tests/jcs_vectors.rs:32–48  ·  view source on GitHub ↗

Parse the fixture's input the way any caller receiving JSON does, canonicalize it, and require the exact bytes.

(name: &str)

Source from the content-addressed store, hash-verified

30/// Parse the fixture's input the way any caller receiving JSON does, canonicalize
31/// it, and require the exact bytes.
32fn assert_canonical(name: &str) {
33 let f = fixture(name);
34 let text = f["input"]
35 .as_str()
36 .expect("fixture carries an input string");
37 let value: Value = serde_json::from_str(text).expect("fixture input is valid JSON");
38 let expected = f["expect"]["canonical"]
39 .as_str()
40 .expect("fixture expects a canonical form");
41 assert_eq!(
42 jcs::canonicalize(&value),
43 expected,
44 "{name} ({}): {}",
45 f["vector"].as_str().unwrap_or("?"),
46 f["divergence"].as_str().unwrap_or("")
47 );
48}
49
50#[test]
51fn number_decimal_below_exponent_threshold() {

Calls 2

fixtureFunction · 0.70
as_strMethod · 0.45

Tested by

no test coverage detected