diff --git a/scm-bisect/src/testing.rs b/scm-bisect/src/testing.rs index a8b0dafc7..58689d976 100644 --- a/scm-bisect/src/testing.rs +++ b/scm-bisect/src/testing.rs @@ -1,3 +1,5 @@ +//! Testing utilities. + use std::collections::{HashMap, HashSet}; use std::convert::Infallible; @@ -7,6 +9,7 @@ use proptest::prelude::*; use crate::basic::{BasicSourceControlGraph, BasicStrategyKind}; +/// Graph that represents a "stick" of nodes from 0 to `max` (exclusive). #[derive(Clone, Debug)] pub struct UsizeGraph { pub max: usize, @@ -27,8 +30,10 @@ impl BasicSourceControlGraph for UsizeGraph { } } +/// Directed acyclic graph with nodes `char` and edges `char -> char`. #[derive(Clone, Debug)] pub struct TestGraph { + /// Mapping from parent to children. pub nodes: HashMap>, } @@ -57,6 +62,7 @@ impl BasicSourceControlGraph for TestGraph { } } +/// Select an arbitrary [`BasicStrategyKind`]. pub fn arb_strategy() -> impl ProptestStrategy { prop_oneof![ Just(BasicStrategyKind::Linear), @@ -65,6 +71,7 @@ pub fn arb_strategy() -> impl ProptestStrategy { ] } +/// Create an arbitrary [`TestGraph`] and an arbitrary set of failing nodes. pub fn arb_test_graph_and_nodes() -> impl ProptestStrategy)> { let nodes = prop::collection::hash_set( prop::sample::select(vec!['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']),