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

Function testManyAny

gjson_test.go:874–904  ·  view source on GitHub ↗
(t *testing.T, json string, paths, expected []string,
	bytes bool)

Source from the content-addressed store, hash-verified

872 testManyAny(t, json, paths, expected, false)
873}
874func 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}
905func TestIssue20(t *testing.T) {
906 json := `{ "name": "FirstName", "name1": "FirstName1", ` +
907 `"address": "address1", "addressDetails": "address2", }`

Callers 1

testManyFunction · 0.85

Calls 5

GetBytesFunction · 0.85
GetFunction · 0.85
GetManyBytesFunction · 0.85
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…