]> git.lizzy.rs Git - rust.git/blob - src/test/ui/custom_test_frameworks/dynamic.rs
Auto merge of #100845 - timvermeulen:iter_compare, r=scottmcm
[rust.git] / src / test / ui / custom_test_frameworks / dynamic.rs
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 {
13     fn name(&self) -> String {
14         String::from(self.0)
15     }
16
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 {
25     fn name(&self) -> String {
26         self.0.clone()
27     }
28
29     fn run(&self) -> bool {
30         self.0 == "foo"
31     }
32 }
33
34 #[test_case]
35 const TEST_2: AllFoo = AllFoo("foo foo");