File tree Expand file tree Collapse file tree 3 files changed +112
-0
lines changed Expand file tree Collapse file tree 3 files changed +112
-0
lines changed Original file line number Diff line number Diff line change @@ -72,3 +72,28 @@ fn extract_class(node: &Handle) -> String {
7272 _ => String :: new ( )
7373 }
7474}
75+
76+ #[ cfg( test) ]
77+ mod test {
78+ #[ test]
79+ fn small_html ( ) {
80+ let ( head, body, class) = super :: extract_head_and_body (
81+ r#"<head><meta name="generator" content="rustdoc"></head><body class="rustdoc struct"><p>hello</p>"#
82+ ) . unwrap ( ) ;
83+ assert_eq ! ( head, r#"<meta name="generator" content="rustdoc">"# ) ;
84+ assert_eq ! ( body, "<p>hello</p>" ) ;
85+ assert_eq ! ( class, "rustdoc struct" ) ;
86+ }
87+
88+ // more of an integration test
89+ #[ test]
90+ fn parse_regex_html ( ) {
91+ let original = std:: fs:: read_to_string ( "benches/struct.CaptureMatches.html" ) . unwrap ( ) ;
92+ let expected_head = std:: fs:: read_to_string ( "tests/regex/head.html" ) . unwrap ( ) ;
93+ let expected_body = std:: fs:: read_to_string ( "tests/regex/body.html" ) . unwrap ( ) ;
94+ let ( head, body, class) = super :: extract_head_and_body ( & original) . unwrap ( ) ;
95+ assert_eq ! ( head, expected_head. trim( ) ) ;
96+ assert_eq ! ( & body, & expected_body. trim( ) ) ;
97+ assert_eq ! ( class, "rustdoc struct" ) ;
98+ }
99+ }
You can’t perform that action at this time.
0 commit comments