Skip to content

Commit b3b90f1

Browse files
committed
Use exact comparisons instead of round-tripping through the parser
This makes the tests independent of the parser we use, although we may need to update our known-good tests whenever we switch parsers.
1 parent d193e10 commit b3b90f1

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/utils/html.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,6 @@ fn extract_class(node: &Handle) -> String {
7575

7676
#[cfg(test)]
7777
mod test {
78-
use super::*;
79-
80-
fn round_trip(a: &str) -> String {
81-
let parser = parse_document(RcDom::default(), ParseOpts::default());
82-
stringify(parser.one(a).document)
83-
}
84-
fn mostly_equal(a: &str, b: &str) -> bool {
85-
round_trip(a.trim()).trim() == round_trip(b.trim()).trim()
86-
}
87-
8878
#[test]
8979
fn small_html() {
9080
let (head, body, class) = super::extract_head_and_body(
@@ -102,8 +92,8 @@ mod test {
10292
let expected_head = std::fs::read_to_string("tests/regex/head.html").unwrap();
10393
let expected_body = std::fs::read_to_string("tests/regex/body.html").unwrap();
10494
let (head, body, class) = super::extract_head_and_body(&original).unwrap();
105-
assert!(mostly_equal(&head, &expected_head));
106-
assert!(mostly_equal(&body, &expected_body));
95+
assert_eq!(head, expected_head.trim());
96+
assert_eq!(&body, &expected_body.trim());
10797
assert_eq!(class, "rustdoc struct");
10898
}
10999
}

0 commit comments

Comments
 (0)