stratis-storage / project

A holding place for issues that affect more than one repository in the project
4 stars 0 forks source link

Consider making use of assertion crates #28

Open mulkieran opened 6 years ago

mulkieran commented 6 years ago

There are a bunch of crates available that expand or improve assertions in various ways. We should consider whether any of these would be valuable to us. They vary quite a bit, and take a variety of strategies, so the question requires a bit of thought.

mulkieran commented 5 years ago

assert_that(&1).is_equal_to(&1);

let test_vec = vec![1,2,3];
assert_that(&test_vec).has_length(3);

Note that the methods available are determined by the type of the thing being asserted about.

[test]

fn expression_should_compute_correct_value { assert_that!(&1+2, eq(3)); // or more wordy ... assert_that!(&1+2, is(eq(3))); }



Note that function modify the meaning of the ```assert_that``` macro. As with spectral, there are many different assertion modifiers.

* https://crates.io/crates/pretty_assertions Colors the differences in a failed assert_eq match. Nice, but not really that useful.

* https://crates.io/crates/assert_float_eq Special assertions for floats, so probably not interesting for us.

* https://crates.io/crates/static_assertions Compile-time assertions. Might be very helpful for catching devicemapper errors.

* https://crates.io/crates/more-asserts Provides gt and lt assertions.

* https://crates.io/crates/power-assert Power Assert. pytest-alike but with minimal documentation and no dependent crates. I haven't looked at the source.

* https://crates.io/crates/assert_cmd For CLIs.

* https://crates.io/crates/adhesion Facilities for design by contract.

* https://crates.io/crates/assert_matches Flexible implementation of an ```assert_matches!``` macro. Significantly more flexible than that provided by the ```matches``` macro but identical with that in its simplest form.

* https://crates.io/crates/static_assert_macro Another compile-time assertion crate.

* https://crates.io/crates/assert_fs A framework for testing things about files.

* https://crates.io/crates/assert_cli Currently deprecated.

* https://crates.io/crates/rustspec_assertions Probably a dead end. The only dependency is rustspec which is officially almost dead.

* https://crates.io/crates/assert_approx_eq For floats.

* https://crates.io/crates/repeated-assert An assertion that keeps trying until a time-out. udev's best friend!

* https://crates.io/crates/assert_ng Really just a specialized form of pytest style assertions, for ```==``` only.

* https://crates.io/crates/assert_ne Defines an ```assert_ne``` macro. That exists in the standard library, so no need for this one.

* https://crates.io/crates/assert-type-eq Use assertions to check at compile-time possible run-time type incompatibilities.

* https://crates.io/crates/extra-asserts A toy.

* https://crates.io/crates/asserts A crate squatter.

* https://crates.io/crates/arsert An also-ran.

* https://crates.io/crates/assertions Compile-time assertions.

* https://crates.io/crates/bassert Looks like it's mostly intended to be funny.

* https://crates.io/crates/passert Another power assert macro. No dependents.

* https://crates.io/crates/nearly_eq For floats.

* https://crates.io/crates/appro-eq For floats.

* https://crates.io/crates/expect A library for constructing assertions about types.