Property based testing
Property based testing using the proptest crate
The proptest library works well together with test-r
. There is no special requirements, just make sure to import test-r
's test
attribute before using the proptest!
macro to define the property based tests.
For example:
#![allow(unused)] fn main() { use test_r::test; use proptest::prelude::*; fn parse_date(s: &str) -> Option<(u32, u32, u32)> { todo!() } proptest! { #[test] fn parses_all_valid_dates(s in "[0-9]{4}-[0-9]{2}-[0-9]{2}") { parse_date(&s); } } }