(t *testing.T)
| 838 | var testWatchForFallback bool |
| 839 | |
| 840 | func TestManyBasic(t *testing.T) { |
| 841 | testWatchForFallback = true |
| 842 | defer func() { |
| 843 | testWatchForFallback = false |
| 844 | }() |
| 845 | testMany := func(shouldFallback bool, expect string, paths ...string) { |
| 846 | results := GetManyBytes( |
| 847 | []byte(manyJSON), |
| 848 | paths..., |
| 849 | ) |
| 850 | if len(results) != len(paths) { |
| 851 | t.Fatalf("expected %v, got %v", len(paths), len(results)) |
| 852 | } |
| 853 | if fmt.Sprintf("%v", results) != expect { |
| 854 | fmt.Printf("%v\n", paths) |
| 855 | t.Fatalf("expected %v, got %v", expect, results) |
| 856 | } |
| 857 | } |
| 858 | testMany(false, "[Point]", "position.type") |
| 859 | testMany(false, `[emptya ["world peace"] 31]`, ".a", "loves", "age") |
| 860 | testMany(false, `[["world peace"]]`, "loves") |
| 861 | testMany(false, `[{"last":"Anderson","first":"Nancy"} Nancy]`, "name", |
| 862 | "name.first") |
| 863 | testMany(true, `[]`, strings.Repeat("a.", 40)+"hello") |
| 864 | res := Get(manyJSON, strings.Repeat("a.", 48)+"a") |
| 865 | testMany(true, `[`+res.String()+`]`, strings.Repeat("a.", 48)+"a") |
| 866 | // these should fallback |
| 867 | testMany(true, `[Cat Nancy]`, "name\\.first", "name.first") |
| 868 | testMany(true, `[world]`, strings.Repeat("a.", 70)+"hello") |
| 869 | } |
| 870 | func testMany(t *testing.T, json string, paths, expected []string) { |
| 871 | testManyAny(t, json, paths, expected, true) |
| 872 | testManyAny(t, json, paths, expected, false) |
nothing calls this directly
no test coverage detected
searching dependent graphs…