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

Function TestIterator_NextAfterEnd

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

Source from the content-addressed store, hash-verified

253}
254
255func TestIterator_NextAfterEnd(t *testing.T) {
256 bucket := "bucket"
257
258 runNutsDBTest(t, nil, func(t *testing.T, db *DB) {
259 txCreateBucket(t, db, DataStructureBTree, bucket, nil)
260
261 for i := 0; i < 10; i++ {
262 txPut(t, db, bucket, testutils.GetTestBytes(i), testutils.GetTestBytes(i), Persistent, nil, nil)
263 }
264
265 _ = db.View(func(tx *Tx) error {
266 iterator := NewIterator(tx, bucket, IteratorOptions{Reverse: false})
267 defer iterator.Release()
268
269 // Move to the end
270 count := 0
271 for iterator.Valid() {
272 count++
273 if !iterator.Next() {
274 break
275 }
276 }
277 require.Equal(t, 10, count)
278
279 // Try to move beyond end
280 require.False(t, iterator.Valid())
281 require.False(t, iterator.Next())
282 require.False(t, iterator.Valid())
283
284 // Key and Item should return nil
285 require.Nil(t, iterator.Key())
286 require.Nil(t, iterator.Item())
287
288 return nil
289 })
290 })
291}
292
293func TestIterator_ValidConsistency(t *testing.T) {
294 bucket := "bucket"

Callers

nothing calls this directly

Calls 11

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