You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
737 B
23 lines
737 B
package user
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestNormalizeFeedbackMessage(t *testing.T) {
|
|
if got, reason := normalizeFeedbackMessage(" 耳机连不上 "); reason != "" || got != "耳机连不上" {
|
|
t.Fatalf("trim: got %q reason %q", got, reason)
|
|
}
|
|
if _, reason := normalizeFeedbackMessage(" "); reason == "" {
|
|
t.Fatal("blank should be rejected")
|
|
}
|
|
long := strings.Repeat("字", feedbackMessageMax+1)
|
|
if _, reason := normalizeFeedbackMessage(long); reason == "" {
|
|
t.Fatal("overlong should be rejected")
|
|
}
|
|
edge := strings.Repeat("a", feedbackMessageMax)
|
|
if got, reason := normalizeFeedbackMessage(edge); reason != "" || got != edge {
|
|
t.Fatalf("max length should pass, reason %q len %d", reason, len(got))
|
|
}
|
|
}
|
|
|