Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Cases added to token.rs #212

Closed
wants to merge 4 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/html5/tokenizer/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
assert!(!token.is_start_tag("span"));
}
#[test]
fn test_is_any_start_tag() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a newline between each test and the one that follows?

Suggested change
}
#[test]
fn test_is_any_start_tag() {
}
#[test]
fn test_is_any_start_tag() {

Copy link
Author

@chamber909 chamber909 Nov 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohk i did it

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());
}
}
Loading