#assert #test #testing #compare #asserts

all_asserts

A crate for multiple types of asserts that don’t exist in the standard library

3 releases (1 stable)

✓ Uses Rust 2018 edition

1.0.0 Nov 16, 2019
0.1.4 Mar 19, 2019

#98 in Development tools

Download history 14/week @ 2019-11-27 6/week @ 2019-12-04 46/week @ 2019-12-11 1/week @ 2019-12-18 8/week @ 2019-12-25 5/week @ 2020-01-01 14/week @ 2020-01-08 8/week @ 2020-01-15 2/week @ 2020-01-22 1/week @ 2020-01-29 2/week @ 2020-02-05 8/week @ 2020-02-12 15/week @ 2020-02-19 71/week @ 2020-02-26 14/week @ 2020-03-04 8/week @ 2020-03-11

71 downloads per month
Used in 2 crates

Apache-2.0

9KB
136 lines

Importing and using

Add these lines to your rust application:

#[macro_use]
extern crate all_asserts;

And now you can use the asserts wherever you like! On Panic you should get something like this (the example is from assert_lt!):

thread 'main' panicked at 'assertion failed: `(left <= right)`
  left: `100`,
 right: `200`', src/main.rs:79:5

Isn't that much better than what the current macros provide? Well, I'll leave you to decide!

Usage of the macros

The name of the assert pretty much tells you everything:

  • assert_gt!(a, b) -> Will panic if a is not greater than b
  • assert_ge!(a, b) -> Will panic if a is not greater than or equal to b
  • assert_lt!(a, b) -> Will panic if a is not less than b
  • assert_le!(a, b) -> Will panic if a is not greater than or equal to b

No runtime deps