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

Function TestCount

graph/iterator/count_test.go:12–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestCount(t *testing.T) {
13 ctx := context.TODO()
14 fixed := NewFixed(
15 graph.PreFetched(quad.String("a")),
16 graph.PreFetched(quad.String("b")),
17 graph.PreFetched(quad.String("c")),
18 graph.PreFetched(quad.String("d")),
19 graph.PreFetched(quad.String("e")),
20 )
21 it := NewCount(fixed, nil)
22 require.True(t, it.Next(ctx))
23 require.Equal(t, graph.PreFetched(quad.Int(5)), it.Result())
24 require.False(t, it.Next(ctx))
25 require.True(t, it.Contains(ctx, graph.PreFetched(quad.Int(5))))
26 require.False(t, it.Contains(ctx, graph.PreFetched(quad.Int(3))))
27
28 fixed.Reset()
29
30 fixed2 := NewFixed(
31 graph.PreFetched(quad.String("b")),
32 graph.PreFetched(quad.String("d")),
33 )
34 it = NewCount(NewAnd(fixed, fixed2), nil)
35 require.True(t, it.Next(ctx))
36 require.Equal(t, graph.PreFetched(quad.Int(2)), it.Result())
37 require.False(t, it.Next(ctx))
38 require.False(t, it.Contains(ctx, graph.PreFetched(quad.Int(5))))
39 require.True(t, it.Contains(ctx, graph.PreFetched(quad.Int(2))))
40}

Callers

nothing calls this directly

Calls 9

PreFetchedFunction · 0.92
NewFixedFunction · 0.85
NewCountFunction · 0.85
NewAndFunction · 0.85
StringMethod · 0.65
NextMethod · 0.65
ResultMethod · 0.65
ContainsMethod · 0.65
ResetMethod · 0.65

Tested by

no test coverage detected