package account import ( "strings" "testing" ) func TestValidHandle(t *testing.T) { t.Parallel() for in, want := range map[string]bool{ "alice": true, "a_1": true, strings.Repeat("a", 20): true, "ab": false, strings.Repeat("a", 21): false, "Alice": false, "a.b": false, "jörg": false, } { if got := ValidHandle(in); got != want { t.Errorf("ValidHandle(%q) = %v", in, got) } } if got := NormalizeHandle(" @Alice "); got != "alice" { t.Errorf("NormalizeHandle = %q", got) } } func TestCleanDisplayName(t *testing.T) { t.Parallel() tests := []struct{ in, want string }{ {" Max Mustermann ", "Max Mustermann"}, {"Jörg 🌻", "Jörg 🌻"}, {"a​b\x07c", "abc"}, {strings.Repeat("ä", 40), strings.Repeat("ä", 32)}, } for _, tt := range tests { if got := CleanDisplayName(tt.in); got != tt.want { t.Errorf("CleanDisplayName(%q) = %q, erwartet %q", tt.in, got, tt.want) } } }