]> git.lizzy.rs Git - rust.git/commitdiff
test: add remove() test cases for BTreeSet
authorKeita Nonaka <iKonnyaku40@gmail.com>
Thu, 14 Apr 2022 05:19:08 +0000 (22:19 -0700)
committerKeita Nonaka <iKonnyaku40@gmail.com>
Thu, 14 Apr 2022 05:19:08 +0000 (22:19 -0700)
library/alloc/src/collections/btree/set/tests.rs

index a56916081b748014c4fdd5e24814c212b82cd688..429b1644976c71586589f49ed806ceb8cccb59a5 100644 (file)
@@ -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() {