MCPcopy Index your code
hub / github.com/go-openapi/jsonpointer / TestArray

Function TestArray

pointer_test.go:319–351  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

317}
318
319func TestArray(t *testing.T) {
320 t.Parallel()
321
322 ins := []string{`/foo/0`, `/foo/0`, `/foo/1`}
323 outs := []string{"bar", "bar", "baz"}
324
325 for i, pointer := range ins {
326 expected := outs[i]
327
328 t.Run(fmt.Sprintf("with pointer %q", pointer), func(t *testing.T) {
329 p, err := New(pointer)
330 require.NoError(t, err)
331
332 t.Run("should resolve against struct", func(t *testing.T) {
333 result, _, err := p.Get(testStructJSONDoc(t))
334 require.NoError(t, err)
335 assert.Equal(t, expected, result)
336 })
337
338 t.Run("should resolve against pointer to struct", func(t *testing.T) {
339 result, _, err := p.Get(testStructJSONPtr(t))
340 require.NoError(t, err)
341 assert.Equal(t, expected, result)
342 })
343
344 t.Run("should resolve against dynamic JSON map", func(t *testing.T) {
345 result, _, err := p.Get(testDocumentJSON(t))
346 require.NoError(t, err)
347 assert.Equal(t, expected, result)
348 })
349 })
350 }
351}
352
353func TestStruct(t *testing.T) {
354 t.Parallel()

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
testStructJSONDocFunction · 0.85
testStructJSONPtrFunction · 0.85
testDocumentJSONFunction · 0.85
GetMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…