From 9e98f60a65c3e07856b7e3c761523b19c9a2492f Mon Sep 17 00:00:00 2001 From: Jordan Terrell Date: Fri, 8 Mar 2019 04:07:27 -0600 Subject: [PATCH] Adding test for AsRef<[u8]> impl on DBVector... --- tests/test_db.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_db.rs b/tests/test_db.rs index 1067bb3..47dac85 100644 --- a/tests/test_db.rs +++ b/tests/test_db.rs @@ -49,6 +49,26 @@ fn external() { } } +#[test] +fn db_vector_as_ref_byte_slice() { + let path = DBPath::new("_rust_rocksdb_db_vector_as_ref_byte_slice"); + + { + let db = DB::open_default(&path).unwrap(); + + assert!(db.put(b"k1", b"v1111").is_ok()); + + let r: Result, Error> = db.get(b"k1"); + let vector = r.unwrap().unwrap(); + + assert!(get_byte_slice(&vector) == b"v1111"); + } +} + +fn get_byte_slice>(source: &'_ T) -> &'_ [u8] { + source.as_ref() +} + #[test] fn errors_do_stuff() { let path = DBPath::new("_rust_rocksdb_error");