-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
32 lines (29 loc) · 921 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
package main
import "testing"
func TestToASCII(t *testing.T) {
tt := map[string]bool{
"example.com": true,
"example.com.": true,
".example.com": true,
"www.müller.example.com": true,
"target.example.com": false,
"example.target.example.com": false,
".": false,
"": false,
".com": false,
"example-.com": false,
"-example.com": false,
"*.example.com": false,
"example.net": false,
"invalid_domain.com": false,
}
for domain, ok := range tt {
_, err := ToASCII(domain, []string{"example.com"}, []string{"target.example.com"})
if ok && err != nil {
t.Errorf("ToASCII(%q) = %v; want nil", domain, err)
}
if !ok && err == nil {
t.Errorf("ToASCII(%q) = nil; want error", domain)
}
}
}