changeset 365:f7df71486099

version: Add regression test for get_overlapping()
author Lewin Bormann <lbo@spheniscida.de>
date Sat, 07 Oct 2017 21:36:47 +0200
parents 8ef8559c6072
children 8ae87daebe4a
files src/version.rs
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/version.rs	Sat Oct 07 21:23:01 2017 +0200
+++ b/src/version.rs	Sat Oct 07 21:36:47 2017 +0200
@@ -746,6 +746,27 @@
     }
 
     #[test]
+    fn test_version_get_overlapping_basic() {
+        let v = make_version().0;
+
+        // Overlapped by tables 1 and 2.
+        let ol = v.get_overlapping(LookupKey::new(b"aay", 50).internal_key());
+        // Check that sorting order is newest-first in L0.
+        assert_eq!(2, ol[0][0].borrow().num);
+        // Check that table from L1 matches.
+        assert_eq!(3, ol[1][0].borrow().num);
+
+        let ol = v.get_overlapping(LookupKey::new(b"cb", 50).internal_key());
+        assert_eq!(3, ol[1][0].borrow().num);
+        assert_eq!(6, ol[2][0].borrow().num);
+
+        let ol = v.get_overlapping(LookupKey::new(b"x", 50).internal_key());
+        for i in 0..NUM_LEVELS {
+            assert!(ol[i].is_empty());
+        }
+    }
+
+    #[test]
     fn test_version_overlap_in_level() {
         let v = make_version().0;