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
//! # Assertables: Rust crate of assert macros for testing
//!
//! The `assertables` Rust crate provides many assert macros to improve your
//! compile-time tests 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/)
//! * Contact: [joel@joelparkerhenderson.com](mailto:joel@joelparkerhenderson.com)
//!
//!
//! ## Introduction
//!
//! The Rust programming language provides a few built-in assert macros to test code:
//!
//! The Rust programming language provides a few built-in assert macros to test code:
//!
//! * `assert!()`
//! * `assert_eq!(a, b)`
//! * `assert_ne!(a, b)`
//!
//! The assertables crate provides many more, so you can write smarter tests.
//!
//! For values:
//!
//! * [`assert_lt!(a, b)`](macro@crate::assert_lt)
//! * [`assert_le!(a, b)`](macro@crate::assert_le)
//! * [`assert_gt!(a, b)`](macro@crate::assert_gt)
//! * [`assert_ge!(a, b)`](macro@crate::assert_ge)
//!
//! For numbers:
//!
//! * [`assert_in_delta!(a, b, delta)`](macro@crate::assert_in_delta)
//! * [`assert_in_epsilon!(a, b, epsilon)`](macro@crate::assert_in_epsilon)
//!
//! For strings:
//!
//! * [`assert_starts_with!(a, b)`](macro@crate::assert_starts_with)
//! * [`assert_ends_with!(a, b)`](macro@crate::assert_ends_with)
//!
//! For matching:
//!
//! * [`assert_contains!(a, b)`](macro@crate::assert_contains)
//! * [`assert_is_match!(a, b)`](macro@crate::assert_is_match)
//!
//! For infix numeric operators and infix logical operators:
//!
//! * [`assert_infix!(a == b)`](macro@crate::assert_infix)
//! * [`assert_infix!(a && b)`](macro@crate::assert_infix)
//!
//! For results:
//!
//! * [`assert_result_ok!(a)`](macro@crate::assert_result_ok)
//! * [`assert_result_ok_eq!(a)`](macro@crate::assert_result_ok_eq)
//! * [`assert_result_ok_ne!(a)`](macro@crate::assert_result_ok_ne)
//! * [`assert_result_err!(a)`](macro@crate::assert_result_err)
//!
//! For options:
//!
//! * [`assert_option_some!(a)`](macro@crate::assert_option_some)
//! * [`assert_option_none!(a)`](macro@crate::assert_option_none)
//!
//! For polls:
//!
//! * [`assert_poll_ready!(a)`](macro@crate::assert_poll_ready)
//! * [`assert_poll_pending!(a)`](macro@crate::assert_poll_pending)
//!
//! For collections such as arrays, vectors, maps, sets:
//!
//! * [`assert_set_subset!(collection1, collection2)`](macro@crate::assert_set_subset)
//! * [`assert_set_disjoint!(collection1, collection2)`](macro@crate::assert_set_disjoint)
//!
//! For file system paths and input/output readers:
//!
//! * [`assert_fs_read_to_string_eq!(path1, path2)`](macro@crate::assert_fs_read_to_string_eq)
//! * [`assert_io_read_to_string_eq!(reader1, reader2)`](macro@crate::assert_io_read_to_string_eq)
//!
//! For command capture of standard output and standard error:
//!
//! * [`assert_command_stdout_eq!(command1, command2)`](macro@crate::assert_command_stdout_eq)
//! * [`assert_program_args_stdout_eq!(program1, args1, program2, args2)`](macro@crate::assert_program_args_stdout_eq);
//!
//! There are many more macros that are grouped into modules.
//!
//! Modules for enums:
//!
//! * [`assert_option`](module@crate::assert_option) for `Option` {`Some`, `None`}
//! * [`assert_result`](module@crate::assert_result) for `Result` {`Ok`, `Err`}
//! * [`assert_poll`](module@crate::assert_poll) for `Poll` {`Ready`, `Pending`}
//!
//! Modules for collections, such as arrays, vectors, lists, maps:
//!
//! * [`assert_set`](module@crate::assert_set) for set collections
//! * [`assert_bag`](module@crate::assert_bag) for bag collections
//!
//! Modules for functions:
//!
//! * [`assert_fn`](module@crate::assert_fn) for functions in general.
//! * [`assert_fn_ok`](module@crate::assert_fn_ok) for functions that return Result::Ok.
//! * [`assert_fn_err`](module@crate::assert_fn_err) for functions that return Result::Err.
//!
//! Modules for readers:
//!
//! * [`assert_fs_read_to_string`](module@crate::assert_fs_read_to_string) for file system path contents.
//! * [`assert_io_read_to_string`](module@crate::assert_io_read_to_string) for input/output reader streams.
//!
//! Modules for external calls:
//!
//! * [`assert_command`](module@crate::assert_command) for commands and their stdout & stderr.
//! * [`assert_program_args`](module@crate::assert_program_args) for programs with args and their stdout & stderr.
//!
//!
//! ### Benefits
//!
//! * Your tests are more purposeful and powerful. This helps your code be more
//! reliable.
//!
//! * Your assert failures provide more information. This helps you
//! troubleshoot faster.
//!
//! * You gain runtime asserts. This helps you with validations and
//! verifications.
//!
//!
//! ### Features
//!
//! * Easy to use: each macro is well-documented with runnable examples and
//! tests.
//!
//! * Zero overhead: if you don't use a macro, then it's never compiled into
//! your code.
//!
//! * Zero dependencies: the crate has no release dependencies, and just a short list of development dependencies.
//!
//!
//! ### Naming conventions
//!
//! Abbreviations:
//!
//! * `eq` ≈ equal
//! * `ne` ≈ not equal.
//! * `lt` ≈ less than
//! * `le` ≈ less than or equal.
//! * `gt` ≈ greater than
//! * `ge` ≈ greater than or equal.
//!
//! Shorthands:
//!
//! * `path` ≈ implements `AsRef<Path>`
//! * `reader` ≈ method `reader.read*()`
//! * `readee` ≈ function `read*(readee)`
//! * `matcher` ≈ such as `matcher.is_match(matchee)`
//! * `container` ≈ such as `container.contains(containee)`
//! * `set` ≈ a collection such as `::std::collections::BTreeSet`
//! * `bag` ≈ a collection such as `::std::collections::BTreeMap`
//!
//! Samples:
//!
//! * `alfa, bravo, charlie, …`
//! * `lorem, ipsum, dolor, …`
//! * `foo, goo, hoo, …`
//!
//!
//! ## Forms
//!
//!
//! ### Forms for panic versus error
//!
//! All the assert macros have 3 forms for different purposes:
//!
//! * Panic form for typical tests.
//! * Debug form for debugging runtimes.
//! * Result form for runtime checks, verifications, validations, etc.
//!
//! Examples:
//!
//! * [`assert_starts_with!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_starts_with.html) // panic!
//! * [`debug_assert_starts_with!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.debug_assert_starts_with.html) // panic! in debug mode
//! * [`assert_starts_with_as_result!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_starts_with_as_result.html) // return Ok or Err
//!
//!
//! ### Forms for messages
//!
//! All the assert macros have 2 forms for messages.
//!
//! * Default message form.
//! * Custom message form.
//!
//! Examples:
//!
//! * [`assert_starts_with!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_starts_with.html)
//! * [`assert_starts_with!(a, b, "Your custom message here")`](https://docs.rs/assertables/latest/assertables/macro.assert_starts_with.html)
//!
//!
//! ### Forms for other versus expression
//!
//! Many of the assert macros have 2 forms for comparing left hand side and right hand side.
//!
//! * Comparing a LHS item to a RHS other of the same type.
//! * Comparing a LHS item to a RHS expression.
//!
//! Examples:
//!
//! * [`assert_io_read_to_string_eq!(reader1, reader2)`](https://docs.rs/assertables/latest/assertables/macro.assert_io_read_to_string_eq.html)
//! * [`assert_io_read_to_string_eq_expr!(reader, expr)`](https://docs.rs/assertables/latest/assertables/macro.assert_io_read_to_string_eq_expr.html)
//!
//!
//! ## Change highlights
//!
//! 8.6: Add `assert_poll_ready_eq`, `assert_poll_ready_ne` (planned)
//!
//! 8.5: Add `assert_option_some_eq`, `assert_option_some_ne` (planned)
//!
//! 8.4: Add `assert_result_ok_eq`, `assert_result_ok_ne`
//!
//! 8.3: Add `assert_poll_ready`, `assert_poll_pending`.
//!
//! 8.2: Add `assert_infix`.
//!
//! 8.1: Add `assert_result_ok`, `assert_result_err`, `assert_option_some`, `assert_option_none`.
//!
//! 8.0: Add `assert_fs_read_to_string_*`. Breaking change: rename `assert_read_to_string_*` macros to `assert_io_read_to_string_*`.
//!
//! 7.x: Add `assert_in_delta`, `assert_in_epsilon`. Add `assert_fn_*` macros with multiple arities.
//!
//! 6.x: Add `assert_starts_with`, `assert_ends_with`, `assert_contains`, `assert_is_match`. Add `debug_assert_*` macros everywhere.
//!
//!
//! ## Tracking
//!
//! * Package: assertables-rust-crate
//! * Version: 8.4.0
//! * Created: 2021-03-30T15:47:49Z
//! * Updated: 2024-09-11T02:11:16Z
//! * License: MIT or Apache-2.0 or GPL-2.0 or GPL-3.0 or contact us for more
//! * Contact: Joel Parker Henderson (joel@sixarm.com)
// Assert truth
pub mod assert; // (in addition to what's provided by Rust `std`)
// Assert value comparison
pub mod assert_eq; // (in addition to what's provided by Rust `std`)
pub mod assert_ge;
pub mod assert_gt;
pub mod assert_le;
pub mod assert_lt;
pub mod assert_ne;
// Assert value nearness
pub mod assert_in_delta;
pub mod assert_in_epsilon;
// Assert value matching
pub mod assert_contains;
pub mod assert_ends_with;
pub mod assert_is_match;
pub mod assert_not_contains;
pub mod assert_not_ends_with;
pub mod assert_not_match;
pub mod assert_not_starts_with;
pub mod assert_starts_with;
// For maybes
pub mod assert_result;
pub mod assert_option;
pub mod assert_poll;
// For collections
pub mod assert_set;
pub mod assert_bag;
// For functions
pub mod assert_fn;
pub mod assert_fn_ok;
pub mod assert_fn_err;
// For reading
pub mod assert_fs_read_to_string;
pub mod assert_io_read_to_string;
// For externals
pub mod assert_command;
pub mod assert_program_args;
// Experimental - work in progress - unsupported
pub mod assert_infix;