Oregami
Repositories/oxedyne/fe2o3

oxedyne/fe2o3/fe2o3_jdat/tests/decode_cases.rs

1.6 KiB, 1 run

created by r1870400018:67309, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1//! The cases rc's Opus QA of 2026-10-05 wrote against the text decoder (U0-5, D-20261005-12): each is
2//! text that must be refused, or must read, and the fixture holds the expectation beside the text.
3//! Every case the QA wrote now has an answer, the whitespace in a kind label (read as a space) and
4//! `(f64|1e400)` (refused) among them, and the U0-8 cases for comments, a BOM and whole-number kinds.
5
6use oxedyne_fe2o3_jdat::prelude::*;
7
8#[test]
9fn test_the_qa_cases_are_read_or_refused_00() {
10 let text = include_str!("fixtures/jdat_qa_cases.json");
11 let cases: serde_json::Value = serde_json::from_str(text).unwrap_or_default();
12 let cases = cases.as_array().cloned().unwrap_or_default();
13 assert!(cases.len() > 100, "the fixture holds {} cases", cases.len());
14 let mut wrong = Vec::new();
15 for (i, c) in cases.iter().enumerate() {
16 let s = c["s"].as_str().unwrap_or_default();
17 let want = c["want"].as_str().unwrap_or_default();
18 let tag = c["tag"].as_str().unwrap_or_default();
19 match (want, Dat::decode_string(s)) {
20 ("read", Err(e)) => wrong.push(format!(
21 "#{} {} {:?} should read, and was refused: {}", i, tag, s, e.plain())),
22 ("refuse", Ok(d)) => wrong.push(format!(
23 "#{} {} {:?} should be refused, and became {}", i, tag, s, d)),
24 _ => (),
25 }
26 }
27 for w in &wrong {
28 println!("{}", w);
29 }
30 assert!(wrong.is_empty(), "{} of {} cases went the wrong way, the first being: {}",
31 wrong.len(), cases.len(), wrong.first().cloned().unwrap_or_default());
32}