TestVectorSet

Derive Macro TestVectorSet 

Source
#[derive(TestVectorSet)]
{
    // Attributes available to this derive:
    #[test_vec]
}
Expand description

Derive assert_tv::TestVectorSet for a struct of TestValue<…> fields.

Requirements:

  • Struct with named fields (no tuple/unit structs).
  • Every field is of type assert_tv::TestValue<…>.

Per-field attributes via #[test_vec(...)]:

  • name = "…": human-readable field name.
  • description = "…": longer description for reports.
  • serialize_with = "path::to::fn": fn(&T) -> anyhow::Result<serde_json::Value>.
  • deserialize_with = "path::to::fn": fn(&serde_json::Value) -> anyhow::Result<T>.
  • offload = true: store value in a compressed sidecar file.

Example:

use assert_tv::{TestVectorSet, TestValue};

#[derive(TestVectorSet)]
struct Fields {
    #[test_vec(name = "rand", description = "random input")]
    rand: TestValue<u64>,

    #[test_vec(name = "out", offload = true)]
    out: TestValue<Vec<u8>>,
}