0.5.0
Pre-release
Pre-release
New additions
-
The pattern used in
matches_pattern!can now accept method invocations:impl MyStruct { fn get_foo(&self) -> u32 {...} } verify_that!(value, matches_pattern!(MyStruct { get_foo(): eq(5) }))
-
The
unordered_elements_are!,contains_each!, andis_contained_in!macros now support map data structures such asHashMapandBTreeMap:let value = HashMap::from_iter([(1, "One"), (2, "Two")]); verify_that!(value, unordered_elements_are![(eq(2), eq("Two")), (eq(1), eq("One"))])
-
The
pointwise!matcher now explicitly supports closures, and allows supplying up to three containers:verify_that!(value, pointwise!(|v| near(v, 0.1), [1.0, 2.0, 3.0]) verify_that!(value, pointwise!(near, [1.0, 2.0, 3.0], [0.01, 0.001, 0.1])
-
There is now support for easily mapping errors from the anyhow crate to test results:
#[test] fn invokes_fallible_function() -> Result<()> { a_fallible_function().into_test_result()?; ... }
Other improvements
- Async tests should now work correctly with the
googletest::testattribute (see below). googletest::testshould now be compatible with other test attributes such astokio::test.- The syn dependency has been upgraded to major version 2.
API changes
-
The attribute macro
google_testhas been renamed totest:OLD:
#[googletest::google_test] fn should_work() -> Result<()> {...}
NEW:
#[googletest::test] fn should_work() -> Result<()> {...}
Downstream tests do not currently have to update their code. The old
google_testname has been retained as an alias, but is marked deprecated.