Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug for DeleteWhiteSpace when str is other utf8 string, eg. chinese #29

Open
si9ma opened this issue Jul 25, 2020 · 0 comments
Open

Bug for DeleteWhiteSpace when str is other utf8 string, eg. chinese #29

si9ma opened this issue Jul 25, 2020 · 0 comments

Comments

@si9ma
Copy link

si9ma commented Jul 25, 2020

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant