From 1fa37377aaa49c97c50f68294975778322dc3b8f Mon Sep 17 00:00:00 2001 From: Ankush Mondal <125016498+ankush1233@users.noreply.github.com> Date: Tue, 31 Oct 2023 12:30:57 +0530 Subject: [PATCH 1/3] Update token.rs added 3 more test cases for : is_start_tag(), is_any_start_tag(), is_text_token() --- src/html5/tokenizer/token.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/html5/tokenizer/token.rs b/src/html5/tokenizer/token.rs index 8f36cbdd1..5aa43e830 100644 --- a/src/html5/tokenizer/token.rs +++ b/src/html5/tokenizer/token.rs @@ -232,4 +232,36 @@ mod tests { let token = Token::Eof; assert_eq!(format!("{}", token), "EOF"); } + #[test] + fn test_is_start_tag() { + let token = Token::StartTag{ + name: "div".to_string(), + is_self_closing: false, + attributes: HashMap::new(), + }; + assert!(token.is_start_tag("div")); + assret!(!token.is_start_tag("span")); + } + #[test] + fn test_is_any_start_tag() { + let start_tag = Token::StartTag{ + name: "div".to_string(), + is_self_closing: false, + attributes: HashMap::new(), + }; + let other_tag = Token::Text("TestingText".to_string()); + assert!(start_tag.is_any_start_tag()); + assert!(!other_tag.is_any_start_tag()); + } + #[test] + fn test_is_text_token() { + let text_token = Token::Text("TestingText".to_string()); + let other_token = Token::StartTag{ + name: "div".to_string(), + is_self_closing: false, + attributes: HashMap::new(), + }; + assert!(text_token.is_text_token()); + assert!(!other_token.is_text_token()); + } } From e8d515cc5706a366ac0f520e3f92684f64ff0395 Mon Sep 17 00:00:00 2001 From: Ankush Mondal <125016498+ankush1233@users.noreply.github.com> Date: Tue, 31 Oct 2023 13:23:25 +0530 Subject: [PATCH 2/3] Update token.rs assret --> assert --- src/html5/tokenizer/token.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/html5/tokenizer/token.rs b/src/html5/tokenizer/token.rs index 5aa43e830..74e362630 100644 --- a/src/html5/tokenizer/token.rs +++ b/src/html5/tokenizer/token.rs @@ -240,7 +240,7 @@ mod tests { attributes: HashMap::new(), }; assert!(token.is_start_tag("div")); - assret!(!token.is_start_tag("span")); + assert!(!token.is_start_tag("span")); } #[test] fn test_is_any_start_tag() { From 887934ca020b09b45b999c670f872ab98bb16f6a Mon Sep 17 00:00:00 2001 From: Ankush Mondal <125016498+ankush1233@users.noreply.github.com> Date: Sat, 4 Nov 2023 13:43:23 +0530 Subject: [PATCH 3/3] Update token.rs --- src/html5/tokenizer/token.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/html5/tokenizer/token.rs b/src/html5/tokenizer/token.rs index 74e362630..df4bdcd62 100644 --- a/src/html5/tokenizer/token.rs +++ b/src/html5/tokenizer/token.rs @@ -232,6 +232,7 @@ mod tests { let token = Token::Eof; assert_eq!(format!("{}", token), "EOF"); } + #[test] fn test_is_start_tag() { let token = Token::StartTag{ @@ -242,6 +243,7 @@ mod tests { assert!(token.is_start_tag("div")); assert!(!token.is_start_tag("span")); } + #[test] fn test_is_any_start_tag() { let start_tag = Token::StartTag{ @@ -253,6 +255,7 @@ mod tests { assert!(start_tag.is_any_start_tag()); assert!(!other_tag.is_any_start_tag()); } + #[test] fn test_is_text_token() { let text_token = Token::Text("TestingText".to_string());