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

Function TestSkipIteratorBasics

graph/iterator/skip_test.go:11–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestSkipIteratorBasics(t *testing.T) {
12 ctx := context.TODO()
13 allIt := NewFixed(
14 Int64Node(1),
15 Int64Node(2),
16 Int64Node(3),
17 Int64Node(4),
18 Int64Node(5),
19 )
20
21 u := NewSkip(allIt, 0)
22 expectSz, _ := allIt.Size()
23 if sz, _ := u.Size(); sz != expectSz {
24 t.Errorf("Failed to check Skip size: got:%v expected:%v", sz, expectSz)
25 }
26 expect := []int{1, 2, 3, 4, 5}
27 if got := iterated(u); !reflect.DeepEqual(got, expect) {
28 t.Errorf("Failed to iterate Skip correctly: got:%v expected:%v", got, expect)
29 }
30
31 allIt.Reset()
32
33 u = NewSkip(allIt, 3)
34 expectSz = 2
35 if sz, _ := u.Size(); sz != expectSz {
36 t.Errorf("Failed to check Skip size: got:%v expected:%v", sz, expectSz)
37 }
38 expect = []int{4, 5}
39 if got := iterated(u); !reflect.DeepEqual(got, expect) {
40 t.Errorf("Failed to iterate Skip correctly: got:%v expected:%v", got, expect)
41 }
42
43 u.Reset()
44 for _, v := range []int{1, 2, 3} {
45 if u.Contains(ctx, Int64Node(v)) {
46 t.Errorf("Failed to find a correct value in the Skip iterator.")
47 }
48 }
49 for _, v := range []int{4, 5} {
50 if !u.Contains(ctx, Int64Node(v)) {
51 t.Errorf("Failed to find a correct value in the Skip iterator.")
52 }
53 }
54
55 u.Reset()
56 for _, v := range []int{5, 4, 3} {
57 if u.Contains(ctx, Int64Node(v)) {
58 t.Errorf("Failed to find a correct value in the Skip iterator.")
59 }
60 }
61 for _, v := range []int{1, 2} {
62 if !u.Contains(ctx, Int64Node(v)) {
63 t.Errorf("Failed to find a correct value in the Skip iterator.")
64 }
65 }
66
67 // TODO(dennwc): check with NextPath
68}

Callers

nothing calls this directly

Calls 8

NewFixedFunction · 0.85
Int64NodeTypeAlias · 0.85
NewSkipFunction · 0.85
iteratedFunction · 0.85
SizeMethod · 0.65
ErrorfMethod · 0.65
ResetMethod · 0.65
ContainsMethod · 0.65

Tested by

no test coverage detected