| 215 | } |
| 216 | |
| 217 | func 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 | } |
| 241 | func TestManyRecursion(t *testing.T) { |
| 242 | var json string |
| 243 | var path string |