MCPcopy Index your code
hub / github.com/nutsdb/nutsdb / TestIterator

Function TestIterator

iterator_test.go:24–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestIterator(t *testing.T) {
25 bucket := "bucket"
26
27 runNutsDBTest(t, nil, func(t *testing.T, db *DB) {
28 txCreateBucket(t, db, DataStructureBTree, bucket, nil)
29
30 for i := 0; i < 100; i++ {
31 txPut(t, db, bucket, testutils.GetTestBytes(i), testutils.GetTestBytes(i), Persistent, nil, nil)
32 }
33
34 _ = db.View(func(tx *Tx) error {
35 iterator := NewIterator(tx, bucket, IteratorOptions{Reverse: false})
36 defer iterator.Release()
37
38 i := 0
39
40 for {
41 value, err := iterator.Value()
42 require.NoError(t, err)
43 require.Equal(t, testutils.GetTestBytes(i), value)
44 if !iterator.Next() {
45 break
46 }
47 i++
48 }
49
50 return nil
51 })
52 })
53}
54
55func TestIterator_Reverse(t *testing.T) {
56 bucket := "bucket"

Callers

nothing calls this directly

Calls 9

ReleaseMethod · 0.95
ValueMethod · 0.95
NextMethod · 0.95
GetTestBytesFunction · 0.92
runNutsDBTestFunction · 0.85
txCreateBucketFunction · 0.85
txPutFunction · 0.85
NewIteratorFunction · 0.85
ViewMethod · 0.80

Tested by

no test coverage detected