Commit a73ebe88 authored by goroutine's avatar goroutine Committed by GitHub

Merge pull request #40 from BusyJay/busyjay/clean-up

clean up test directory
parents 7363e39b 9fa33a5f
...@@ -194,33 +194,6 @@ mod tests { ...@@ -194,33 +194,6 @@ mod tests {
DB::open(&opts, path).unwrap() DB::open(&opts, path).unwrap()
} }
#[test]
fn read_with_upper_bound() {
let path = "_rust_rocksdb_read_with_upper_bound_test";
let mut opts = Options::new();
opts.create_if_missing(true);
{
let db = DB::open(&opts, path).unwrap();
let writeopts = WriteOptions::new();
db.put_opt(b"k1-0", b"a", &writeopts).unwrap();
db.put_opt(b"k1-1", b"b", &writeopts).unwrap();
db.put_opt(b"k2-0", b"c", &writeopts).unwrap();
let mut readopts = ReadOptions::new();
readopts.set_iterate_upper_bound(b"k2");
let mut iter = db.iter_opt(readopts);
iter.seek(SeekKey::Start);
let mut count = 0;
while iter.valid() {
count += 1;
if !iter.next() {
break;
}
}
assert_eq!(count, 2);
}
}
// TODO(tyler) unstable // TODO(tyler) unstable
// #[bench] // #[bench]
// fn a_writes(b: &mut Bencher) { // fn a_writes(b: &mut Bencher) {
......
use rocksdb::{DB, Writable, SeekKey, DBIterator, Kv}; use rocksdb::*;
use tempdir::TempDir; use tempdir::TempDir;
fn prev_collect<'a>(iter: &mut DBIterator<'a>) -> Vec<Kv> { fn prev_collect<'a>(iter: &mut DBIterator<'a>) -> Vec<Kv> {
...@@ -113,3 +113,30 @@ pub fn test_iterator() { ...@@ -113,3 +113,30 @@ pub fn test_iterator() {
iter.prev(); iter.prev();
assert!(!iter.valid()); assert!(!iter.valid());
} }
#[test]
fn read_with_upper_bound() {
let path = TempDir::new("_rust_rocksdb_read_with_upper_bound_test").expect("");
let mut opts = Options::new();
opts.create_if_missing(true);
{
let db = DB::open(&opts, path.path().to_str().unwrap()).unwrap();
let writeopts = WriteOptions::new();
db.put_opt(b"k1-0", b"a", &writeopts).unwrap();
db.put_opt(b"k1-1", b"b", &writeopts).unwrap();
db.put_opt(b"k2-0", b"c", &writeopts).unwrap();
let mut readopts = ReadOptions::new();
readopts.set_iterate_upper_bound(b"k2");
let mut iter = db.iter_opt(readopts);
iter.seek(SeekKey::Start);
let mut count = 0;
while iter.valid() {
count += 1;
if !iter.next() {
break;
}
}
assert_eq!(count, 2);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment