Skip to content

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

@si9ma

Description

@si9ma
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions