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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
//! # Assertables: Rust crate of assert macros for testing
//!
//! The `assertables` Rust crate provides many assert macros
//! to help with compile-time testing and run-time reliability
//!
//! Crate:
//! [https://crates.io/crates/assertables](https://crates.io/crates/assertables)
//!
//! Docs:
//! [https://docs.rs/assertables/](https://docs.rs/assertables/)
//!
//! Repo:
//! [https://github.com/sixarm/assertables-rust-crate/](https://github.com/sixarm/assertables-rust-crate/)
//!
//!
//! ## Highlights
//!
//! Macros for values such as:
//!
//! ```ignore
//! assert_gt!(value1, value2); // value1 > value2
//! ```
//!
//! Macros for arrays, vectors, sets, bags, etc., such as:
//!
//! ```ignore
//! assert_set_subset_other!(set1, set2); // set1 is a subset of set2
//! ```
//!
//! Macros for functions such as:
//!
//! ```ignore
//! assert_fn_eq!(function, input, output); // function(input) == output
//! ```
//!
//! Macros for readers such as:
//!
//! ```ignore
//! assert_read_to_string_eq!(reader, string); // reader read to string == string
//! ```
//!
//! Macros for commands such as:
//!
//! ```ignore
//! assert_command_stdout_eq!(command, expr); // command standard output == expression
//! ```
//! 
//!
//! ## Version 6 notable improvements
//!
//! * Add debug_assert_* macros everywhere.
//!
//! * Add many documentation examples.
//!
//! * Add GPL3 license.
//!
//! 
//! ## Naming conventions
//!
//! Abbreviations:
//!
//! * `eq` means equal; `ne` means not equal.
//!
//! * `lt` means less than; `le` means less than or equal.
//!
//! * `gt` means greater than; `ge` means greater than or equal.
//!
//! Shorthands:
//!
//! * `reader` means implements `.read_to_string(…)` such as `std::io::Read`.
//!
//! * `matcher` means implements `.is_match(…)` such as `regex::Regex`.
//!
//! * `containee` means usable inside `.contains(…)` such as a `std::string::String` substring.
//!
//! * `set` means a collection such as `::std::collections::BTreeSet`.
//!
//! * `bag` means a collection such as `::std::collections::BTreeMap` which has key counts.
//!
//!
//! ## Forms for panic! versus Err()
//!
//! The macros have forms for immediate interrupts versus returning results:
//!
//! ```ignore
//! assert_gt!(a, b); // return () or panic!(…)
//!
//! assert_gt_as_result!(a, b); // return Result Ok(()) or Err(…)
//! ```
//!
//! 
//! ## Forms for default messages versus custom messages
//!
//! The macros have forms for default messages versus custom messages.
//!
//! Examples with panics:
//! 
//! ```ignore
//! assert_gt!(1, 2); // panic!("assertion failed: assert_gt(1, 2)…")
//! 
//! assert_gt!(1, 2, "message"); // panic!("message")
//! ```
//! 
//! Examples with errors:
//! 
//! ```ignore
//! assert_gt_as_result!(1, 2); // return Err("assertion failed: assert_gt(1, 2)…")
//!
//! assert_gt_as_result!(1, 2, "message"); // return Err("message")
//! ```
//!
//!
//! ## Forms for comparing an expression versus an equivalent
//!
//! Some macros have forms for comparing to an expression (`expr`) versus an equivalent (`other`):
//!
//! ```ignore
//! assert_read_to_string_eq!(reader, expr); // reader.read_to_string() == expr
//!
//! assert_read_to_string_eq_other!(reader1, reader2); // reader1.read_to_string() == reader2.read_to_string()
//! ```
//!
//!
//! ## assert_* for values
//!
//! Compare values.
//!
//! * `assert_eq!(a, b)` ~ a == b
//!
//! * `assert_ne!(a, b)` ~ a != b
//!
//! * `assert_lt!(a, b)` ~ a < b
//!
//! * `assert_le!(a, b)` ~ a <= b
//!
//! * `assert_gt!(a, b)` ~ a > b
//!
//! * `assert_ge!(a, b)` ~ a >= b
//!
//!
//! ## assert_set_* for set collection comparisons
//!
//! These macros help with comparison of set parameters, such as two arrays or
//! two vectors. where the item order does not matter, and the item count does
//! not matter. The macros convert inputs into HashSet iterators.
//!
//! * `assert_set_eq_other!(a, b)` ~ set a == set b
//!
//! * `assert_set_ne_other!(a, b)` ~ set a != set b
//!
//! * `assert_set_subset_other!(a, b)` ~ set a ⊆ set b
//!
//! * `assert_set_superset_other!(a, b)` ~ set a ⊇ set b
//!
//! * `assert_set_joint!(a, b)` ~ set a is joint with set b
//!
//! * `assert_set_disjoint!(a, b)` ~ set a is disjoint with set b
//!
//!
//! ## assert_bag_* for bag collection comparisons
//!
//! These macros help with comparison of bag parameters, such as comparison of
//! two arrays or two vectors, where the item order does not matter, and the
//! item count does matter. The macros convert inputs into HashMap iterators.
//!
//! * `assert_bag_eq_other(a, b)` ~ bag a == bag b
//!
//! * `assert_bag_ne_other(a, b)` ~ bag a != bag b
//!
//! * `assert_bag_subbag(a, b)` ~ bag a ⊆ bag b
//!
//! * `assert_bag_superbag(a, b)` ~ bag a ⊇ bag b
//!
//!
//! ## assert_fn_* for function return comparisons
//!
//! * `assert_fn_eq!(f, a, b)` ~ f(a) == b
//!
//! * `assert_fn_eq_other!(f, a, b)` ~ f(a) == f(b)
//!
//! * `assert_fn_ne!(f, a, b)` ~ f(a) != b
//!
//! * `assert_fn_ne_other!(f, a, b)` ~ f(a) != f(b)
//!
//! * `assert_fn_lt!(f, a, b)` ~ f(a) < v
//!
//! * `assert_fn_lt_other!(f, a, b)` ~ f(a) < f(b)
//!
//! * `assert_fn_le!(f, a, b)` ~ f(a) <= b
//!
//! * `assert_fn_le_other!(f, a, b)` ~ f(a) <= f(b)
//!
//! * `assert_fn_gt!(f, a, b)` ~ f(a) > b
//!
//! * `assert_fn_gt_other!(f, a, b)` ~ f(a) > f(b)
//!
//! * `assert_fn_ge!(f, a, b)` ~ f(a) >= b
//!
//! * `assert_fn_ge_other!(f, a, b)` ~ f(a) >= f(b)
//!
//!
//! ## assert_fn_ok_* for function Ok() comparisons
//!
//! ### Compare with expr
//! 
//! * `assert_fn_ok_eq!(f, a, b)` ~ f(a).unwrap() == b
//!
//! * `assert_fn_ok_ne!(f, a, b)` ~ f(a).unwrap() != b
//! 
//! * `assert_fn_ok_lt!(f, a, b)` ~ f(a).unwrap() < b
//!
//! * `assert_fn_ok_le!(f, a, b)` ~ f(a).unwrap() <= b
//! 
//! * `assert_fn_ok_gt!(f, a, b)` ~ f(a).unwrap() > b
//! 
//! * `assert_fn_ok_gt!(f, a, b)` ~ f(a).unwrap() > b
//!
//! ### Compare with other
//! 
//! * `assert_fn_ok_eq_other!(f, a, b)` ~ f(a).unwrap() == f(b).unwrap()
//!
//! * `assert_fn_ok_ne_other!(f, a, b)` ~ f(a).unwrap() != f(b).unwrap()
//!
//! * `assert_fn_ok_lt_other!(f, a, b)` ~ f(a).unwrap() < f(b).unwrap()
//!
//! * `assert_fn_ok_le_other!(f, a, b)` ~ f(a).unwrap() <= f(b).unwrap()
//!
//! * `assert_fn_ok_gt_other!(f, a, b)` ~ f(a).unwrap() > f(b).unwrap()
//!
//! * `assert_fn_ok_gt_other!(f, a, b)` ~ f(a).unwrap() > f(b).unwrap()
//!
//!
//! ## assert_fn_err_* for function Err() comparisons
//! 
//! ### with expr
//!
//! * `assert_fn_err_eq!(f, a, b)` ~ f(a).unwrap_err() == b
//!
//! * `assert_fn_err_ne!(f, a, b)` ~ f(a).unwrap_err() != b
//!
//! * `assert_fn_err_lt!(f, a, b)` ~ f(a).unwrap_err() < b
//!
//! * `assert_fn_err_le!(f, a, b)` ~ f(a).unwrap_err() <= b
//!
//! * `assert_fn_err_gt!(f, a, b)` ~ f(a).unwrap_err() > b
//!
//! * `assert_fn_err_ge!(f, a, b)`~ f(a).unwrap_err() >= b
//!
//! 
//! ### with other
//! 
//! * `assert_fn_err_eq_other!(f, a, b)` ~ f(a).unwrap_err() == f(b).unwrap_err()
//!
//! * `assert_fn_err_ne_other!(f, a, b)` ~ f(a).unwrap_err() != f(b).unwrap_err()
//!
//! * `assert_fn_err_lt_other!(f, a, b)` ~ f(a).unwrap_err() < f(b).unwrap_err()
//!
//! * `assert_fn_err_le_other!(f, a, b)` ~ f(a).unwrap_err() <= f(b).unwrap_err()
//!
//! * `assert_fn_err_gt_other!(f, a, b)` ~ f(a).unwrap_err() > f(b).unwrap_err()
//!
//! * `assert_fn_err_ge_other!(f, a, b)`~ f(a).unwrap_err() >= f(b).unwrap_err()
//!
//!
//! ## assert_read_to_string_* for std::io::Read comparisons
//!
//! These macros help with readers, such as file handles, byte
//! arrays, input streams, and the trait std::io::Read.
//!
//! * `assert_read_to_string_eq!(a, b)` ~ a.read_to_string() == b
//!
//! * `assert_read_to_string_ne!(a, b)` ~ a.read_to_string() != b
//!
//! * `assert_read_to_string_lt!(a, b)` ~ a.read_to_string() < b
//!
//! * `assert_read_to_string_le!(a, b)` ~ a.read_to_string() <= b
//!
//! * `assert_read_to_string_gt!(a, b)` ~ a.read_to_string() > b
//!
//! * `assert_read_to_string_ge!(a, b)` ~ a.read_to_string() >= b
//!
//! * `assert_read_to_string_eq_other!(a, b)` ~ a.read_to_string() == b.read_to_string()
//!
//! * `assert_read_to_string_ne_other!(a, b)` ~ a.read_to_string() != b.read_to_string()
//!
//! * `assert_read_to_string_lt_other!(a, b)` ~ a.read_to_string() < b.read_to_string()
//!
//! * `assert_read_to_string_le_other!(a, b)` ~ a.read_to_string() <= b.read_to_string()
//!
//! * `assert_read_to_string_gt_other!(a, b)` ~ a.read_to_string() > b.read_to_string()
//!
//! * `assert_read_to_string_ge_other!(a, b)` ~ a.read_to_string() >= b.read_to_string()
//!
//!
//! ## assert_command_ for process command comparisons
//!
//! Using standard output a.k.a. stdout:
//!
//! * `assert_command_stdout_eq!(command, value)` ~ String::from_utf8(command.output().unwrap().stdout).unwrap() == value
//!
//! * `assert_command_stdout_eq_other!(command, command)` ~ String::from_utf8(command.output().unwrap().stdout).unwrap() == String::from_utf8(command.output().unwrap().stdout).unwrap()
//!
//! * `assert_command_stdout_contains!(command, containee)` ~ String::from_utf8(command.output().unwrap().stdout).unwrap().contains(containee)
//!
//! * `assert_command_stdout_matches!(command, matcher)` ~ regex.is_match(String::from_utf8(command.output().unwrap().stdout).unwrap())
//!
//! Using standard error a.k.a. stderr:
//!
//! * `assert_command_stderr_eq!(command, value)` ~ String::from_utf8(command.output().unwrap().stderr).unwrap() == value
//!
//! * `assert_command_stderr_eq_other!(command, command)` ~ String::from_utf8(command.output().unwrap().stderr).unwrap() == String::from_utf8(command.output().unwrap().stdout).unwrap()
//!
//! * `assert_command_stderr_contains!(command, containee)` ~ String::from_utf8(command.output().unwrap().stderr).unwrap().contains(containee)
//!
//! * `assert_command_stderr_matches!(command, matcher)` ~ regex.is_match(String::from_utf8(command.output().unwrap().stderr).unwrap())
//!
//!
//! ## assert_program_args_ for process command comparisons created via program name and args interator
//!
//! Using standard output a.k.a. stdout:
//!
//! * `assert_program_args_stdout_eq!(program, args, value)` ~ String::from_utf8(Command::new(program).args(args)..output().unwrap().stdout).unwrap() == value
//!
//! * `assert_program_args_stdout_eq_other!(program, args, program, args)` ~ String::from_utf8(Command::new(program).args(args)..output().unwrap().stdout).unwrap() == String::from_utf8(Command::new(program).args(args)..output().unwrap().stdout).unwrap()
//!
//! * `assert_program_args_stdout_contains!(program, args, containee)` ~ String::from_utf8(Command::new(program).args(args)..output().unwrap().stdout).unwrap().contains(containee)
//!
//! * `assert_program_args_stdout_matches!(program, args, matcher)` ~ regex.is_match(String::from_utf8(Command::new(program).args(args)..output().unwrap().stdout).unwrap())
//!
//! Using standard error a.k.a. stderr:
//!
//! * `assert_program_args_stderr_eq!(program, args, value)` ~ String::from_utf8(Command::new(program).args(args)..output().unwrap().stderr).unwrap() == value
//!
//! * `assert_program_args_stderr_eq_other!(program, args, program, args)` ~ String::from_utf8(Command::new(program).args(args)..output().unwrap().stderr).unwrap() == String::from_utf8(Command::new(program).args(args)..output().unwrap().stdout).unwrap()
//!
//! * `assert_program_args_stderr_contains!(program, args, containee)` ~ String::from_utf8(Command::new(program).args(args)..output().unwrap().stderr).unwrap().contains(containee)
//!
//! * `assert_program_args_stderr_matches!(program, args, matcher)` ~ regex.is_match(String::from_utf8(Command::new(program).args(args)..output().unwrap().stderr).unwrap())
//!
//!
//! ## Tracking
//!
//! * Package: assertables-rust-crate
//! * Version: 6.0.1
//! * Created: 2021-03-30T15:47:49Z
//! * Updated: 2023-01-10T21:34:22Z
//! * License: MIT or Apache-2.0 or GPL-2.0-or-later or contact us for custom license
//! * Contact: Joel Parker Henderson (joel@sixarm.com)

// Assert truth
pub mod assert; // (provided by Rust `std`)

// Assert value comparison
pub mod assert_eq; // (provided by Rust `std`)
pub mod assert_ne;
pub mod assert_lt;
pub mod assert_le;
pub mod assert_gt;
pub mod assert_ge;

// Assertable iterator-related set-based comparison
pub mod assert_set_eq_other;
pub mod assert_set_ne_other;
pub mod assert_set_subset_other; 
pub mod assert_set_superset_other; 
pub mod assert_set_joint;
pub mod assert_set_disjoint;

// Assertable iterator-related bag-based comparison
pub mod assert_bag_eq_other;
pub mod assert_bag_ne_other;
pub mod assert_bag_subbag_other; 
pub mod assert_bag_superbag_other; 

// Assert function return versus value
pub mod assert_fn_eq;
pub mod assert_fn_ne;
pub mod assert_fn_lt;
pub mod assert_fn_le;
pub mod assert_fn_gt;
pub mod assert_fn_ge;

// Assert function return versus other
pub mod assert_fn_eq_other;
pub mod assert_fn_ne_other;
pub mod assert_fn_lt_other;
pub mod assert_fn_le_other;
pub mod assert_fn_gt_other;
pub mod assert_fn_ge_other;

// Assert function Ok() versus value
pub mod assert_fn_ok_eq;
pub mod assert_fn_ok_ne;
pub mod assert_fn_ok_lt;
pub mod assert_fn_ok_le;
pub mod assert_fn_ok_gt;
pub mod assert_fn_ok_ge;

// Assert function Ok() versus other
pub mod assert_fn_ok_eq_other;
pub mod assert_fn_ok_ne_other;
pub mod assert_fn_ok_lt_other;
pub mod assert_fn_ok_le_other;
pub mod assert_fn_ok_gt_other;
pub mod assert_fn_ok_ge_other;

// Assert function Err() versus value
pub mod assert_fn_err_eq;
pub mod assert_fn_err_ne;
pub mod assert_fn_err_lt;
pub mod assert_fn_err_le;
pub mod assert_fn_err_gt;
pub mod assert_fn_err_ge;

// Assert function Err() versus other
pub mod assert_fn_err_eq_other;
pub mod assert_fn_err_ne_other;
pub mod assert_fn_err_lt_other;
pub mod assert_fn_err_le_other;
pub mod assert_fn_err_gt_other;
pub mod assert_fn_err_ge_other;

// Assert std::io::read comparisons versus value
pub mod assert_read_to_string_eq;
pub mod assert_read_to_string_ne;
pub mod assert_read_to_string_lt;
pub mod assert_read_to_string_le;
pub mod assert_read_to_string_gt;
pub mod assert_read_to_string_ge;

// Assert std::io::read comparisons versus other
pub mod assert_read_to_string_eq_other;
pub mod assert_read_to_string_ne_other;
pub mod assert_read_to_string_lt_other;
pub mod assert_read_to_string_le_other;
pub mod assert_read_to_string_gt_other;
pub mod assert_read_to_string_ge_other;

// Assert std::io::read specializations
pub mod assert_read_to_string_contains;
pub mod assert_read_to_string_matches;

// Assert command stdout
pub mod assert_command_stdout_eq;
pub mod assert_command_stdout_eq_other;

// Assert command stdout specializations
pub mod assert_command_stdout_contains;
pub mod assert_command_stdout_matches;

// Assert command stderr
pub mod assert_command_stderr_eq;
pub mod assert_command_stderr_eq_other;

// Assert command stderr specializations
pub mod assert_command_stderr_contains;
pub mod assert_command_stderr_matches;

// Assert program args stdout
pub mod assert_program_args_stdout_eq;
pub mod assert_program_args_stdout_eq_other;

// Assert program args stdout specializations
pub mod assert_program_args_stdout_contains;
pub mod assert_program_args_stdout_matches;

// Assert program args stderr
pub mod assert_program_args_stderr_eq;
pub mod assert_program_args_stderr_eq_other;

// Assert program args stderr specializations
pub mod assert_program_args_stderr_contains;
pub mod assert_program_args_stderr_matches;