mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-17 03:02:28 +08:00
refactor: change ReverseStr to Reverse in strutil package
This commit is contained in:
@@ -209,8 +209,8 @@ func IsString(v interface{}) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReverseStr return string whose char order is reversed to the given string
|
// Reverse return string whose char order is reversed to the given string
|
||||||
func ReverseStr(s string) string {
|
func Reverse(s string) string {
|
||||||
r := []rune(s)
|
r := []rune(s)
|
||||||
for i, j := 0, len(r)-1; i < j; i, j = i+1, j-1 {
|
for i, j := 0, len(r)-1; i < j; i, j = i+1, j-1 {
|
||||||
r[i], r[j] = r[j], r[i]
|
r[i], r[j] = r[j], r[i]
|
||||||
|
|||||||
@@ -143,11 +143,11 @@ func TestIsString(t *testing.T) {
|
|||||||
assert.Equal(false, IsString([]string{}))
|
assert.Equal(false, IsString([]string{}))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReverseStr(t *testing.T) {
|
func TestReverse(t *testing.T) {
|
||||||
assert := internal.NewAssert(t, "TestReverseStr")
|
assert := internal.NewAssert(t, "TestReverse")
|
||||||
|
|
||||||
assert.Equal("cba", ReverseStr("abc"))
|
assert.Equal("cba", Reverse("abc"))
|
||||||
assert.Equal("54321", ReverseStr("12345"))
|
assert.Equal("54321", Reverse("12345"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrap(t *testing.T) {
|
func TestWrap(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user