|
|
@ -112,6 +112,31 @@ pub fn test_iterator() { |
|
|
|
let expected = vec![(cba(&k2), cba(&v2)), (cba(&k1), cba(&v1))]; |
|
|
|
let expected = vec![(cba(&k2), cba(&v2)), (cba(&k1), cba(&v1))]; |
|
|
|
assert_eq!(iterator1.collect::<Vec<_>>(), expected); |
|
|
|
assert_eq!(iterator1.collect::<Vec<_>>(), expected); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
let iterator1 = db.iterator(IteratorMode::From(b"k0", Direction::Forward)); |
|
|
|
|
|
|
|
assert!(iterator1.valid()); |
|
|
|
|
|
|
|
let iterator2 = db.iterator(IteratorMode::From(b"k1", Direction::Forward)); |
|
|
|
|
|
|
|
assert!(iterator2.valid()); |
|
|
|
|
|
|
|
let iterator3 = db.iterator(IteratorMode::From(b"k11", Direction::Forward)); |
|
|
|
|
|
|
|
assert!(iterator3.valid()); |
|
|
|
|
|
|
|
let iterator4 = db.iterator(IteratorMode::From(b"k5", Direction::Forward)); |
|
|
|
|
|
|
|
assert!(!iterator4.valid()); |
|
|
|
|
|
|
|
let iterator5 = db.iterator(IteratorMode::From(b"k0", Direction::Reverse)); |
|
|
|
|
|
|
|
assert!(iterator5.valid()); |
|
|
|
|
|
|
|
let iterator6 = db.iterator(IteratorMode::From(b"k1", Direction::Reverse)); |
|
|
|
|
|
|
|
assert!(iterator6.valid()); |
|
|
|
|
|
|
|
let iterator7 = db.iterator(IteratorMode::From(b"k11", Direction::Reverse)); |
|
|
|
|
|
|
|
assert!(iterator7.valid()); |
|
|
|
|
|
|
|
let iterator8 = db.iterator(IteratorMode::From(b"k5", Direction::Reverse)); |
|
|
|
|
|
|
|
assert!(!iterator8.valid()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
let mut iterator1 = db.iterator(IteratorMode::From(b"k4", Direction::Forward)); |
|
|
|
|
|
|
|
iterator1.next(); |
|
|
|
|
|
|
|
assert!(iterator1.valid()); |
|
|
|
|
|
|
|
iterator1.next(); |
|
|
|
|
|
|
|
assert!(!iterator1.valid()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
let opts = Options::new(); |
|
|
|
let opts = Options::new(); |
|
|
|
assert!(DB::destroy(&opts, path).is_ok()); |
|
|
|
assert!(DB::destroy(&opts, path).is_ok()); |
|
|
|