proptest-rs / proptest

Hypothesis-like property testing for Rust
Apache License 2.0
1.74k stars 161 forks source link

How to use prop_assert_eq in a helper test function? #502

Closed incertia closed 2 months ago

incertia commented 2 months ago

Let's suppose I have a helper function designed to test a specific implementation of a trait.

fn test_trait<T: MyTrait>() { /* ... */ }

proptest! {
  #[test]
  fn test_struct1() {
    test_trait::<Struct1>();
  }

  #[test]
  fn test_struct2() {
    test_trait::<Struct2>();
  }
}

What is the correct way to call prop_assert_eq! in the helper function?

matthew-russo commented 2 months ago

Did you end up figuring out how to structure things? Is there anything we can help with?