MCPcopy
hub / github.com/cayleygraph/cayley / TestRecursiveNextPath

Function TestRecursiveNextPath

graph/iterator/recursive_test.go:90–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func TestRecursiveNextPath(t *testing.T) {
91 ctx := context.TODO()
92 qs := rec_test_qs
93 start := qs.NodesAllIterator()
94 start = Tag(start, "person")
95 it := singleHop(qs, "follows")(start)
96 and := NewAnd()
97 and.AddSubIterator(it)
98 fixed := NewFixed()
99 fixed.Add(graph.PreFetched(quad.Raw("alice")))
100 and.AddSubIterator(fixed)
101 r := NewRecursive(and, singleHop(qs, "parent"), 0)
102
103 expected := []string{"fred", "fred", "fred", "fred", "greg", "greg", "greg", "greg"}
104 var got []string
105 for r.Next(ctx) {
106 res := make(map[string]graph.Ref)
107 r.TagResults(res)
108 got = append(got, quad.ToString(qs.NameOf(res["person"])))
109 for r.NextPath(ctx) {
110 res := make(map[string]graph.Ref)
111 r.TagResults(res)
112 got = append(got, quad.ToString(qs.NameOf(res["person"])))
113 }
114 }
115 sort.Strings(expected)
116 sort.Strings(got)
117 if !reflect.DeepEqual(got, expected) {
118 t.Errorf("Failed to check NextPath, got: %v, expected: %v", got, expected)
119 }
120}

Callers

nothing calls this directly

Calls 14

AddSubIteratorMethod · 0.95
AddMethod · 0.95
PreFetchedFunction · 0.92
TagFunction · 0.85
singleHopFunction · 0.85
NewAndFunction · 0.85
NewFixedFunction · 0.85
NewRecursiveFunction · 0.85
NodesAllIteratorMethod · 0.65
NextMethod · 0.65
TagResultsMethod · 0.65
NameOfMethod · 0.65

Tested by

no test coverage detected