#[test_collection]
Expand description

A macro that duplicates a test for multiple data structures. This macros has the following functionalities:

  • Any number of data structures can be tested.
  • Any number of extra macros can be applied to the test.
  • The test takes a single argument, which for the test will be properly initialized with the a data structure of the type that is being tested.
  • The type of the argument is automatically changed to the data structure that is being tested.

Panics

The test function must have a single type parameter with a trait bound.

Example

use trait_based_collection_macros::test_collection;
use trait_based_collection::*;

#[test_collection(Stack, ArrayStack; should_panic)]
fn test<C: Collection<usize>>(mut stack: C) {
   stack[1000]; // This should panic
}