From 2ac9a1fe35c03358de502db85c0b4633f072a90e Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Mon, 29 Nov 2021 19:26:36 +0100 Subject: refactor: make tests independent of TokenizerOpts::default() --- src/tokenizer/mod.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/tokenizer/mod.rs b/src/tokenizer/mod.rs index 0a0f7af..2d5e1ed 100644 --- a/src/tokenizer/mod.rs +++ b/src/tokenizer/mod.rs @@ -2267,15 +2267,19 @@ mod test { assert_eq!(s, Some("yx".into())); } - #[test] - fn check_lines() { - let opts = TokenizerOpts { + fn opts() -> TokenizerOpts { + TokenizerOpts { exact_errors: false, discard_bom: true, profile: false, initial_state: None, last_start_tag_name: None, - }; + } + } + + #[test] + fn check_lines() { + let opts = opts(); let vector = vec![ String::from("\n"), String::from("\n"), @@ -2304,13 +2308,7 @@ mod test { #[test] fn check_lines_with_new_line() { - let opts = TokenizerOpts { - exact_errors: false, - discard_bom: true, - profile: false, - initial_state: None, - last_start_tag_name: None, - }; + let opts = opts(); let vector = vec![ String::from("\r\n"), String::from("\r\n"), @@ -2340,7 +2338,7 @@ mod test { #[test] #[cfg(not(feature = "named-entities"))] fn named_entities() { - let opts = TokenizerOpts::default(); + let opts = opts(); let vector = vec![String::from("&\r\n"), String::from("&aamp;\r\n")]; let expected = vec![(3, Token::CharacterTokens("&\n&aamp;\n".into()))]; let results = tokenize(vector, opts); @@ -2350,7 +2348,7 @@ mod test { #[test] #[cfg(feature = "named-entities")] fn named_entities() { - let opts = TokenizerOpts::default(); + let opts = opts(); let vector = vec![String::from("&\r\n"), String::from("&aamp;\r\n")]; let expected = vec![ (3, CharacterTokens("&\n".into())), -- cgit v1.2.3