(t *testing.T)
| 383 | } |
| 384 | |
| 385 | func 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 | |
| 413 | func TestIterator_CachedItemConsistency(t *testing.T) { |
| 414 | bucket := "bucket" |
nothing calls this directly
no test coverage detected