about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2023-12-27 17:18:12 -0600
committergennyble <gen@nyble.dev>2023-12-27 17:18:12 -0600
commit4b4689ca0d086e11de52cbbf848fa0873acd7274 (patch)
tree9da09a0b93cf50b47dc771e4e6ff1a9cdaae14c1 /tests
parent54dec82cb8620937306e9a16b4b532cb52c7ee55 (diff)
downloadcutie-4b4689ca0d086e11de52cbbf848fa0873acd7274.tar.gz
cutie-4b4689ca0d086e11de52cbbf848fa0873acd7274.zip
rountrips!
Diffstat (limited to 'tests')
-rw-r--r--tests/nyble_pages.rs22
1 files changed, 22 insertions, 0 deletions
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);
+}