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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
//! Panicking assertion helpers for tests (in the spirit of Go’s
//! [testify/assert](https://pkg.go.dev/github.com/stretchr/testify/assert)).
//!
//! Import the names you need from this module (`suitecase::assert`):
//!
//! ```
//! use suitecase::assert::{equal, contains, assert_ok};
//! ```
//!
//! # When to use
//!
//! Use these inside [`#[test]`](https://doc.rust-lang.org/reference/attributes/testing.html#the-test-attribute)
//! functions, suite case bodies, or anywhere you want a **named** check that **fails the test by
//! panicking** with a clear message. They complement `assert!` / `assert_eq!` with richer diagnostics
//! for common patterns (collections, errors, floats, options, ordering, …).
//!
//! # Panics and caller location
//!
//! Every public function in this module **panics** when its condition is not met (see each item’s
//! **Panics** section). Functions are annotated with [`#[track_caller]`](https://doc.rust-lang.org/std/panic/struct.Location.html),
//! so the panic points at the **call site** in your test, not inside this crate.
//!
//! # Submodules
//!
//! Implementation is split across private submodules (`boolean`, `collections`, `equality`, …);
//! every public helper is re-exported from this module so you can use a flat import path.
//!
//! | Subdirectory | Role |
//! |--------------|------|
//! | `boolean` | `true_`, `false_`, and `_with_msg` variants |
//! | `collections` | Strings, slices, maps, multiset subset / equality |
//! | `equality` | `equal`, `not_equal`, `equal_values`, messages |
//! | `errors` | [`std::error::Error`] chains, downcasts, I/O kinds |
//! | `floats` | Absolute delta and relative epsilon for floats |
//! | `fs` | File and directory existence |
//! | `option_result` | [`Option`], [`Result`], “is zero” checks |
//! | `ordering` | Comparisons and monotonic slices |
//! | `panic` | Expect panics / no panic, substring match |
//! | `pointer` | Same allocation (`std::sync::Arc`, `std::sync::Weak`, references) |
//! | `time` | [`std::time::Duration`] tolerances |
//!
//! Root-level helpers such as [`fail`], [`condition`], and [`same`] are defined in this module.
//!
//! # Example
//!
//! ```
//! use suitecase::assert::{contains_str, equal, assert_ok};
//!
//! let value = assert_ok(Ok::<_, &str>(42));
//! equal(&value, &42);
//! contains_str("hello world", "world");
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Fails the test immediately with `msg`.
///
/// # Panics
///
/// Always panics.
///
/// # Examples
///
/// ```should_panic
/// use suitecase::assert::fail;
///
/// fail("expected failure");
/// ```
!
/// Fails the test immediately with a formatted message.
///
/// # Panics
///
/// Always panics.
///
/// # Examples
///
/// ```should_panic
/// use suitecase::assert::fail_fmt;
///
/// fail_fmt(format_args!("n={}", 3));
/// ```
!
/// Asserts that `ok` is `true`, otherwise fails with `msg`.
///
/// # Panics
///
/// Panics when `ok` is `false`.
///
/// # Examples
///
/// ```
/// use suitecase::assert::condition;
///
/// condition(2 > 1, "ordering");
/// ```
/// Asserts that `f()` returns `true`, otherwise fails with `msg`.
///
/// # Panics
///
/// Panics when `f()` is `false`.
///
/// # Examples
///
/// ```
/// use suitecase::assert::condition_fn;
///
/// condition_fn(|| 1 + 1 == 2, "math");
/// ```
/// Asserts that `a` and `b` point to the same allocation (see [`same_ref`]).
///
/// # Panics
///
/// Panics when the two references do not point to the same allocation.
///
/// # Examples
///
/// ```
/// use suitecase::assert::same;
///
/// let x = 1_i32;
/// same(&x, &x);
/// ```
Sized>
/// Asserts that `a` and `b` do not point to the same allocation (see [`not_same_ref`]).
///
/// # Panics
///
/// Panics when the two references point to the same allocation.
///
/// # Examples
///
/// ```
/// use suitecase::assert::not_same;
///
/// let a = 1_i32;
/// let b = 1_i32;
/// not_same(&a, &b);
/// ```
Sized>