Skip to main content

TestCase

Trait TestCase 

Source
pub trait TestCase {
    type Args<'a>: Arbitrary<'a>;
    type FactoryItem<'a>: Arbitrary<'a>;

    // Required method
    fn init<'a>(
        &self,
        args: &mut Self::Args<'a>,
    ) -> (impl Driver<'a>, impl AsyncFnMut(Self::FactoryItem<'a>));
}
Expand description

Defines a future to test for waker correctness, along with the Driver that makes it progress.

Use the testcase! macro for a concise way to implement this trait.

Required Associated Types§

Source

type Args<'a>: Arbitrary<'a>

Shared state constructed once per test iteration. Both the driver and the factory close over references to this value.

Use () when no shared state is needed, or ArbitraryDefault<T> when you need a Default-constructed T that doesn’t implement Arbitrary.

Source

type FactoryItem<'a>: Arbitrary<'a>

An arbitrary value passed to the factory on each invocation. Use () if the future under test doesn’t need external input; use a concrete type (e.g. u8) when the future itself consumes data.

Required Methods§

Source

fn init<'a>( &self, args: &mut Self::Args<'a>, ) -> (impl Driver<'a>, impl AsyncFnMut(Self::FactoryItem<'a>))

Construct a (Driver, factory) pair for one test iteration.

The factory is an async closure that will be called multiple times per iteration, each time receiving a new FactoryItem. Cancellation between calls exercises cancel-safety.

This function should be deterministic – derive any randomness from args.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§