forked from Plantiga/go-wireless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
54 lines (49 loc) · 1.4 KB
/
config_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
48
49
50
51
52
53
54
package wireless
import (
"strconv"
"testing"
)
func TestConfigRoundTripPlain(t *testing.T) {
tt := "hello world"
in := configWriteString(tt)
out, err := configParseString(in)
if err != nil {
t.Errorf("unexpected error in configParseString, %s", err)
}
if out != tt {
t.Errorf("configParseString returned %s (wanted %s)", strconv.QuoteToASCII(out), strconv.QuoteToASCII(tt))
}
}
func TestConfigRoundTripBackslash(t *testing.T) {
tt := `hello\world`
in := configWriteString(tt)
out, err := configParseString(in)
if err != nil {
t.Errorf("unexpected error in configParseString, %s", err)
}
if out != tt {
t.Errorf("configParseString returned %s (wanted %s)", strconv.QuoteToASCII(out), strconv.QuoteToASCII(tt))
}
}
func TestConfigRoundTripTab(t *testing.T) {
tt := "hello\tworld"
in := configWriteString(tt)
out, err := configParseString(in)
if err != nil {
t.Errorf("unexpected error in configParseString, %s", err)
}
if out != tt {
t.Errorf("configParseString returned %s (wanted %s)", strconv.QuoteToASCII(out), strconv.QuoteToASCII(tt))
}
}
func TestConfigRoundTripUnicode(t *testing.T) {
tt := "Ë \" ' \\ 😅"
in := configWriteString(tt)
out, err := configParseString(in)
if err != nil {
t.Errorf("unexpected error in configParseString, %s", err)
}
if out != tt {
t.Errorf("configParseString returned %s (wanted %s)", strconv.QuoteToASCII(out), strconv.QuoteToASCII(tt))
}
}