Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add test cases for iterator.seek.

  • Loading branch information...
commit 0bf8d26a6e809ee9ebe6cf45e4474a9f3ab1ac71 1 parent d9c6ce4
@justmoon justmoon authored
Showing with 34 additions and 0 deletions.
  1. +34 −0 test/iterator-test.coffee
View
34 test/iterator-test.coffee
@@ -59,6 +59,40 @@ describe 'Iterator', ->
iterator.next if ++i <= 200 then next else done
next()
+ it 'should seek to a key', (done) ->
+ i = 100
+ next = (err) ->
+ assert.ifError err
+ expectKey = "#{i}"
+ expectVal = "Hello #{i}"
+ iterator.seek expectKey, (err) ->
+ assert.ifError err
+ iterator.key (err, key) ->
+ assert.ifError err
+ assert.equal expectKey, key
+ iterator.value (err, val) ->
+ assert.ifError err
+ assert.equal expectVal, val
+ if ++i <= 100 then next() else done()
+ next()
+
+ it 'should seek to a key (buffer)', (done) ->
+ i = 100
+ next = (err) ->
+ assert.ifError err
+ expectKey = "#{i}"
+ expectVal = "Hello #{i}"
+ iterator.seek new Buffer(expectKey, 'ascii'), (err) ->
+ assert.ifError err
+ iterator.key (err, key) ->
+ assert.ifError err
+ assert.equal expectKey, key
+ iterator.value (err, val) ->
+ assert.ifError err
+ assert.equal expectVal, val
+ if ++i <= 100 then next() else done()
+ next()
+
it 'should not get invalid key', (done) ->
iterator.seek '201', (err) ->
assert.ifError err
Please sign in to comment.
Something went wrong with that request. Please try again.