rust: adapted hg-core tests for iteration over Result
authorGeorges Racinet <gracinet@anybox.fr>
Tue, 11 Dec 2018 17:13:17 +0100
changeset 40929 43ca24b772d6
parent 40928 576474baa209
child 40930 fcdff048a8e5
rust: adapted hg-core tests for iteration over Result Now AncestorsIterator iters on Result<Revision, GraphError>
rust/hg-core/src/ancestors.rs
--- a/rust/hg-core/src/ancestors.rs	Tue Dec 11 21:57:54 2018 -0500
+++ b/rust/hg-core/src/ancestors.rs	Tue Dec 11 17:13:17 2018 +0100
@@ -173,6 +173,7 @@
     ) -> Vec<Revision> {
         AncestorsIterator::new(graph, initrevs, stoprev, inclusive)
             .unwrap()
+            .map(|res| res.unwrap())
             .collect()
     }
 
@@ -218,12 +219,12 @@
     fn test_contains() {
         let mut lazy =
             AncestorsIterator::new(Stub, vec![10, 1], 0, true).unwrap();
-        assert!(lazy.contains(1));
-        assert!(!lazy.contains(3));
+        assert!(lazy.contains(1).unwrap());
+        assert!(!lazy.contains(3).unwrap());
 
         let mut lazy =
             AncestorsIterator::new(Stub, vec![0], 0, false).unwrap();
-        assert!(!lazy.contains(NULL_REVISION));
+        assert!(!lazy.contains(NULL_REVISION).unwrap());
     }
 
     /// A corrupted Graph, supporting error handling tests
@@ -255,7 +256,6 @@
         // inclusive=false looks up initrev's parents right away
         let mut iter =
             AncestorsIterator::new(Corrupted, vec![1], 0, false).unwrap();
-        assert_eq!(iter.next(), Some(0));
-        assert_eq!(iter.next(), None);
+        assert_eq!(iter.next(), Some(Err(GraphError::ParentOutOfRange(0))));
     }
 }