MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / TestIterator_MultipleSeeks

Function TestIterator_MultipleSeeks

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

Source from the content-addressed store, hash-verified

383}
384
385func TestIterator_MultipleSeeks(t *testing.T) {
386 bucket := "bucket"
387
388 runNutsDBTest(t, nil, func(t *testing.T, db *DB) {
389 txCreateBucket(t, db, DataStructureBTree, bucket, nil)
390
391 for i := 0; i < 100; i++ {
392 txPut(t, db, bucket, testutils.GetTestBytes(i), testutils.GetTestBytes(i), Persistent, nil, nil)
393 }
394
395 _ = db.View(func(tx *Tx) error {
396 iterator := NewIterator(tx, bucket, IteratorOptions{Reverse: false})
397 defer iterator.Release()
398
399 // Seek to different positions
400 positions := []int{10, 50, 20, 80, 5}
401 for _, pos := range positions {
402 require.True(t, iterator.Seek(testutils.GetTestBytes(pos)))
403 require.True(t, iterator.Valid())
404 key := iterator.Key()
405 require.Equal(t, testutils.GetTestBytes(pos), key)
406 }
407
408 return nil
409 })
410 })
411}
412
413func TestIterator_CachedItemConsistency(t *testing.T) {
414 bucket := "bucket"

Callers

nothing calls this directly

Calls 10

ReleaseMethod · 0.95
SeekMethod · 0.95
ValidMethod · 0.95
KeyMethod · 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