Skip to main content

Module testing

Module testing 

Source
Expand description

Thread-local one-shot fault for the try_reserve_exact seam in the enclosing module. Reachable under cfg(any(test, feature = "test-components")) so integration tests in the facade crate can drive the same seam the crate-internal sibling tests use. FailOnce::install returns an RAII guard that clears the thread-local on drop so a panicking assertion does not poison the next test on the thread.

try_reserve_exact against Vec<()> is the canonical way to mint a real TryReserveError without unsafe.

Structs§

FailOnce
RAII guard that arms a fault on construction and clears it on drop. Use when a test might panic between arming and consuming the fault.

Functions§

arm_fault
Replace the thread-local fault with Some(err). The next try_reserve_exact call consumes it and returns Err.
synthetic_err
Synthesize a real TryReserveError. Asking for usize::MAX elements of a 32-byte type overflows the allocation-size computation in Vec::try_reserve_exact and returns Err(CapacityOverflow) without actually touching the allocator.