chiark / gitweb /
hidden: consistency_check: More
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 13 Mar 2021 19:32:00 +0000 (19:32 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 13 Mar 2021 19:58:03 +0000 (19:58 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/hidden.rs

index becb108322ab3e83acc30174c008279112cd0a75..4cfa1a274434bfdc2e2539d3b8c27f623bc30d0a 100644 (file)
@@ -529,6 +529,28 @@ mod vpid {
         assert_eq!(occ.notches.table[notch], NR::Piece(piece));
       }
     }
+
+    for (occid, occ) in goccults.occults.iter() {
+      let ogpc = gpieces.get(occ.occulter).unwrap();
+      assert_eq!(ogpc.occult.active, Some(occid));
+      assert_eq!(occ.notches.table.len(), occ.notches.zg.len());
+      let nfree1 = occ.notches.table.iter()
+        .filter(|nr| nr.piece().is_none()).count();
+      let mut walk = occ.notches.freelist;
+      let mut nfree2 = 0;
+      while let Some(here) = walk {
+        nfree2 += 1;
+        let next = match occ.notches.table[here] {
+          NR::Free(next) => next,
+          NR::Piece(_) => panic!(),
+        };
+        if let Some(next) = next {
+          assert!(next > here);
+        }
+        walk = next;
+      }
+      assert_eq!(nfree1,  nfree2);
+    }
   }
 }