Open svenstaro opened 5 years ago
I ran into this issue, and my current solution to generating dates is to use proptest-arbitrary-interop with chrono's arbitrary
feature:
use proptest_arbitrary_interop::arb;
prop_compose! {
fn my_strategy()(
created_at in arb::<DateTime<FixedOffset>>(),
) -> ... { ... }
}
However, my particular use case required RFC3339 datetimes, so I ended up having to add a filter:
prop_compose! {
fn my_strategy()(
created_at in arb::<DateTime<FixedOffset>>().prop_filter("Ability to parse from RFC3339 format", |datetime| {
DateTime::parse_from_rfc3339(&datetime.to_rfc3339()).is_ok()
}),
) -> ... { ... }
}
I'd be interested in a filter-less solution.
Generating dates is not actually trivial and since this crate already has two examples to generate dates, how about an example with a strategy using chrono to actually generate real dates?