MCPcopy
hub / github.com/tidwall/gjson / TestManyVariousPathCounts

Function TestManyVariousPathCounts

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

Source from the content-addressed store, hash-verified

215}
216
217func TestManyVariousPathCounts(t *testing.T) {
218 json := `{"a":"a","b":"b","c":"c"}`
219 counts := []int{3, 4, 7, 8, 9, 15, 16, 17, 31, 32, 33, 63, 64, 65, 127,
220 128, 129, 255, 256, 257, 511, 512, 513}
221 paths := []string{"a", "b", "c"}
222 expects := []string{"a", "b", "c"}
223 for _, count := range counts {
224 var gpaths []string
225 for i := 0; i < count; i++ {
226 if i < len(paths) {
227 gpaths = append(gpaths, paths[i])
228 } else {
229 gpaths = append(gpaths, fmt.Sprintf("not%d", i))
230 }
231 }
232 results := GetMany(json, gpaths...)
233 for i := 0; i < len(paths); i++ {
234 if results[i].String() != expects[i] {
235 t.Fatalf("expected '%v', got '%v'", expects[i],
236 results[i].String())
237 }
238 }
239 }
240}
241func TestManyRecursion(t *testing.T) {
242 var json string
243 var path string

Callers

nothing calls this directly

Calls 2

GetManyFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…