(t *testing.T)
| 253 | } |
| 254 | |
| 255 | func 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 | |
| 293 | func TestIterator_ValidConsistency(t *testing.T) { |
| 294 | bucket := "bucket" |
nothing calls this directly
no test coverage detected