-
Notifications
You must be signed in to change notification settings - Fork 7
/
utils_test.go
42 lines (28 loc) · 751 Bytes
/
utils_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
32
33
34
35
36
37
38
39
40
41
42
package xss
import (
"testing"
// "fmt"
)
func TestSpaceIndex(t *testing.T) {
x := "<a href=\"https://example.com\">"
index := spaceIndex(x)
if index != 2 {
t.Errorf("index err %+v %d", x, index)
}
// t.Logf("space index %+v", index)
}
func TestStripBlankChar(t *testing.T) {
x := "!---a\u0000\u0001\u0002\u0003\r\n b----" + string(rune(127)) + string(rune(9))
result := stripBlankChar(x)
if result != "!---a\r\n b----" {
t.Errorf("stripBlankChar err %s", result)
}
}
func TestStripCommentTag(t *testing.T) {
x := "<a><!-------asfasf ------>sadfasdfsadf</a>"
result := stripCommentTag(x)
if result != "<a>sadfasdfsadf</a>" {
t.Errorf("stripCommentTag err %s", result)
}
// t.Logf("stripCommentTag %+v", result)
}