1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! [`TestResult`]: the return type that makes `?` the single control-flow
//! operator of a test.
//!
//! A test (or any test helper) returns `TestResult`, so every fallible step
//! short-circuits with `?` and the first failure is the one reported.
use crateTestError;
/// The result type returned by `test-better` tests and helpers.
///
/// It defaults its `Ok` type to `()`, the common case for a `#[test]` function,
/// while helpers that produce a value name it explicitly (`TestResult<User>`).
///
/// # Examples
///
/// ```
/// use test_better_core::{TestError, TestResult};
///
/// fn checked_div(numerator: i32, denominator: i32) -> TestResult<i32> {
/// if denominator == 0 {
/// return Err(TestError::assertion("denominator must be non-zero"));
/// }
/// Ok(numerator / denominator)
/// }
///
/// fn test_division() -> TestResult {
/// let quotient = checked_div(10, 2)?;
/// if quotient != 5 {
/// return Err(TestError::from_expected_actual(5, quotient));
/// }
/// Ok(())
/// }
///
/// fn main() -> TestResult {
/// test_division()?;
/// Ok(())
/// }
/// ```
pub type TestResult<T = > = ;