blob: 2a8fc75df12c56bad31360afbf2693372a76cefe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
use cutie::Html;
#[test]
fn pares_homepage() {
let str = std::fs::read_to_string("tests/nyble.html").unwrap();
let _html = Html::parse(str);
}
fn test_roundtrip(raw: &str) {
let html = Html::parse(raw);
let string = html.to_string();
for (ln, (raw, round)) in raw.lines().zip(string.lines()).enumerate() {
if raw != round {
panic!("line {ln} differs!\n\traw: {raw}\n\ttrip: {round}")
}
}
}
#[test]
fn homepage_roundtrip() {
let str = std::fs::read_to_string("tests/nyble.html").unwrap();
test_roundtrip(&str);
}
#[test]
fn parses_grass() {
let str = std::fs::read_to_string("tests/touching_grass.html").unwrap();
let _html = Html::parse(str);
}
#[test]
fn grass_roundtrip() {
let str = std::fs::read_to_string("tests/touching_grass.html").unwrap();
test_roundtrip(&str);
}
|