| 872 | testManyAny(t, json, paths, expected, false) |
| 873 | } |
| 874 | func testManyAny(t *testing.T, json string, paths, expected []string, |
| 875 | bytes bool) { |
| 876 | var result []Result |
| 877 | for i := 0; i < 2; i++ { |
| 878 | var which string |
| 879 | if i == 0 { |
| 880 | which = "Get" |
| 881 | result = nil |
| 882 | for j := 0; j < len(expected); j++ { |
| 883 | if bytes { |
| 884 | result = append(result, GetBytes([]byte(json), paths[j])) |
| 885 | } else { |
| 886 | result = append(result, Get(json, paths[j])) |
| 887 | } |
| 888 | } |
| 889 | } else if i == 1 { |
| 890 | which = "GetMany" |
| 891 | if bytes { |
| 892 | result = GetManyBytes([]byte(json), paths...) |
| 893 | } else { |
| 894 | result = GetMany(json, paths...) |
| 895 | } |
| 896 | } |
| 897 | for j := 0; j < len(expected); j++ { |
| 898 | if result[j].String() != expected[j] { |
| 899 | t.Fatalf("Using key '%s' for '%s'\nexpected '%v', got '%v'", |
| 900 | paths[j], which, expected[j], result[j].String()) |
| 901 | } |
| 902 | } |
| 903 | } |
| 904 | } |
| 905 | func TestIssue20(t *testing.T) { |
| 906 | json := `{ "name": "FirstName", "name1": "FirstName1", ` + |
| 907 | `"address": "address1", "addressDetails": "address2", }` |