(t *testing.T)
| 164 | } |
| 165 | |
| 166 | func TestIterator_Rewind(t *testing.T) { |
| 167 | bucket := "bucket" |
| 168 | |
| 169 | runNutsDBTest(t, nil, func(t *testing.T, db *DB) { |
| 170 | txCreateBucket(t, db, DataStructureBTree, bucket, nil) |
| 171 | |
| 172 | for i := 0; i < 50; i++ { |
| 173 | txPut(t, db, bucket, testutils.GetTestBytes(i), testutils.GetTestBytes(i), Persistent, nil, nil) |
| 174 | } |
| 175 | |
| 176 | _ = db.View(func(tx *Tx) error { |
| 177 | iterator := NewIterator(tx, bucket, IteratorOptions{Reverse: false}) |
| 178 | defer iterator.Release() |
| 179 | |
| 180 | // Move to position 10 |
| 181 | for i := 0; i < 10; i++ { |
| 182 | require.True(t, iterator.Valid()) |
| 183 | iterator.Next() |
| 184 | } |
| 185 | |
| 186 | // Rewind back to start |
| 187 | require.True(t, iterator.Rewind()) |
| 188 | require.True(t, iterator.Valid()) |
| 189 | |
| 190 | // Verify we're at the first element |
| 191 | key := iterator.Key() |
| 192 | require.Equal(t, testutils.GetTestBytes(0), key) |
| 193 | |
| 194 | return nil |
| 195 | }) |
| 196 | }) |
| 197 | } |
| 198 | |
| 199 | func TestIterator_Rewind_Reverse(t *testing.T) { |
| 200 | bucket := "bucket" |
nothing calls this directly
no test coverage detected