]> git.lizzy.rs Git - rust.git/commitdiff
range_map: also test size of the internal representation
authorRalf Jung <post@ralfj.de>
Fri, 4 Jan 2019 15:03:39 +0000 (16:03 +0100)
committerRalf Jung <post@ralfj.de>
Mon, 7 Jan 2019 14:10:22 +0000 (15:10 +0100)
src/range_map.rs

index 762b17b1ae3389a8a9fac9e06bb70e271e4fee20..84965fd4cf739fe9238f49d308c788e723841786 100644 (file)
@@ -203,6 +203,7 @@ fn basic_insert() {
         }
         // Check
         assert_eq!(to_vec(&map, 10, 1), vec![42]);
+        assert_eq!(map.map.len(), 3);
 
         // Insert with size 0
         for x in map.iter_mut(Size::from_bytes(10), Size::from_bytes(0)) {
@@ -212,6 +213,7 @@ fn basic_insert() {
             *x = 19;
         }
         assert_eq!(to_vec(&map, 10, 2), vec![42, -1]);
+        assert_eq!(map.map.len(), 3);
     }
 
     #[test]
@@ -223,6 +225,7 @@ fn gaps() {
         for x in map.iter_mut(Size::from_bytes(15), Size::from_bytes(1)) {
             *x = 43;
         }
+        assert_eq!(map.map.len(), 5);
         assert_eq!(
             to_vec(&map, 10, 10),
             vec![-1, 42, -1, -1, -1, 43, -1, -1, -1, -1]
@@ -233,6 +236,7 @@ fn gaps() {
                 *x = 23;
             }
         }
+        assert_eq!(map.map.len(), 6);
 
         assert_eq!(
             to_vec(&map, 10, 10),
@@ -244,6 +248,7 @@ fn gaps() {
         for x in map.iter_mut(Size::from_bytes(15), Size::from_bytes(10)) {
             *x = 19;
         }
+        assert_eq!(map.map.len(), 6);
         assert_eq!(map.iter(Size::from_bytes(19), Size::from_bytes(1))
             .map(|&t| t).collect::<Vec<_>>(), vec![19]);
         assert_eq!(map.iter(Size::from_bytes(20), Size::from_bytes(1))