Prove every tld row's type and displayed spelling, which 100 draws of 1438 cannot
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// writeFiles writes a data directory from a map of relative file name, extension
|
||||
@@ -837,6 +838,30 @@ func TestEveryTimezoneRowIsWellFormed(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestEveryTldRowSpellsItsKey scans the file rather than drawing: 100 draws leave
|
||||
// most of 1438 rows unrendered, and the register wraps a right-to-left label in bidi
|
||||
// marks that belong to its display, not to the label.
|
||||
func TestEveryTldRowSpellsItsKey(t *testing.T) {
|
||||
head, rows := shippedRows(t, "tld.tsv", "tld", "type", "unicode")
|
||||
types := map[string]bool{"country-code": true, "generic": true, "generic-restricted": true, "infrastructure": true, "sponsored": true}
|
||||
for i, r := range rows {
|
||||
key, kind, shown := r[head["tld"]], r[head["type"]], r[head["unicode"]]
|
||||
if !types[kind] {
|
||||
t.Errorf("tld.tsv line %d: %s is typed %q, which the register assigns no TLD", i+2, key, kind)
|
||||
}
|
||||
for _, c := range shown {
|
||||
if unicode.Is(unicode.Cf, c) {
|
||||
t.Errorf("tld.tsv line %d: %s displays %q, carrying the format character %U", i+2, key, shown, c)
|
||||
}
|
||||
}
|
||||
if idn := strings.HasPrefix(key, ".xn--"); idn && shown == key {
|
||||
t.Errorf("tld.tsv line %d: the IDN %s displays its A-label, not a Unicode form", i+2, key)
|
||||
} else if !idn && shown != key {
|
||||
t.Errorf("tld.tsv line %d: the ASCII TLD %s displays %q", i+2, key, shown)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// shippedRows reads a shipped misc TSV as the loader does, proving it names the
|
||||
// columns asked for and that every row fills them.
|
||||
func shippedRows(t *testing.T, file string, want ...string) (map[string]int, [][]string) {
|
||||
|
||||
Reference in New Issue
Block a user