Crate assertables

source
Expand description

§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.

§Introduction

The Rust programming language provides a few built-in assert macros to test code:

The Rust programming language provides assert macros to test code:

The assertables crate provides many more, to help you work with numbers, strings, results, options, iterators, files, commands, and more. See below for the macros.

Top benefits:

  1. You can write better tests to improve reliability and maintainability.
  2. You can handle more corner cases without needing to write custom code.
  3. You can troubleshoot faster because error messages show specifics.

Top features:

  1. Easy to use: everything is well-documented with runnable examples.
  2. Runtime savvy: all the assertables macros have runtime versions.
  3. Zero overhead: if you don’t use a macro, then it’s never compiled.

To use the macros, add this to your Cargo.toml file:

[dev-dependencies]
assertables = "*"

§Highlights

For values:

For approximations:

For groups:

For strings:

For lengths:

For matching:

For infix operators:

For nearness:

For Result Ok/Err:

For Option Some/None:

For Poll Ready/Pending:

For comparing collections that provide into_iter() such as arrays and vectors:

For file system paths and input/output readers:

For command capture of standard output and standard error:

§Modules

There are many more macros that are organized in modules.

Modules for values:

Modules for strings:

Modules for lengths:

Modules for matching:

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

Modules for Result Ok/Err:

Modules for Option Some/None:

Modules for Poll Ready/Pending:

Modules for functions:

Modules for readers:

Modules for external calls:

§Forms

All assertables macros have forms for an optional message:

All assertables macros have forms for different outcomes:

Many assertables macros have forms for comparing left hand side (LHS) and right hand side (RHS) as the same type or as an arbitrary expression:

§Tracking

  • Package: assertables-rust-crate

  • Version: 8.16.0

  • Created: 2021-03-30T15:47:49Z

  • Updated: 2024-10-08T15:07:34Z

  • 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)

Modules§

Macros§