2015-04-27 23:09:29 +02:00
|
|
|
#include "QueueMapTest.h"
|
|
|
|
|
2015-07-21 18:19:34 +02:00
|
|
|
QueueMapTest::QueueMapTest(): _map(cpputils::make_unique_ref<blockstore::caching::QueueMap<MinimalKeyType, MinimalValueType>>()) {
|
2015-04-27 23:09:29 +02:00
|
|
|
MinimalKeyType::instances = 0;
|
|
|
|
MinimalValueType::instances = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
QueueMapTest::~QueueMapTest() {
|
2015-07-21 18:19:34 +02:00
|
|
|
cpputils::destruct(std::move(_map));
|
2015-04-27 23:09:29 +02:00
|
|
|
EXPECT_EQ(0, MinimalKeyType::instances);
|
|
|
|
EXPECT_EQ(0, MinimalValueType::instances);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QueueMapTest::push(int key, int value) {
|
|
|
|
_map->push(MinimalKeyType::create(key), MinimalValueType::create(value));
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::optional<int> QueueMapTest::pop() {
|
|
|
|
auto elem = _map->pop();
|
|
|
|
if (!elem) {
|
|
|
|
return boost::none;
|
|
|
|
}
|
|
|
|
return elem.value().value();
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::optional<int> QueueMapTest::pop(int key) {
|
|
|
|
auto elem = _map->pop(MinimalKeyType::create(key));
|
|
|
|
if (!elem) {
|
|
|
|
return boost::none;
|
|
|
|
}
|
|
|
|
return elem.value().value();
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::optional<int> QueueMapTest::peek() {
|
|
|
|
auto elem = _map->peek();
|
|
|
|
if (!elem) {
|
|
|
|
return boost::none;
|
|
|
|
}
|
|
|
|
return elem.value().value();
|
|
|
|
}
|
|
|
|
|
|
|
|
int QueueMapTest::size() {
|
|
|
|
return _map->size();
|
|
|
|
}
|