Skip to content

Commit

Permalink
Add namespace, to enable explicit "use" case
Browse files Browse the repository at this point in the history
  • Loading branch information
joelparkerhenderson committed Sep 27, 2024
1 parent d8ed5ff commit 6353c77
Show file tree
Hide file tree
Showing 161 changed files with 461 additions and 455 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "assertables"
version = "8.9.0"
version = "8.10.0"
authors = ["Joel Parker Henderson <[email protected]>"]
edition = "2021"
description = "Assertables: assert macros for better testing, debugging, quality assurance, and runtime reliability."
Expand Down
112 changes: 56 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,100 +21,100 @@ The assertables crate provides many more, so you can write smarter tests.

For values:

* [`assert_lt!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_lt.html) `// less than`
* [`assert_le!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_le.html) `// less than or equal`
* [`assert_gt!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_gt.html) `// greater than`
* [`assert_ge!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_ge.html) `// greater than or equal`
* [`assert_lt!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_lt.html) `// less than`
* [`assert_le!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_le.html) `// less than or equal`
* [`assert_gt!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_gt.html) `// greater than`
* [`assert_ge!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_ge.html) `// greater than or equal`

For approximation:

* [`assert_approx_eq!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_approx_eq.html)
* [`assert_approx_ne!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_approx_ne.html)
* [`assert_approx_eq!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_approx_eq.html)
* [`assert_approx_ne!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_approx_ne.html)

For strings:

* [`assert_starts_with!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_starts_with.html)
* [`assert_ends_with!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_ends_with.html)
* [`assert_starts_with!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_starts_with.html)
* [`assert_ends_with!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_ends_with.html)

For matching:

* [`assert_contains!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_contains.html)
* [`assert_is_match!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_is_match.html)
* [`assert_contains!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_contains.html)
* [`assert_is_match!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_is_match.html)

For infix operators:

* [`assert_infix!(a == b)`](https://docs.rs/assertables/latest/assertables/macro.assert_infix.html)
* [`assert_infix!(a && b)`](https://docs.rs/assertables/latest/assertables/macro.assert_infix.html)
* [`assert_infix!(a == b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_infix.html)
* [`assert_infix!(a && b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_infix.html)

For nearness:

* [`assert_in_delta!(a, b, delta)`](https://docs.rs/assertables/latest/assertables/macro.assert_in_delta.html)
* [`assert_in_epsilon!(a, b, epsilon)`](https://docs.rs/assertables/latest/assertables/macro.assert_in_epsilon.html)
* [`assert_in_delta!(a, b, delta)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_in_delta.html)
* [`assert_in_epsilon!(a, b, epsilon)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_in_epsilon.html)

For Result Ok/Err:

* [`assert_ok!(a)`](https://docs.rs/assertables/latest/assertables/macro.assert_ok.html)
* [`assert_ok_eq!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_ok_eq.html)
* [`assert_ok_eq_expr!(a, expr)`](https://docs.rs/assertables/latest/assertables/macro.assert_ok_eq_expr.html)
* [`assert_ok_ne!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_ok_ne.html)
* [`assert_ok_ne_expr!(a, expr)`](https://docs.rs/assertables/latest/assertables/macro.assert_ok_ne_expr).html)
* [`assert_err!(a)`](https://docs.rs/assertables/latest/assertables/macro.assert_err.html)
* [`assert_ok!(a)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_ok.html)
* [`assert_ok_eq!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_ok_eq.html)
* [`assert_ok_eq_expr!(a, expr)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_ok_eq_expr.html)
* [`assert_ok_ne!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_ok_ne.html)
* [`assert_ok_ne_expr!(a, expr)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_ok_ne_expr.html)
* [`assert_err!(a)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_err.html)

For Option Some/None:

* [`assert_some!(a)`](https://docs.rs/assertables/latest/assertables/macro.assert_some.html)
* [`assert_some_eq!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_some_eq.html)
* [`assert_some_eq_expr!(a, expr)`](https://docs.rs/assertables/latest/assertables/macro.assert_some_eq_expr.html)
* [`assert_some_ne!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_some_ne.html)
* [`assert_some_ne_expr!(a, expr)`](https://docs.rs/assertables/latest/assertables/macro.assert_some_ne_expr.html)
* [`assert_none!(a)`](https://docs.rs/assertables/latest/assertables/macro.assert_none.html)
* [`assert_some!(a)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_some.html)
* [`assert_some_eq!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_some_eq.html)
* [`assert_some_eq_expr!(a, expr)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_some_eq_expr.html)
* [`assert_some_ne!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_some_ne.html)
* [`assert_some_ne_expr!(a, expr)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_some_ne_expr.html)
* [`assert_none!(a)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_none.html)

For Poll Ready/Pending:

* [`assert_ready!(a)`](https://docs.rs/assertables/latest/assertables/macro.assert_ready.html)
* [`assert_ready_eq!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_ready_eq.html)
* [`assert_ready_eq_expr!(a, expr)`](https://docs.rs/assertables/latest/assertables/macro.assert_ready_eq_expr.html)
* [`assert_ready_ne!(a, b)`](https://docs.rs/assertables/latest/assertables/macro.assert_ready_ne.html)
* [`assert_ready_ne_expr!(a, expr)`](https://docs.rs/assertables/latest/assertables/macro.assert_ready_ne_expr.html)
* [`assert_pending!(a)`](https://docs.rs/assertables/latest/assertables/macro.assert_pending.html)
* [`assert_ready!(a)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_ready.html)
* [`assert_ready_eq!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_ready_eq.html)
* [`assert_ready_eq_expr!(a, expr)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_ready_eq_expr.html)
* [`assert_ready_ne!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_ready_ne.html)
* [`assert_ready_ne_expr!(a, expr)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_ready_ne_expr.html)
* [`assert_pending!(a)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_pending.html)

For collections such as arrays, vectors, maps, sets:

* [`assert_set_subset!(collection1, collection2)`](https://docs.rs/assertables/latest/assertables/macro.assert_set_subset.html)
* [`assert_set_disjoint!(collection1, collection2)`](https://docs.rs/assertables/latest/assertables/macro.assert_set_disjoint.html)
* [`assert_set_subset!(collection1, collection2)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_set_subset.html)
* [`assert_set_disjoint!(collection1, collection2)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_set_disjoint.html)

For file system paths and input/output readers:

* [`assert_fs_read_to_string_eq!(path1, path2)`](https://docs.rs/assertables/latest/assertables/macro.assert_fs_read_to_string_eq.html)
* [`assert_io_read_to_string_eq!(reader1, reader2)`](https://docs.rs/assertables/latest/assertables/macro.assert_io_read_to_string_eq.html)
* [`assert_fs_read_to_string_eq!(path1, path2)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_fs_read_to_string_eq.html)
* [`assert_io_read_to_string_eq!(reader1, reader2)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_io_read_to_string_eq.html)

For command capture of standard output and standard error:

* [`assert_command_stdout_eq!(command1, command2)`](https://docs.rs/assertables/latest/assertables/macro.assert_command_stdout_eq.html)
* [`assert_program_args_stdout_eq!(program1, args1, program2, args2)`](https://docs.rs/assertables/latest/assertables/macro.assert_program_args_stdout_eq.html)
* [`assert_command_stdout_eq!(command1, command2)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_command_stdout_eq.html)
* [`assert_program_args_stdout_eq!(program1, args1, program2, args2)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_program_args_stdout_eq.html)

There are many more macros that are grouped into modules.

Modules for collections, such as arrays, vectors, lists, maps:

* [`assert_set`](https://docs.rs/assertables/latest/assertables/assert_set) for set collections
* [`assert_bag`](https://docs.rs/assertables/latest/assertables/assert_bag) for bag collections
* [`assert_set`](https://docs.rs/assertables/8.9.0/assertables/assert_set) for set collections
* [`assert_bag`](https://docs.rs/assertables/8.9.0/assertables/assert_bag) for bag collections

Modules for functions:

* [`assert_fn`](https://docs.rs/assertables/latest/assertables/assert_fn) for functions in general.
* [`assert_fn_ok`](https://docs.rs/assertables/latest/assertables/assert_fn_ok) for functions that return `Result::Ok`.
* [`assert_fn_err`](https://docs.rs/assertables/latest/assertables/assert_fn_err) for functions that return `Result::Err`.
* [`assert_fn`](https://docs.rs/assertables/8.9.0/assertables/assert_fn) for functions in general.
* [`assert_fn_ok`](https://docs.rs/assertables/8.9.0/assertables/assert_fn_ok) for functions that return `Result::Ok`.
* [`assert_fn_err`](https://docs.rs/assertables/8.9.0/assertables/assert_fn_err) for functions that return `Result::Err`.

Modules for readers:

* [`assert_fs_read_to_string`](https://docs.rs/assertables/latest/assertables/assert_fs_read_to_string) for file system path contents.
* [`assert_io_read_to_string`](https://docs.rs/assertables/latest/assertables/assert_io_read_to_string) for input/output reader streams.
* [`assert_fs_read_to_string`](https://docs.rs/assertables/8.9.0/assertables/assert_fs_read_to_string) for file system path contents.
* [`assert_io_read_to_string`](https://docs.rs/assertables/8.9.0/assertables/assert_io_read_to_string) for input/output reader streams.

Modules for external calls:

* [`assert_command`](https://docs.rs/assertables/latest/assertables/assert_command) for commands with stdout/stderr.
* [`assert_program_args`](https://docs.rs/assertables/latest/assertables/assert_program_args) for programs with args with stdout/stderr.
* [`assert_command`](https://docs.rs/assertables/8.9.0/assertables/assert_command) for commands with stdout/stderr.
* [`assert_program_args`](https://docs.rs/assertables/8.9.0/assertables/assert_program_args) for programs with args with stdout/stderr.


### Top 3 benefits
Expand Down Expand Up @@ -148,9 +148,9 @@ All the assert macros have 3 forms for different purposes:

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
* [`assert_starts_with!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_starts_with.html) // panic!
* [`debug_assert_starts_with!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.debug_assert_starts_with.html) // panic! in debug mode
* [`assert_starts_with_as_result!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_starts_with_as_result.html) // return Ok or Err


### Forms for messages
Expand All @@ -162,8 +162,8 @@ All the assert macros have 2 forms for messages.

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)
* [`assert_starts_with!(a, b)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_starts_with.html)
* [`assert_starts_with!(a, b, "Your custom message here")`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_starts_with.html)


### Forms for other versus expression
Expand All @@ -175,15 +175,15 @@ Many of the assert macros have 2 forms for comparing left hand side and right ha

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)
* [`assert_io_read_to_string_eq!(reader1, reader2)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_io_read_to_string_eq.html)
* [`assert_io_read_to_string_eq_expr!(reader, expr)`](https://docs.rs/assertables/8.9.0/assertables/macro.assert_io_read_to_string_eq_expr.html)


## Tracking

* Package: assertables-rust-crate
* Version: 8.9.0
* Version: 8.10.0
* Created: 2021-03-30T15:47:49Z
* Updated: 2024-09-25T15:18:42Z
* Updated: 2024-09-27T18:25:43Z
* License: MIT or Apache-2.0 or GPL-2.0 or GPL-3.0 or contact us for more
* Contact: Joel Parker Henderson ([email protected])
4 changes: 2 additions & 2 deletions book.md
Original file line number Diff line number Diff line change
Expand Up @@ -612,13 +612,13 @@ Code:
#[macro_export]
macro_rules! assert_gt {
($a:expr, $b:expr $(,)?) => ({
match assert_gt_result!($a, $b) {
match $crate::assert_gt_result!($a, $b) {
Ok(()) => (),
Err(err) => panic!("{}", err),
}
});
($a:expr, $b:expr, $($message:tt)+) => ({
match assert_gt!($a, $b) {
match $crate::assert_gt!($a, $b) {
Ok(()) => (),
Err(_err) => panic!("{}", $($message)+),
}
Expand Down
4 changes: 2 additions & 2 deletions src/assert_approx_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ mod tests {
#[macro_export]
macro_rules! assert_approx_eq {
($a:expr, $b:expr $(,)?) => {{
match assert_approx_eq_as_result!($a, $b) {
match $crate::assert_approx_eq_as_result!($a, $b) {
Ok(()) => (),
Err(err) => panic!("{}", err),
}
}};
($a:expr, $b:expr, $($message:tt)+) => {{
match assert_approx_eq_as_result!($a, $b) {
match $crate::assert_approx_eq_as_result!($a, $b) {
Ok(()) => (),
Err(_err) => panic!("{}", $($message)+),
}
Expand Down
4 changes: 2 additions & 2 deletions src/assert_approx_ne.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ mod tests {
#[macro_export]
macro_rules! assert_approx_ne {
($a:expr, $b:expr $(,)?) => {{
match assert_approx_ne_as_result!($a, $b) {
match $crate::assert_approx_ne_as_result!($a, $b) {
Ok(()) => (),
Err(err) => panic!("{}", err),
}
}};
($a:expr, $b:expr, $($message:tt)+) => {{
match assert_approx_ne_as_result!($a, $b) {
match $crate::assert_approx_ne_as_result!($a, $b) {
Ok(()) => (),
Err(_err) => panic!("{}", $($message)+),
}
Expand Down
4 changes: 2 additions & 2 deletions src/assert_bag/assert_bag_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ mod test_as_result {
#[macro_export]
macro_rules! assert_bag_eq {
($a_collection:expr, $b_collection:expr $(,)?) => {{
match assert_bag_eq_as_result!($a_collection, $b_collection) {
match $crate::assert_bag_eq_as_result!($a_collection, $b_collection) {
Ok(()) => (),
Err(err) => panic!("{}", err),
}
}};
($a_collection:expr, $b_collection:expr, $($message:tt)+) => {{
match assert_bag_eq_as_result!($a_collection, $b_collection) {
match $crate::assert_bag_eq_as_result!($a_collection, $b_collection) {
Ok(()) => (),
Err(_err) => panic!("{}", $($message)+),
}
Expand Down
4 changes: 2 additions & 2 deletions src/assert_bag/assert_bag_ne.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ mod test_assert_x_result {
#[macro_export]
macro_rules! assert_bag_ne {
($a_collection:expr, $b_collection:expr $(,)?) => {{
match assert_bag_ne_as_result!($a_collection, $b_collection) {
match $crate::assert_bag_ne_as_result!($a_collection, $b_collection) {
Ok(()) => (),
Err(err) => panic!("{}", err),
}
}};
($a_collection:expr, $b_collection:expr, $($message:tt)+) => {{
match assert_bag_ne_as_result!($a_collection, $b_collection) {
match $crate::assert_bag_ne_as_result!($a_collection, $b_collection) {
Ok(()) => (),
Err(_err) => panic!("{}", $($message)+),
}
Expand Down
4 changes: 2 additions & 2 deletions src/assert_bag/assert_bag_subbag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ mod tests {
#[macro_export]
macro_rules! assert_bag_subbag {
($a_collection:expr, $b_collection:expr $(,)?) => {{
match assert_bag_subbag_as_result!($a_collection, $b_collection) {
match $crate::assert_bag_subbag_as_result!($a_collection, $b_collection) {
Ok(()) => (),
Err(err) => panic!("{}", err),
}
}};
($a_collection:expr, $b_collection:expr, $($message:tt)+) => {{
match assert_bag_subbag_as_result!($a_collection, $b_collection) {
match $crate::assert_bag_subbag_as_result!($a_collection, $b_collection) {
Ok(()) => (),
Err(_err) => panic!("{}", $($message)+),
}
Expand Down
4 changes: 2 additions & 2 deletions src/assert_bag/assert_bag_superbag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ mod tests {
#[macro_export]
macro_rules! assert_bag_superbag {
($a_collection:expr, $b_collection:expr $(,)?) => {{
match assert_bag_superbag_as_result!($a_collection, $b_collection) {
match $crate::assert_bag_superbag_as_result!($a_collection, $b_collection) {
Ok(()) => (),
Err(err) => panic!("{}", err),
}
}};
($a_collection:expr, $b_collection:expr, $($message:tt)+) => {{
match assert_bag_superbag_as_result!($a_collection, $b_collection) {
match $crate::assert_bag_superbag_as_result!($a_collection, $b_collection) {
Ok(()) => (),
Err(_err) => panic!("{}", $($message)+),
}
Expand Down
4 changes: 2 additions & 2 deletions src/assert_command/assert_command_stderr_contains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ mod tests {
#[macro_export]
macro_rules! assert_command_stderr_contains {
($command:expr, $containee:expr $(,)?) => {{
match assert_command_stderr_contains_as_result!($command, $containee) {
match $crate::assert_command_stderr_contains_as_result!($command, $containee) {
Ok(()) => (),
Err(err) => panic!("{}", err),
}
}};
($command:expr, $containee:expr, $($message:tt)+) => {{
match assert_command_stderr_contains_as_result!($command, $containee) {
match $crate::assert_command_stderr_contains_as_result!($command, $containee) {
Ok(()) => (),
Err(_err) => panic!("{}", $($message)+),
}
Expand Down
4 changes: 2 additions & 2 deletions src/assert_command/assert_command_stderr_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ mod tests {
#[macro_export]
macro_rules! assert_command_stderr_eq {
($a_command:expr, $b_command:expr $(,)?) => {{
match assert_command_stderr_eq_as_result!($a_command, $b_command) {
match $crate::assert_command_stderr_eq_as_result!($a_command, $b_command) {
Ok(()) => (),
Err(err) => panic!("{}", err),
}
}};
($a_command:expr, $b_command:expr, $($message:tt)+) => {{
match assert_command_stderr_eq_as_result!($a_command, $b_command) {
match $crate::assert_command_stderr_eq_as_result!($a_command, $b_command) {
Ok(()) => (),
Err(_err) => panic!("{}", $($message)+),
}
Expand Down
Loading

0 comments on commit 6353c77

Please sign in to comment.