use super::annotations;
#[test]
fn a_root_block_does_not_leak_into_the_first_key() {
let values =
"# @schema.root\n# title: Root\n# @schema.root\n# @schema\n# title: Key\n# @schema\na: 1\n";
let found = annotations(values, false).expect("reads");
let titles: Vec<(bool, &str)> = found
.iter()
.map(|a| (a.root, a.keywords["title"].as_str().expect("title")))
.collect();
assert_eq!(titles, vec![(true, "Root"), (false, "Key")]);
}
#[test]
fn an_alias_that_contains_itself_is_an_error() {
for values in ["node: &loop\n self: *loop\n", "a: &a\n b:\n c: *a\n"] {
let error = annotations(values, false).expect_err("fails");
assert!(
error.to_string().starts_with("yaml: anchor '")
&& error.to_string().ends_with("' value contains itself"),
"{error}"
);
}
}