goutils
goutils copied to clipboard
Bug for DeleteWhiteSpace when str is other utf8 string, eg. chinese
func TestDeleteWhiteSpace(t *testing.T) {
// Test 1
str := " a b c "
out := "abc"
if x := DeleteWhiteSpace(str); x != out {
t.Errorf("IndexOf(%v) = %v, want %v", str, x, out)
}
// Test 2
str = " "
out = ""
if x := DeleteWhiteSpace(str); x != out {
t.Errorf("IndexOf(%v) = %v, want %v", str, x, out)
}
// Test 3
str = " 测试 测试 测试 "
out = "测试测试测试"
if x := DeleteWhiteSpace(str); x != out {
t.Errorf("IndexOf(%v) = %v, want %v", str, x, out)
}
}
$ go test
--- FAIL: TestDeleteWhiteSpace (0.00s)
stringutils_test.go:157: IndexOf( 测试 测试 测试 ) = æµ�è¯�æµ�è¯�æµ�è¯�, want 测试测试测试
FAIL
exit status 1
FAIL _/Users/xxxx/Github/goutils 0.371s