prop-test

Crates.ioprop-test
lib.rsprop-test
version0.1.1
sourcesrc
created_at2024-08-15 18:29:18.177978
updated_at2024-08-15 18:35:58.285721
descriptionFormattable proptest macro
homepage
repositoryhttps://github.com/grimerssy/prop-test
max_upload_size
id1339093
size18,693
Stanislav Stoyanov (grimerssy)

documentation

https://docs.rs/prop-test

README

Prop-test

Utility for the proptest crate, which provides a macro that is formattable with rustfmt.

Unlike the original proptest!() macro, this macro isn't expected to "wrap" test functions but is instead intended to be placed as expressions within them.

Example

fn reverse<T: Clone>(xs: &[T]) -> Vec<T> {
    xs.iter().rev().cloned().collect()
}

use prop_test::prelude::*;

// This expression would be inside of a `#[test]` function
prop_test!(&prop::collection::vec(any::<i32>(), 0..100), |xs| {
    prop_assert_eq!(&xs, &reverse(&reverse(&xs)));
    Ok(())
});
Commit count: 0

cargo fmt