]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: common/test_weighted_priority_queue Add Some More Corner Cases
authorRobert LeBlanc <robert.leblanc@endurance.com>
Thu, 3 Mar 2016 00:34:32 +0000 (00:34 +0000)
committerRobert LeBlanc <robert.leblanc@endurance.com>
Thu, 3 Mar 2016 00:36:18 +0000 (00:36 +0000)
Signed-off-by: Robert LeBlanc <robert.leblanc@endurance.com>
src/test/common/test_weighted_priority_queue.cc

index d3ebc4199cfb382c2b6f88f45eb3b5e9ecf4396e..f94af71e97edd85b19d07e2723ce5a6790efb6d7 100644 (file)
@@ -206,6 +206,18 @@ struct Greater {
   }
 };
 
+TEST_F(WeightedPriorityQueueTest, wpq_test_remove_by_filter_null) {
+  WQ wq(0, 0);
+  LQ strictq, normq;
+  unsigned num_items = 100;
+  fill_queue(wq, strictq, normq, num_items);
+  // Pick a value that we didn't enqueue
+  const Greater<Item> pred(std::make_tuple(0, 0, 1 << 17));
+  Removed wq_removed;
+  wq.remove_by_filter(pred, &wq_removed);
+  EXPECT_EQ(0u, wq_removed.size());
+}
+
 TEST_F(WeightedPriorityQueueTest, wpq_test_remove_by_filter) {
   WQ wq(0, 0);
   LQ strictq, normq;
@@ -255,6 +267,17 @@ TEST_F(WeightedPriorityQueueTest, wpq_test_remove_by_filter) {
   }
 }
 
+TEST_F(WeightedPriorityQueueTest, wpq_test_remove_by_class_null) {
+  WQ wq(0, 0);
+  LQ strictq, normq;
+  unsigned num_items = 10;
+  fill_queue(wq, strictq, normq, num_items);
+  Removed wq_removed;
+  // Pick a klass that was not enqueued
+  wq.remove_by_class(klasses + 1, &wq_removed);
+  EXPECT_EQ(0u, wq_removed.size());
+}
+
 TEST_F(WeightedPriorityQueueTest, wpq_test_remove_by_class) {
   WQ wq(0, 0);
   LQ strictq, normq;