mirror of
https://github.com/samber/lo.git
synced 2025-09-26 20:11:13 +08:00
26 lines
390 B
Go
26 lines
390 B
Go
package lo
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestToPtr(t *testing.T) {
|
|
is := assert.New(t)
|
|
|
|
result1 := ToPtr[[]int]([]int{1, 2})
|
|
|
|
is.Equal(*result1, []int{1, 2})
|
|
}
|
|
|
|
func TestToSlicePtr(t *testing.T) {
|
|
is := assert.New(t)
|
|
|
|
str1 := "foo"
|
|
str2 := "bar"
|
|
result1 := ToSlicePtr[string]([]string{str1, str2})
|
|
|
|
is.Equal(result1, []*string{&str1, &str2})
|
|
}
|