MCPcopy Create free account
hub / github.com/stretchr/objx / TestConversionJSONInt

Function TestConversionJSONInt

map_test.go:93–115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func TestConversionJSONInt(t *testing.T) {
94 jsonString :=
95 `{
96 "a": 1,
97 "b": {
98 "data": 1
99 },
100 "c": [1],
101 "d": [[1]]
102 }`
103 m, err := objx.FromJSON(jsonString)
104
105 assert.Nil(t, err)
106 require.NotNil(t, m)
107 assert.Equal(t, 1, m.Get("a").Int())
108 assert.Equal(t, 1, m.Get("b.data").Int())
109
110 assert.True(t, m.Get("c").IsInterSlice())
111 assert.Equal(t, float64(1), m.Get("c").InterSlice()[0])
112
113 assert.True(t, m.Get("d").IsInterSlice())
114 assert.Equal(t, []interface{}{float64(1)}, m.Get("d").InterSlice()[0])
115}
116
117func TestJSONSliceInt(t *testing.T) {
118 jsonString :=

Callers

nothing calls this directly

Calls 9

FromJSONFunction · 0.92
IntMethod · 0.80
GetMethod · 0.80
IsInterSliceMethod · 0.80
InterSliceMethod · 0.80
NilMethod · 0.45
NotNilMethod · 0.45
EqualMethod · 0.45
TrueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…