package chat import ( "strings" "testing" ) func TestPasswordContract(t *testing.T) { for _, value := range []string{"", "too-short", strings.Repeat(" ", 12), strings.Repeat("x", 129), strings.Repeat("x", 12) + string([]byte{0xff})} { if validPassword(value) { t.Fatal("invalid password accepted") } } for _, value := range []string{strings.Repeat("🔑", 128), "valid:password", " password with spaces "} { if !validPassword(value) { t.Fatal("valid Unicode password rejected") } } }