//! LOC carriage (WAI `extensions/loc-carriage.md`): the committed corpus //! `wai/live-conformance/loc/vectors.json` regenerates byte for byte from the H.265 stream it //! takes its access units from, every object and refusal in it holds, and the extension's §6 //! lists exactly the codes [`LocRefusal::all`] gives. The corpus lives beside this crate in //! the monorepo; if it cannot be read the test fails, it never passes on nothing. use joule_moq::loc::{corpus, LocRefusal}; const WAI: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../../../wai/"); fn committed() -> String { std::fs::read_to_string(format!("{WAI}live-conformance/loc/vectors.json")).expect("the LOC corpus") } #[test] fn the_corpus_regenerates() { let hevc = std::fs::read(format!("{WAI}format-probe-conformance/ext/hevc/base_64x64.265")).expect("the H.265 vector"); assert_eq!(corpus::generate(&hevc).expect("generates"), committed(), "run `cargo run -p joule-moq --example loc_vectors -- gen`"); } #[test] fn every_vector_holds() { let doc: serde_json::Value = serde_json::from_str(&committed()).expect("JSON"); assert!(doc["objects"].as_array().is_some_and(|a| a.len() >= 6)); let fails = corpus::verify(&doc); assert!(fails.is_empty(), "{}", fails.join("\n")); } #[test] fn the_extension_lists_the_codes() { let text = std::fs::read_to_string(format!("{WAI}extensions/loc-carriage.md")).expect("the extension"); let at = text.find("\n## 6. Refusals").expect("a §6"); let end = text[at + 1..].find("\n## ").map_or(text.len(), |e| at + 1 + e); let listed: Vec<&str> = text[at..end].lines().filter(|l| l.starts_with("| `")).filter_map(|l| l.split('`').nth(1)).collect(); let want: Vec<&str> = LocRefusal::all().iter().map(|r| r.code()).collect(); assert_eq!(listed, want); }