From 50c339e8f5e5516c9ba4938979e787c0a0a8e081 Mon Sep 17 00:00:00 2001 From: Keita Nonaka Date: Wed, 13 Apr 2022 22:19:08 -0700 Subject: [PATCH] test: add remove() test cases for BTreeSet --- .../alloc/src/collections/btree/set/tests.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/library/alloc/src/collections/btree/set/tests.rs b/library/alloc/src/collections/btree/set/tests.rs index a56916081b748..429b1644976c7 100644 --- a/library/alloc/src/collections/btree/set/tests.rs +++ b/library/alloc/src/collections/btree/set/tests.rs @@ -427,6 +427,26 @@ fn test_clear() { x.clear(); assert!(x.is_empty()); } +#[test] +fn test_remove() { + let mut x = BTreeSet::new(); + assert!(x.is_empty()); + + x.insert(1); + x.insert(2); + x.insert(3); + x.insert(4); + + assert_eq!(x.remove(&2), true); + assert_eq!(x.remove(&0), false); + assert_eq!(x.remove(&5), false); + assert_eq!(x.remove(&1), true); + assert_eq!(x.remove(&2), false); + assert_eq!(x.remove(&3), true); + assert_eq!(x.remove(&4), true); + assert_eq!(x.remove(&4), false); + assert!(x.is_empty()); +} #[test] fn test_zip() {