use en16931::{ATTRIBUTION, Invoice, validate};
fn flat(s: &str) -> String {
s.split_whitespace().collect::<Vec<_>>().join(" ")
}
#[test]
fn attribution_is_carried_everywhere_it_is_required() {
let rendered = validate(&Invoice::default()).to_string();
assert!(
flat(&rendered).contains(&flat(ATTRIBUTION)),
"a validation report must carry the notice:\n{rendered}"
);
let readme = include_str!("../README.md");
assert!(
flat(readme).contains(&flat(ATTRIBUTION)),
"README.md must carry the notice verbatim, not a paraphrase"
);
assert!(
readme.contains("### Attribution"),
"README.md must keep its Attribution section"
);
}
#[test]
fn the_notice_is_canonical_not_merely_present() {
assert_eq!(
ATTRIBUTION,
flat(ATTRIBUTION),
"the source of truth must be canonical — copies may wrap, this may not"
);
assert!(!ATTRIBUTION.contains('\n'));
assert_eq!(ATTRIBUTION.trim(), ATTRIBUTION);
}
#[test]
fn the_notice_states_what_the_agreement_requires() {
assert!(ATTRIBUTION.contains("implementation of the EN 16931-1 semantic data model"));
assert!(ATTRIBUTION.contains("© CEN"));
assert!(ATTRIBUTION.contains("2018 CEN–EC licence agreement"));
}
#[test]
fn even_a_clean_report_carries_it() {
let report = validate(&Invoice::default());
assert!(!report.is_valid(), "sanity: the empty invoice has findings");
let empty = en16931::validation::validate_with(&Invoice::default(), &[]);
assert_eq!(empty.findings().len(), 0);
assert!(
flat(&empty.to_string()).contains(&flat(ATTRIBUTION)),
"a report with no findings must still carry the notice:\n{empty}"
);
}