From d1262390573b758ac4aa610eff96a1b5dcb9f3d6 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 28 Jan 2019 19:45:40 +0000 Subject: Add assert_any_ok macro to unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes we cannot use assert_ok! as we can’t compare the Ok value (or do not want to). For these cases, this patch adds the new assert_any_ok macro to use instead of assert!(x.is_ok()). The advantage is that the error information is not discarded but printed in a helpful error message. --- tests/pws.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/pws.rs') diff --git a/tests/pws.rs b/tests/pws.rs index 3ec7e38..32dc8f7 100644 --- a/tests/pws.rs +++ b/tests/pws.rs @@ -46,12 +46,12 @@ fn enable(device: DeviceWrapper) { CommandError::WrongPassword, device.get_password_safe(&(USER_PASSWORD.to_owned() + "123")) ); - assert!(device.get_password_safe(USER_PASSWORD).is_ok()); + assert_any_ok!(device.get_password_safe(USER_PASSWORD)); assert_cmd_err!( CommandError::WrongPassword, device.get_password_safe(ADMIN_PASSWORD) ); - assert!(device.get_password_safe(USER_PASSWORD).is_ok()); + assert_any_ok!(device.get_password_safe(USER_PASSWORD)); } #[test_device] -- cgit v1.2.1