use diml::{Node, parse};
const BASIC_EXAMPLE: &str = include_str!("basic.diml");
#[test]
fn _0001() {
let input = BASIC_EXAMPLE;
let root = parse(input).unwrap();
assert_eq!(6, root.children().count());
let names = root.children().map(Node::name).collect::<Vec<&str>>();
assert_eq!(
vec![
"comment",
"company",
"domains",
"tutorial",
"author",
"published"
],
names
);
let values = root
.children()
.map(|node| node.content().trim())
.collect::<Vec<&str>>();
assert_eq!(
vec![
"A sample DIML file",
"Engos Software",
"",
"",
"Dariusz Depta",
"true"
],
values
);
let domain_names = root
.first_with_name("domains")
.unwrap()
.children()
.map(Node::name)
.collect::<Vec<&str>>();
assert_eq!(vec!["", "", "", ""], domain_names);
let domain_values = root
.first_with_name("domains")
.unwrap()
.children()
.map(|node| node.content().trim())
.collect::<Vec<&str>>();
assert_eq!(
vec![
"business analysis",
"software development",
"data engineering",
"devops"
],
domain_values
);
assert_eq!(
"Brilliant!",
root.first_with_name("tutorial")
.unwrap()
.first_with_name("diml")
.unwrap()
.first_with_name("type")
.unwrap()
.content()
.trim()
);
}