Fix compilation and tests.

This commit is contained in:
Oleksandr Kozachuk
2023-01-06 15:08:52 +01:00
parent 6f78130fab
commit 127f386e35
2 changed files with 6 additions and 5 deletions
+5 -4
View File
@@ -162,6 +162,7 @@ impl PartialEq for LKPrint {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::collections::HashSet;
use crate::lk::LK; use crate::lk::LK;
use crate::password::Password; use crate::password::Password;
use crate::structs::Mode; use crate::structs::Mode;
@@ -209,13 +210,13 @@ mod tests {
.db .db
.iter() .iter()
.map(|x| (x.0.to_string(), x.1.lock().borrow().to_string())) .map(|x| (x.0.to_string(), x.1.lock().borrow().to_string()))
.collect::<Vec<(String, String)>>(), .collect::<HashSet<(String, String)>>(),
{ {
let mut db = HashMap::new(); let mut db = HashMap::new();
db.insert(pwd1.lock().borrow().name.to_string(), pwd1.clone()); db.insert(pwd1.lock().borrow().name.to_string(), pwd1.clone());
db.into_iter() db.into_iter()
.map(|x| (x.0.to_string(), x.1.lock().borrow().to_string())) .map(|x| (x.0.to_string(), x.1.lock().borrow().to_string()))
.collect::<Vec<(String, String)>>() .collect::<HashSet<(String, String)>>()
} }
); );
assert_eq!( assert_eq!(
@@ -249,12 +250,12 @@ mod tests {
.db .db
.iter() .iter()
.map(|x| (x.0.to_string(), x.1.lock().borrow().to_string())) .map(|x| (x.0.to_string(), x.1.lock().borrow().to_string()))
.collect::<Vec<(String, String)>>(), .collect::<HashSet<(String, String)>>(),
{ {
let mut db = HashMap::new(); let mut db = HashMap::new();
db.insert(pwd1.lock().borrow().name.to_string(), pwd1.clone()); db.insert(pwd1.lock().borrow().name.to_string(), pwd1.clone());
db.insert(pwd2.lock().borrow().name.to_string(), pwd2.clone()); db.insert(pwd2.lock().borrow().name.to_string(), pwd2.clone());
db.into_iter().map(|x| (x.0, x.1.lock().borrow().to_string())).collect::<Vec<(String, String)>>() db.into_iter().map(|x| (x.0, x.1.lock().borrow().to_string())).collect::<HashSet<(String, String)>>()
} }
); );
assert_eq!( assert_eq!(
+1 -1
View File
@@ -85,7 +85,7 @@ impl<'a> PartialEq for Command<'a> {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
match (self, other) { match (self, other) {
(Command::Add(s), Command::Add(o)) => *s.lock() == *o.lock(), (Command::Add(s), Command::Add(o)) => *s.lock() == *o.lock(),
(Command::Leave(s), Command::Leave(o)) => s == o, (Command::Keep(s), Command::Keep(o)) => s == o,
(Command::Ls(s), Command::Ls(o)) => s == o, (Command::Ls(s), Command::Ls(o)) => s == o,
(Command::Ld(s), Command::Ld(o)) => s == o, (Command::Ld(s), Command::Ld(o)) => s == o,
(Command::Mv(a, b), Command::Mv(x, y)) => a == x && b == y, (Command::Mv(a, b), Command::Mv(x, y)) => a == x && b == y,