package deviceconfig import ( "strings" "testing" ) func TestDisplayName(t *testing.T) { for _, name := range []string{"", "客厅陪伴设备", strings.Repeat("名", 32), "卧室 · EchoEar"} { if !ValidDisplayName(name) { t.Fatalf("rejected %q", name) } } for _, name := range []string{strings.Repeat("名", 33), " leading", "trailing ", "\u3000名称", "a\x00b", "a\nb", "a\u0085b", string([]byte{0xff})} { if ValidDisplayName(name) { t.Fatalf("accepted %q", name) } } }