MCPcopy
hub / github.com/spf13/cast / TestIndirect

Function TestIndirect

indirect_test.go:14–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestIndirect(t *testing.T) {
15 c := qt.New(t)
16
17 x := 13
18 y := &x
19 z := &y
20
21 var ptr *string
22 var ptrptr **string
23
24 var i any
25
26 var n = int(13)
27 var i2 any = n
28
29 var i3 any = &n
30
31 var b *bool
32 var i4 any = b
33
34 testCases := []struct {
35 input any
36 expected any
37 expectedOk bool
38 }{
39 {x, 13, false},
40 {y, 13, true},
41 {z, 13, true},
42 {ptr, nil, true},
43 {ptrptr, nil, true},
44 {i, nil, false},
45 {&i, nil, true},
46 {i2, 13, false},
47 {&i2, 13, true},
48 {i3, 13, true},
49 {&i3, 13, true},
50 {i4, nil, true},
51 {&i4, nil, true},
52 {nil, nil, false},
53 }
54
55 for _, testCase := range testCases {
56 // TODO: remove after minimum Go version is >=1.22
57 testCase := testCase
58
59 t.Run("", func(t *testing.T) {
60 v, ok := indirect(testCase.input)
61
62 c.Assert(v, qt.Equals, testCase.expected)
63 c.Assert(ok, qt.Equals, testCase.expectedOk)
64 })
65 }
66}

Callers

nothing calls this directly

Calls 1

indirectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…