Skip to main content

scirs2_core/testing/
propertybased.rs

1//! Property-based testing utilities
2
3#[cfg(feature = "testing")]
4use quickcheck::{Arbitrary, Gen, QuickCheck};
5
6/// Property test configuration
7pub struct PropertyTestConfig {
8    pub tests: u64,
9    pub max_size: usize,
10}
11
12impl Default for PropertyTestConfig {
13    fn default() -> Self {
14        Self {
15            tests: 100,
16            max_size: 100,
17        }
18    }
19}
20
21/// Run property-based tests
22pub fn run_property_test<F, A>(property: F, config: PropertyTestConfig)
23where
24    F: Fn(A) -> bool + quickcheck::Testable,
25    A: Arbitrary + std::fmt::Debug,
26{
27    QuickCheck::new()
28        .tests(config.tests)
29        .max_tests(config.tests)
30        .quickcheck(property);
31}