feat: add FromSlicePtr (#217)

* feat: add FromSlicePtr

* Update README.md

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
This commit is contained in:
Masakazu Ohtsuka
2024-07-26 14:51:40 +09:00
committed by GitHub
parent df28bdd91b
commit aa609e4f47
3 changed files with 40 additions and 0 deletions

View File

@@ -121,6 +121,16 @@ func TestToSlicePtr(t *testing.T) {
is.Equal(result1, []*string{&str1, &str2})
}
func TestFromSlicePtr(t *testing.T) {
is := assert.New(t)
str1 := "foo"
str2 := "bar"
result1 := FromSlicePtr([]*string{&str1, &str2, nil})
is.Equal(result1, []string{str1, str2, ""})
}
func TestToAnySlice(t *testing.T) {
t.Parallel()
is := assert.New(t)