1 // run-pass 2 // aux-build:dynamic_runner.rs 3 // compile-flags:--test 4 #![feature(custom_test_frameworks)] 5 #![test_runner(dynamic_runner::runner)] 6 7 extern crate dynamic_runner; 8 9 pub struct AllFoo(&'static str); 10 struct IsFoo(String); 11 12 impl dynamic_runner::Testable for AllFoo { name(&self) -> String13 fn name(&self) -> String { 14 String::from(self.0) 15 } 16 subtests(&self) -> Vec<Box<dyn dynamic_runner::Testable>>17 fn subtests(&self) -> Vec<Box<dyn dynamic_runner::Testable>> { 18 self.0.split(" ").map(|word| 19 Box::new(IsFoo(word.into())) as Box<dyn dynamic_runner::Testable> 20 ).collect() 21 } 22 } 23 24 impl dynamic_runner::Testable for IsFoo { name(&self) -> String25 fn name(&self) -> String { 26 self.0.clone() 27 } 28 run(&self) -> bool29 fn run(&self) -> bool { 30 self.0 == "foo" 31 } 32 } 33 34 #[test_case] 35 const TEST_2: AllFoo = AllFoo("foo foo"); 36