chiark / gitweb /
hidden: Add another consistency check for pieces<->notches
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 Apr 2022 15:10:15 +0000 (16:10 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 Apr 2022 15:10:15 +0000 (16:10 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/vpid.rs

index f0575cbbc2b9ed38424b730059b7ac7f8db77a63..5ff139d4d342ec96b29bc51a78f4fb91d2dc296d 100644 (file)
@@ -410,6 +410,15 @@ pub fn consistency_check(
     let ogpc = gpieces.get(occ.occulter).unwrap();
     assert_eq!(ogpc.occult.active, Some(occid));
     assert_eq!(occ.notches.table.len(), occ.notches.zg.len());
+
+    for (notch, nr) in occ.notches.table.iter_enumerated() {
+      if_let!{ Some(ppiece) = nr.piece(); else continue };
+      let pgpc = gpieces.get(ppiece).unwrap();
+      let passive = pgpc.occult.passive.as_ref().unwrap();
+      assert_eq!(passive.occid, occid);
+      assert_eq!(passive.notch, notch);
+    }
+
     let nfree1 = occ.notches.table.iter()
       .filter(|nr| nr.piece().is_none()).count();
     let mut walk = occ.notches.freelist;