summaryrefslogtreecommitdiff
path: root/tests/pws.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pws.rs')
-rw-r--r--tests/pws.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/pws.rs b/tests/pws.rs
index 4a2ca4f..b349558 100644
--- a/tests/pws.rs
+++ b/tests/pws.rs
@@ -49,14 +49,14 @@ fn enable(device: DeviceWrapper) {
fn drop(device: DeviceWrapper) {
{
let pws = get_pws(&device);
- assert!(pws.write_slot(1, "name", "login", "password").is_ok());
+ assert_eq!(Ok(()), pws.write_slot(1, "name", "login", "password"));
assert_eq!("name", pws.get_slot_name(1).unwrap());
let result = get_slot_name_direct(1);
assert_eq!(Ok(String::from("name")), result);
}
let result = get_slot_name_direct(1);
assert_eq!(Ok(String::from("name")), result);
- assert!(device.lock().is_ok());
+ assert_eq!(Ok(()), device.lock());
let result = get_slot_name_direct(1);
assert_eq!(Err(CommandError::NotAuthorized), result);
}
@@ -65,19 +65,19 @@ fn drop(device: DeviceWrapper) {
fn get_status(device: DeviceWrapper) {
let pws = get_pws(&device);
for i in 0..SLOT_COUNT {
- assert!(pws.erase_slot(i).is_ok(), "Could not erase slot {}", i);
+ assert_eq!(Ok(()), pws.erase_slot(i), "Could not erase slot {}", i);
}
let status = pws.get_slot_status().unwrap();
assert_eq!(status, [false; SLOT_COUNT as usize]);
- assert!(pws.write_slot(1, "name", "login", "password").is_ok());
+ assert_eq!(Ok(()), pws.write_slot(1, "name", "login", "password"));
let status = pws.get_slot_status().unwrap();
for i in 0..SLOT_COUNT {
assert_eq!(i == 1, status[i as usize]);
}
for i in 0..SLOT_COUNT {
- assert!(pws.write_slot(i, "name", "login", "password").is_ok());
+ assert_eq!(Ok(()), pws.write_slot(i, "name", "login", "password"));
}
let status = pws.get_slot_status().unwrap();
assert_eq!(status, [true; SLOT_COUNT as usize]);
@@ -86,12 +86,12 @@ fn get_status(device: DeviceWrapper) {
#[test_device]
fn get_data(device: DeviceWrapper) {
let pws = get_pws(&device);
- assert!(pws.write_slot(1, "name", "login", "password").is_ok());
+ assert_eq!(Ok(()), pws.write_slot(1, "name", "login", "password"));
assert_eq!("name", pws.get_slot_name(1).unwrap());
assert_eq!("login", pws.get_slot_login(1).unwrap());
assert_eq!("password", pws.get_slot_password(1).unwrap());
- assert!(pws.erase_slot(1).is_ok());
+ assert_eq!(Ok(()), pws.erase_slot(1));
// TODO: check error codes
assert_eq!(Err(CommandError::Undefined), pws.get_slot_name(1));
assert_eq!(Err(CommandError::Undefined), pws.get_slot_login(1));
@@ -100,7 +100,7 @@ fn get_data(device: DeviceWrapper) {
let name = "with å";
let login = "pär@test.com";
let password = "'i3lJc[09?I:,[u7dWz9";
- assert!(pws.write_slot(1, name, login, password).is_ok());
+ assert_eq!(Ok(()), pws.write_slot(1, name, login, password));
assert_eq!(name, pws.get_slot_name(1).unwrap());
assert_eq!(login, pws.get_slot_login(1).unwrap());
assert_eq!(password, pws.get_slot_password(1).unwrap());
@@ -128,17 +128,17 @@ fn write(device: DeviceWrapper) {
pws.write_slot(SLOT_COUNT, "name", "login", "password")
);
- assert!(pws.write_slot(0, "", "login", "password").is_ok());
+ assert_eq!(Ok(()), pws.write_slot(0, "", "login", "password"));
assert_eq!(Err(CommandError::Undefined), pws.get_slot_name(0));
assert_eq!(Ok(String::from("login")), pws.get_slot_login(0));
assert_eq!(Ok(String::from("password")), pws.get_slot_password(0));
- assert!(pws.write_slot(0, "name", "", "password").is_ok());
+ assert_eq!(Ok(()), pws.write_slot(0, "name", "", "password"));
assert_eq!(Ok(String::from("name")), pws.get_slot_name(0));
assert_eq!(Err(CommandError::Undefined), pws.get_slot_login(0));
assert_eq!(Ok(String::from("password")), pws.get_slot_password(0));
- assert!(pws.write_slot(0, "name", "login", "").is_ok());
+ assert_eq!(Ok(()), pws.write_slot(0, "name", "login", ""));
assert_eq!(Ok(String::from("name")), pws.get_slot_name(0));
assert_eq!(Ok(String::from("login")), pws.get_slot_login(0));
assert_eq!(Err(CommandError::Undefined), pws.get_slot_password(0));
@@ -149,8 +149,8 @@ fn erase(device: DeviceWrapper) {
let pws = get_pws(&device);
assert_eq!(Err(CommandError::InvalidSlot), pws.erase_slot(SLOT_COUNT));
- assert!(pws.write_slot(0, "name", "login", "password").is_ok());
- assert!(pws.erase_slot(0).is_ok());
- assert!(pws.erase_slot(0).is_ok());
+ assert_eq!(Ok(()), pws.write_slot(0, "name", "login", "password"));
+ assert_eq!(Ok(()), pws.erase_slot(0));
+ assert_eq!(Ok(()), pws.erase_slot(0));
assert_eq!(Err(CommandError::Undefined), pws.get_slot_name(0));
}