Crates.io | chek |
lib.rs | chek |
version | 0.1.0 |
source | src |
created_at | 2019-06-25 02:05:33.741091 |
updated_at | 2019-06-25 02:05:33.741091 |
description | An assertions library. |
homepage | https://github.com/thomcc/chek |
repository | https://github.com/thomcc/chek |
max_upload_size | |
id | 143364 |
size | 65,173 |
chek
: macros for checking things.This is essentially a set of more fully-featured assert macros along the lines
of assert_eq!
, assert_ne!
, etc. It provides better output than just
performing a comparison in the assert!(...)
body, in that it includes the
values of the arguments on output. Unlike assert_eq!
/assert_ne!
, it also
will log the expression strings that produced the value.
It's the successor to my more-asserts
crate, which is somewhat unpleasant to use
in rust 2018 without a #[macro_use] extern crate ...
, due to the long module name.
Additionally, it is no_std compatible in all configurations.
inline_panics
This changes the assertions to panic directly, instead of calling a separate
function which performs the panic. This results in better error reporting in the
panic itself (it will report the correct line number / file instead of reporting
that the panic happened inside the chek
crate), at the cost of some additional
code bloat.
This is on by default.
The following macros all take optional formatting message args as well, e.g.
check::lt!(a, b, "it should have been less because of: {}", thing)
. Note that
even if this is provided, a
and b
will still be logged, so you don't need to
do that manually.
chek::less!(a, b)
: Equivalent to assert!(a < b)
, but with better output on failure
chek::debug_less!
.chek::lt!
and chek::debug_lt!
for the debug_assertions-only version.chek::less_or_equal!(a, b)
: Equivalent to assert!(a <= b)
, but with better output on failure
chek::less_or_equal!
.chek::le!
and chek::debug_le!
for the debug_assertions-only version.chek::greater!(a, b)
: Equivalent to assert!(a > b)
, but with better output on failure
chek::debug_greater!
.chek::gt!
and chek::debug_gt!
for the debug_assertions-only version.chek::greater_or_equal!(a, b)
: Equivalent to assert!(a >= b)
, but with better output on failure
chek::debug_greater_or_equal!
.chek::ge!
and chek::debug_ge!
for the debug_assertions-only version.chek::equal!(a, b)
: Equivalent to assert_eq!(a, b)
, but with better output on failure.
chek::debug_equal!
.chek::eq!
and chek::debug_eq!
for the debug_assertions-only version.chek::not_equal!(a, b)
: Equivalent to assert_ne!(a, b)
, but with better output on failure.
chek::debug_not_equal!
.chek::ne!
and chek::debug_ne!
for the debug_assertions-only version.chek::almost_zero!(a)
: Similar to assert!(almost::zero(a))
, but with better output on failure.
chek::debug_almost_zero!
.almost
crate. See the almost::zero
documentation documentation for more details.chek::not_almost_zero!(a)
: Similar to assert!(!almost::zero(a))
, but with better output on failure.
chek::debug_not_almost_zero!
.almost
crate. See the almost::zero
documentation documentation for more details.chek::almost_equal!(a, b)
: Equivalent to assert!(almost::equal(a, b))
, but with better output on failure.
a
or b
is a hard-coded constant zero! instead, use chek::almost_zero!(v)
.chek::debug_almost_equal!
.almost
crate. See the almost::equal
documentation documentation for more details.chek::not_almost_equal!(a, b)
: Equivalent to assert!(!almost::equal(a, b))
, but with better output on failure.
a
or b
is a hard-coded constant zero! instead, use chek::not_almost_zero!(v)
.chek::debug_not_almost_equal!
.almost
crate. See the almost::equal
documentation documentation for more details.chek::almost_zero_with_tolerance!(a)
: Similar to assert!(almost::zero_with_tolerance(a, b, tol))
, but with better output on failure.
chek::debug_almost_zero_with_tolerance!
.almost
crate. See the almost::zero_with_tolerance
documentation documentation for more details.chek::not_almost_zero_with_tolerance!(a)
: Similar to assert!(!almost::zero_with_tolerance(a, b, tol))
, but with better output on failure.
chek::debug_not_almost_zero_with_tolerance!
.almost
crate. See the almost::zero_with_tolerance
documentation documentation for more details.chek::debug_unreachable_unchecked!()
: Unsafe. Similar to std::hint::unreachable_unchecked
, but panics in debug builds if it's hit.
chek::debug_unreachable!()
: Equivalent to the unreachable!
macro but replaced with a no-op in release builds.