30 lines
790 B
Go
30 lines
790 B
Go
package whois
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeQueryDomainInputIDN(t *testing.T) {
|
|
got, err := normalizeQueryDomainInput("\u4f8b\u5b50.\u6d4b\u8bd5")
|
|
if err != nil {
|
|
t.Fatalf("normalizeQueryDomainInput() error: %v", err)
|
|
}
|
|
if got != "xn--fsqu00a.xn--0zwm56d" {
|
|
t.Fatalf("unexpected idn ascii result: %q", got)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeQueryDomainInputASN(t *testing.T) {
|
|
got, err := normalizeQueryDomainInput("13335")
|
|
if err != nil {
|
|
t.Fatalf("normalizeQueryDomainInput() error: %v", err)
|
|
}
|
|
if got != "AS13335" {
|
|
t.Fatalf("unexpected asn normalization result: %q", got)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeLookupDomainInputRejectASN(t *testing.T) {
|
|
if _, err := normalizeLookupDomainInput("AS13335"); err == nil {
|
|
t.Fatal("expected normalizeLookupDomainInput to reject asn")
|
|
}
|
|
}
|