From 4b4689ca0d086e11de52cbbf848fa0873acd7274 Mon Sep 17 00:00:00 2001 From: gennyble Date: Wed, 27 Dec 2023 17:18:12 -0600 Subject: rountrips! --- tests/nyble_pages.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/nyble_pages.rs') diff --git a/tests/nyble_pages.rs b/tests/nyble_pages.rs index 14ca1cc..2c99bc2 100644 --- a/tests/nyble_pages.rs +++ b/tests/nyble_pages.rs @@ -6,8 +6,30 @@ fn pares_homepage() { 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); +} -- cgit 1.4.1-3-g733a5