Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajjon committed Dec 15, 2023
1 parent 88744c3 commit 71f1659
Showing 1 changed file with 31 additions and 46 deletions.
77 changes: 31 additions & 46 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,52 +111,37 @@ fn get() {
assert_eq!(identified_vec.get(&3), Some(&User::blob_sr()));

// 1
let id: &u16 = &1;
// identified_vec
// .get_mut(id)
// .unwrap()
// .name
// .borrow_mut()
// .push_str(", Esq.");
// assert_eq!(
// identified_vec.get(id),
// Some(&User::new(id.clone(), "Blob, Esq."))
// );
// identified_vec.upd

// // 2
// id = &2;
// identified_vec
// .get_mut(id)
// .unwrap()
// .name
// .borrow_mut()
// .drain(4..9);
// assert_eq!(identified_vec.get(id), Some(&User::new(id.clone(), "Blob")));

// // 3
// id = &3;
// identified_vec
// .get_mut(id)
// .unwrap()
// .name
// .borrow_mut()
// .drain(4..9);
// assert_eq!(identified_vec.get(id), Some(&User::new(id.clone(), "Blob")));

// identified_vec.remove_by_id(id);
// assert_eq!(identified_vec.get(id), None);
// identified_vec.append(User::new(4, "Blob, Sr."));
// assert_eq!(
// identified_vec.elements(),
// [
// User::new(1, "Blob, Esq."),
// User::new(2, "Blob"),
// User::new(4, "Blob, Sr."),
// ]
// .iter()
// .collect::<Vec<&User>>()
// );
let mut id: &u16 = &1;
identified_vec.update_with(id, |u| u.name.borrow_mut().push_str(", Esq."));

assert_eq!(
identified_vec.get(id),
Some(&User::new(id.clone(), "Blob, Esq."))
);

// 2
id = &2;
identified_vec.update_with(id, |u| _ = u.name.borrow_mut().drain(4..9));
assert_eq!(identified_vec.get(id), Some(&User::new(id.clone(), "Blob")));

// 3
id = &3;
identified_vec.update_with(id, |u| _ = u.name.borrow_mut().drain(4..9));
assert_eq!(identified_vec.get(id), Some(&User::new(id.clone(), "Blob")));

identified_vec.remove_by_id(id);
assert_eq!(identified_vec.get(id), None);
identified_vec.append(User::new(4, "Blob, Sr."));
assert_eq!(
identified_vec.elements(),
[
User::new(1, "Blob, Esq."),
User::new(2, "Blob"),
User::new(4, "Blob, Sr."),
]
.iter()
.collect::<Vec<&User>>()
);
}

#[test]
Expand Down

0 comments on commit 71f1659

Please sign in to comment.