MCPcopy Create free account
hub / github.com/gavv/httpexpect / TestNumber_Decode

Function TestNumber_Decode

number_test.go:79–135  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

77}
78
79func TestNumber_Decode(t *testing.T) {
80 t.Run("target is empty interface", func(t *testing.T) {
81 reporter := newMockReporter(t)
82
83 value := NewNumber(reporter, 10.1)
84
85 var target interface{}
86 value.Decode(&target)
87
88 value.chain.assert(t, success)
89 assert.Equal(t, 10.1, target)
90 })
91
92 t.Run("target is int", func(t *testing.T) {
93 reporter := newMockReporter(t)
94
95 value := NewNumber(reporter, 10)
96
97 var target int
98 value.Decode(&target)
99
100 value.chain.assert(t, success)
101 assert.Equal(t, 10, target)
102 })
103
104 t.Run("target is float64", func(t *testing.T) {
105 reporter := newMockReporter(t)
106
107 value := NewNumber(reporter, 10.1)
108
109 var target float64
110 value.Decode(&target)
111
112 value.chain.assert(t, success)
113 assert.Equal(t, 10.1, target)
114 })
115
116 t.Run("target is nil", func(t *testing.T) {
117 reporter := newMockReporter(t)
118
119 value := NewNumber(reporter, 10.1)
120
121 value.Decode(nil)
122
123 value.chain.assert(t, failure)
124 })
125
126 t.Run("target is unmarshable", func(t *testing.T) {
127 reporter := newMockReporter(t)
128
129 value := NewNumber(reporter, 10.1)
130
131 value.Decode(123)
132
133 value.chain.assert(t, failure)
134 })
135}
136

Callers

nothing calls this directly

Calls 5

DecodeMethod · 0.95
newMockReporterFunction · 0.85
NewNumberFunction · 0.85
assertMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…