feat: adding FromSlicePtrOr (#506)

This commit is contained in:
Samuel Berthe
2024-07-26 07:56:32 +02:00
committed by GitHub
parent aa609e4f47
commit cb150f5d38
3 changed files with 33 additions and 0 deletions

View File

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