Skip to content

Commit

Permalink
tests: add a few more cases to test_comments
Browse files Browse the repository at this point in the history
Signed-off-by: ljedrz <[email protected]>
  • Loading branch information
ljedrz committed Dec 17, 2024
1 parent 7ea53c7 commit c02d7d5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions console/network/environment/src/helpers/sanitizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,23 @@ mod tests {
("hello world", "// hel\u{4141}lo\n"),
Sanitizer::parse_comments("// hel\u{4141}lo\nhello world").unwrap()
);
assert_eq!(
("hello world", "/* multi\n line comment\n*/\n"),
Sanitizer::parse_comments("/* multi\n line comment\n*/\nhello world").unwrap()
);
assert_eq!(
("hello world", "// multiple\n// line\n// comments\n"),
Sanitizer::parse_comments("// multiple\n// line\n// comments\nhello world").unwrap()
);
assert_eq!(
("hello world", "/* multi\n line comment\n*/\n/* and\n another\n one\n*/\n"),
Sanitizer::parse_comments("/* multi\n line comment\n*/\n/* and\n another\n one\n*/\nhello world")
.unwrap()
);
assert_eq!(
("hello world", "/* multi\n line comment\n*/\n// two single\n// line comments\n/* and\n another\n multi-liner\n*/\n"),
Sanitizer::parse_comments("/* multi\n line comment\n*/\n// two single\n// line comments\n/* and\n another\n multi-liner\n*/\nhello world").unwrap()
);
assert!(Sanitizer::parse_comments("// hel\x08lo\nhello world").is_err());
assert!(Sanitizer::parse_comments("// hel\u{2066}lo\nhello world").is_err());
assert!(Sanitizer::parse_comments("/* hel\x7flo */\nhello world").is_err());
Expand Down

0 comments on commit c02d7d5

Please sign in to comment.