Parse the fixture's input the way any caller receiving JSON does, canonicalize it, and require the exact bytes.
(name: &str)
| 30 | /// Parse the fixture's input the way any caller receiving JSON does, canonicalize |
| 31 | /// it, and require the exact bytes. |
| 32 | fn 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] |
| 51 | fn number_decimal_below_exponent_threshold() { |
no test coverage detected