1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-11 16:22:26 +08:00

Add ToPointer,ToSlicePointer,ToSlice func (#36)

* Add ToPointer func

* Add ToSlice and ToSlicePointer func

Co-authored-by: zhanghu <305835360@qq.com>
This commit is contained in:
tangqiu0205
2022-07-05 19:15:54 +08:00
committed by GitHub
parent fc0e104591
commit bab0a27e40
4 changed files with 48 additions and 0 deletions

View File

@@ -583,3 +583,21 @@ func TestLastIndexOf(t *testing.T) {
assert.Equal(1, LastIndexOf(arr, "a"))
assert.Equal(-1, LastIndexOf(arr, "d"))
}
func TestToSlice(t *testing.T) {
assert := internal.NewAssert(t, "TestToSlice")
str1 := "a"
str2 := "b"
assert.Equal([]string{"a"}, ToSlice(str1))
assert.Equal([]string{"a", "b"}, ToSlice(str1, str2))
}
func TestToSlicePointer(t *testing.T) {
assert := internal.NewAssert(t, "TestToSlicePointer")
str1 := "a"
str2 := "b"
assert.Equal([]*string{&str1}, ToSlicePointer(str1))
assert.Equal([]*string{&str1, &str2}, ToSlicePointer(str1, str2))
}