From e13a4b104bb328d4ac7bafbf744feeaa410b36cd Mon Sep 17 00:00:00 2001 From: Robert LeBlanc Date: Thu, 3 Mar 2016 00:34:32 +0000 Subject: [PATCH] test: common/test_weighted_priority_queue Add Some More Corner Cases Signed-off-by: Robert LeBlanc --- .../common/test_weighted_priority_queue.cc | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/test/common/test_weighted_priority_queue.cc b/src/test/common/test_weighted_priority_queue.cc index d3ebc4199cfb3..f94af71e97edd 100644 --- a/src/test/common/test_weighted_priority_queue.cc +++ b/src/test/common/test_weighted_priority_queue.cc @@ -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 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; -- 2.39.5