forked from agl/xmpp-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui_test.go
38 lines (33 loc) · 825 Bytes
/
ui_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
package main
import (
"bytes"
"testing"
)
var escapingTests = []string{
"",
"foo",
"foo\\",
"foo\\x01",
"العربية",
}
func TestEscaping(t *testing.T) {
for _, test := range escapingTests {
escaped := escapeNonASCII(test)
unescaped, err := unescapeNonASCII(escaped)
if err != nil {
t.Errorf("Error unescaping '%s' (from '%s')", escaped, test)
continue
}
if unescaped != test {
t.Errorf("Unescaping didn't return the original value: '%s' -> '%s' -> '%s'", test, escaped, unescaped)
}
}
}
func TestHTMLStripping(t *testing.T) {
raw := []byte("<hr>This is some <font color='green'>html</font><br />.")
exp := []byte("This is some html.")
res := stripHTML(raw)
if !bytes.Equal(res, exp) {
t.Errorf("HTML wasn't properly stripped: '%s' -> '%s' but expected '%s'", raw, res, exp)
}
}