MCPcopy Index your code
hub / github.com/tidwall/gjson / TestIter

Function TestIter

gjson_test.go:2731–2760  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2729}
2730
2731func TestIter(t *testing.T) {
2732
2733 json := `{
2734 "a":1,
2735 "b":2,
2736 "c":3,
2737 "d":4
2738 }`
2739 c := 'a'
2740 i := 1
2741 for key, value := range Parse(json).All() {
2742 assert(t, key.String() == fmt.Sprintf("%c", c))
2743 assert(t, int(value.Int()) == i)
2744 c++
2745 i++
2746 }
2747
2748 c = 'a'
2749 for key := range Parse(json).Keys() {
2750 assert(t, key.String() == fmt.Sprintf("%c", c))
2751 c++
2752 }
2753
2754 i = 1
2755 for value := range Parse(json).Values() {
2756 assert(t, int(value.Int()) == i)
2757 i++
2758 }
2759
2760}

Callers

nothing calls this directly

Calls 7

ParseFunction · 0.85
assertFunction · 0.85
AllMethod · 0.80
IntMethod · 0.80
KeysMethod · 0.80
ValuesMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…