-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpointers_test.go
More file actions
45 lines (40 loc) · 680 Bytes
/
pointers_test.go
File metadata and controls
45 lines (40 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package underscore_test
import (
"reflect"
"testing"
u "github.com/rjNemo/underscore"
"github.com/stretchr/testify/assert"
)
func TestPointers(t *testing.T) {
variable := 123
var object struct{}
cases := []struct {
value any
expected bool
}{
{
value: u.ToPointer("myValue"),
expected: true,
},
{
value: u.ToPointer(variable),
expected: true,
},
{
value: &variable,
expected: true,
},
{
value: nil,
expected: false,
},
{
value: u.ToPointer(object),
expected: true,
},
}
for _, c := range cases {
got := (reflect.ValueOf(c.value).Kind() == reflect.Ptr)
assert.Equal(t, c.expected, got)
}
}