use wikrs::diag::Severity;
use wikrs::diff::{self, Bucket};
fn run(wikitext: &str) -> (String, bool) {
let parsed = wikrs::parser::parse(wikitext);
let text = wikrs::render::plain(&parsed.nodes);
let has_unsupported = parsed
.diagnostics
.iter()
.any(|d| d.severity == Severity::Unsupported);
(text, has_unsupported)
}
#[test]
fn clean_prose_is_faithful_against_superset_truth() {
let (text, unsupported) = run("The '''quick''' brown [[fox]] jumps over the lazy dog. \
It was a [[bright]] cold day in April.");
assert!(!unsupported, "clean prose should not be flagged");
let truth = "The quick brown fox jumps over the lazy dog. It was a bright cold \
day in April. Foxes are small carnivorous mammals.";
assert_eq!(diff::classify(&text, truth, unsupported), Bucket::Faithful);
}
#[test]
fn unsupported_construct_lands_in_reported() {
let (text, unsupported) = run("<table><tr><td>cell</td></tr></table>");
assert!(unsupported, "an HTML table should be flagged Unsupported");
assert_eq!(diff::classify(&text, "cell", unsupported), Bucket::Reported);
}
#[test]
fn silent_disagreement_is_divergent() {
let (text, unsupported) = run("Paris is the capital of France and a major city.");
assert!(!unsupported);
let truth = "Berlin is the largest city and capital of Germany.";
assert_eq!(diff::classify(&text, truth, unsupported), Bucket::Divergent);
}