-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
31 lines (29 loc) · 1.14 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"slices"
"testing"
)
func TestCheckHTML(t *testing.T) {
var tests = []struct {
input string
want []string
}{
{"", []string{}},
{"simple text", []string{}},
{"<start>", []string{errStartWithoutEnd("start")}},
{"<start></end>", []string{errStartEndMismatch("start", "end")}},
{"</end>", []string{errEndWithoutStart("end")}},
{"</end><start>", []string{errEndWithoutStart("end"), errStartWithoutEnd("start")}},
{"<a><label></a>", []string{errStartEndMismatch("label", "a"), errStartWithoutEnd("a")}},
{"<a><label>some label</label>some text<tag></a>", []string{errStartEndMismatch("tag", "a"), errStartWithoutEnd("a")}},
{"<img src='foo'>image here</img>", []string{}},
{"<img src=\"img\">image<br/>here</img>", []string{}},
{"<img src=\"img\">image<br>here</img>", []string{errStartEndMismatch("br", "img"), errStartWithoutEnd("img")}},
{"text1<tag>text2</img>text3</tag>text4", []string{errStartEndMismatch("tag", "img"), errEndWithoutStart("tag")}},
}
for _, test := range tests {
if got := checkHTML(test.input); !slices.Equal(got, test.want) {
t.Errorf("want: %q, got: %q", test.want, got)
}
}
}