testify_core/
test.rs

1use std::fmt::Debug;
2
3pub enum TestStatus {
4    Passed,
5    Panicked,
6
7    // The test was expected to panic, but it did not.
8    NotPanicked,
9    Failed,
10
11    // The test was expected to pass, but it failed.
12    NotFailed,
13}
14
15pub type TestFn = fn() -> TestStatus;
16
17#[derive(Debug, Clone)]
18pub struct Test {
19    pub name: String,
20    pub case: Option<String>,
21    pub tags: Vec<String>,
22    pub function: TestFn,
23}
24
25pub trait TestTermination {
26    fn success(&self) -> bool;
27}
28
29impl TestTermination for () {
30    fn success(&self) -> bool {
31        true
32    }
33}
34
35impl<T: TestTermination, E> TestTermination for Result<T, E> {
36    fn success(&self) -> bool {
37        match self {
38            Ok(r) => r.success(),
39            Err(_) => false,
40        }
41    }
42}
43
44impl<T: TestTermination> TestTermination for Option<T> {
45    fn success(&self) -> bool {
46        match self {
47            Some(r) => r.success(),
48            None => false
49        }
50    }
51}