-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
47 lines (34 loc) · 881 Bytes
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import "testing"
func TestEncode(t *testing.T) {
text := "<script>"
expected := "%3Cscript%3E"
received := encode(text, 1)
if received != expected {
t.Fatalf("Excpected: %v, Received: %v", expected, received)
}
}
func TestEncodeWithDepth(t *testing.T) {
text := "<script>"
expected := "%253Cscript%253E"
received := encode(text, 2)
if received != expected {
t.Fatalf("Excpected: %v, Received: %v", expected, received)
}
}
func TestDecode(t *testing.T) {
text := "%3Cscript%3E"
expected := "<script>"
received := decode(text, 1)
if received != expected {
t.Fatalf("Excpected: %v, Received: %v", expected, received)
}
}
func TestDecodeWithDepth(t *testing.T) {
text := "%253Cscript%253E"
expected := "<script>"
received := decode(text, 2)
if received != expected {
t.Fatalf("Excpected: %v, Received: %v", expected, received)
}
}