1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
11 var idnaTestCases = [...]struct {
16 {"xn--bcher-kva", "bücher"},
19 {"foo--xn--bar.org", "foo--xn--bar.org"},
20 {"golang.org", "golang.org"},
21 {"example.xn--p1ai", "example.рф"},
22 {"xn--czrw28b.tw", "商業.tw"},
23 {"www.xn--mller-kva.de", "www.müller.de"},
26 func TestIDNA(t *testing.T) {
27 for _, tc := range idnaTestCases {
28 if a, err := ToASCII(tc.unicode); err != nil {
29 t.Errorf("ToASCII(%q): %v", tc.unicode, err)
30 } else if a != tc.ascii {
31 t.Errorf("ToASCII(%q): got %q, want %q", tc.unicode, a, tc.ascii)
34 if u, err := ToUnicode(tc.ascii); err != nil {
35 t.Errorf("ToUnicode(%q): %v", tc.ascii, err)
36 } else if u != tc.unicode {
37 t.Errorf("ToUnicode(%q): got %q, want %q", tc.ascii, u, tc.unicode)
42 // TODO(nigeltao): test errors, once we've specified when ToASCII and ToUnicode