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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use Infallible;
/// A trait that represents a property being tested.
///
/// The `Prove` trait is the mechanism by which `checkito` determines whether a
/// property test has passed or failed.
///
/// The outcome of the test is determined by the `Result` returned by the
/// [`Prove::prove`] method. An `Ok` variant signifies a pass, while an `Err`
/// variant signifies a failure. Any `panic` within the test function is also
/// treated as a failure.
///
/// # Provided Implementations
///
/// `checkito` provides implementations for common return types:
///
/// - **`()`**: A function that returns unit `()` will always pass (unless it
/// panics). This is useful for tests that use `assert!` macros for their
/// checks.
/// - **`bool`**: A function that returns `true` passes, and one that returns
/// `false` fails.
/// - **`Result<T, E>`**: A function that returns `Ok(T)` passes, and one that
/// returns `Err(E)` fails. The success and error types can be anything.
///
/// # Examples
///
/// Using `()` with `assert!`:
/// ```
/// # use checkito::check;
/// #[check(0..100)]
/// fn test_with_assert(x: i32) {
/// assert!(x < 100); // This function implicitly returns `()`
/// }
/// ```
///
/// Using `bool`:
/// ```
/// # use checkito::check;
/// #[check(0..100)]
/// fn test_with_bool(x: i32) -> bool {
/// x < 100
/// }
/// ```
///
/// Using `Result`:
/// ```
/// # use checkito::check;
/// #[check(0..100)]
/// fn test_with_result(x: i32) -> Result<(), &'static str> {
/// if x < 100 {
/// Ok(())
/// } else {
/// Err("x was not less than 100")
/// }
/// }
/// ```