[−][src]Macro test_generator::test_expand_list
test_expand_list!() { /* proc-macro */ }
deprecated Generate a test-function call for each list-element
extern crate test_generator; #[cfg(test)] mod tests { test_generator::test_expand_list! { test_size; [ 10, 100, 1000 ]} fn test_size(value: &usize) { assert!( *value > 0 ); } const VEC1: &[u8] = &[ 1, 2, 3, 4 ]; /* speaking array names */ const VEC2: &[u8] = &[ 5, 6, 7, 8 ]; test_generator::test_expand_list! { test_array_size; [ &VEC1, &VEC2 ]} test_generator::test_expand_list! { test_array_size; [ [1, 2, 3, 4], [ 5, 6, 7, 8 ] ] } fn test_array_size<T>(ar: &[T]) { assert!(ar.len() > 0); } }
Will expand to test-functions incorporating the array-elements
#[cfg(test)] mod tests { #[test] fn test_size_0000000010() { test_size(&10); } #[test] fn test_size_0000000100() { test_size(&100); } #[test] fn test_size_0000001000() { test_size(&1000); } #[test] fn test_array_size_VEC1() { test_array_size( &VEC1 ); } #[test] fn test_array_size_VEC2() { test_array_size( &VEC2 ); } #[test] fn test_array_size_01020304() { test_array_size( &[ 1, 2, 3, 4 ] ); } fn test_array_size_05060708() { test_array_size( &[ 5, 6, 7, 8 ] ); } fn test_array_size<T>(ar: &[T]) { assert!(ar.len() > 0); } }