MCPcopy Index your code
hub / github.com/gavv/httpexpect / TestArray_Getters

Function TestArray_Getters

array_test.go:297–367  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

295}
296
297func TestArray_Getters(t *testing.T) {
298 t.Run("length when empty", func(t *testing.T) {
299 reporter := newMockReporter(t)
300
301 data := []interface{}{}
302
303 value := NewArray(reporter, data)
304
305 innerValue := value.Length()
306 assert.Equal(t, 0.0, innerValue.Raw())
307
308 value.chain.assert(t, success)
309 innerValue.chain.assert(t, success)
310 })
311
312 t.Run("length when non-empty", func(t *testing.T) {
313 reporter := newMockReporter(t)
314
315 data := []interface{}{"foo", 123.0}
316
317 value := NewArray(reporter, data)
318
319 innerValue := value.Length()
320 assert.Equal(t, 2.0, innerValue.Raw())
321
322 value.chain.assert(t, success)
323 innerValue.chain.assert(t, success)
324 })
325
326 t.Run("value when empty", func(t *testing.T) {
327 reporter := newMockReporter(t)
328
329 data := []interface{}{}
330
331 value := NewArray(reporter, data)
332
333 innerValue := value.Value(0)
334 assert.NotNil(t, innerValue)
335
336 value.chain.assert(t, failure)
337 innerValue.chain.assert(t, failure)
338 })
339
340 t.Run("value when non-empty", func(t *testing.T) {
341 reporter := newMockReporter(t)
342
343 data := []interface{}{"foo", 123.0}
344
345 value := NewArray(reporter, data)
346
347 innerValue := value.Value(0)
348 assert.Equal(t, "foo", innerValue.Raw())
349
350 value.chain.assert(t, success)
351 innerValue.chain.assert(t, success)
352 })
353
354 t.Run("value out of range", func(t *testing.T) {

Callers

nothing calls this directly

Calls 7

LengthMethod · 0.95
ValueMethod · 0.95
newMockReporterFunction · 0.85
NewArrayFunction · 0.85
assertMethod · 0.80
EqualMethod · 0.45
RawMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…