aboutsummaryrefslogtreecommitdiff
path: root/tests/test_spans.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_spans.rs')
-rw-r--r--tests/test_spans.rs34
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/test_spans.rs b/tests/test_spans.rs
index a33c2b3..33f5d11 100644
--- a/tests/test_spans.rs
+++ b/tests/test_spans.rs
@@ -44,12 +44,42 @@ fn annotate(html: &str, labels: Vec<(Range<usize>, impl AsRef<str>)>) -> String
}
#[test]
+fn start_tag_span() {
+ let html = "<x> <xyz> <xyz > <xyz/>";
+ let mut labels = Vec::new();
+ for token in tokenizer(html) {
+ if let Token::StartTag(tag) = token {
+ labels.push((tag.span, ""));
+ }
+ }
+ assert_snapshot!(annotate(html, labels), @r###"
+ <x> <xyz> <xyz > <xyz/>
+ ^^^ ^^^^^ ^^^^^^^ ^^^^^^
+ "###);
+}
+
+#[test]
+fn end_tag_span() {
+ let html = "</x> </xyz> </xyz > </xyz/>";
+ let mut labels = Vec::new();
+ for token in tokenizer(html) {
+ if let Token::EndTag(tag) = token {
+ labels.push((tag.span, ""));
+ }
+ }
+ assert_snapshot!(annotate(html, labels), @r###"
+ </x> </xyz> </xyz > </xyz/>
+ ^^^^ ^^^^^^ ^^^^^^^^ ^^^^^^^
+ "###);
+}
+
+#[test]
fn start_tag_name_span() {
let html = "<x> <xyz> <xyz > <xyz/>";
let mut labels = Vec::new();
for token in tokenizer(html) {
if let Token::StartTag(tag) = token {
- labels.push((tag.name_span, ""));
+ labels.push((tag.name_span(), ""));
}
}
assert_snapshot!(annotate(html, labels), @r###"
@@ -64,7 +94,7 @@ fn end_tag_name_span() {
let mut labels = Vec::new();
for token in tokenizer(html) {
if let Token::EndTag(tag) = token {
- labels.push((tag.name_span, ""));
+ labels.push((tag.name_span(), ""));
}
}
assert_snapshot!(annotate(html, labels), @r###"