Commit 95ea6fd9 authored by Alexander Baumstark's avatar Alexander Baumstark

Add woPSkiplistTest

parent e9857d5b
Pipeline #408 failed with stages
in 45 seconds
......@@ -26,3 +26,5 @@ do_test(DataNodeTest ptable)
do_test(PTableInfoTest ptable)
do_test(PTupleTest ptable)
do_test(PTableTest ptable)
# woPSkiplist
do_test(woPSkiplist)
#include "catch.hpp"
#include "config.h"
#define UNIT_TESTS 1
#include "woPSkiplist.hpp"
using pmem::obj::delete_persistent_atomic;
using pmem::obj::pool;
TEST_CASE("Insert and lookup key") {
using woPSkip = woPSkiplist<int, int, 8, 8>;
struct root {
pptr<woPSkip> skiplist;
};
pool<root> pop;
const std::string path = dbis::gPmemPath + "woPSkiplistTest";
//std::remove(path.c_str());
if (access(path.c_str(), F_OK) != 0)
pop = pool<root>::create(path, "woPSkiplist", ((size_t)(1024 * 1024 * 16)));
else
pop = pool<root>::open(path, "woPSkiplist");
auto q = pop.root();
auto &rootRef = *q;
const auto alloc_class = pop.ctl_set<struct pobj_alloc_class_desc>("heap.alloc_class.128.desc",
PBPTreeType4::AllocClass);
if(!rootRef.skiplist)
transaction::run(pop, [&] {rootRef.skiplist = make_persistent<woPSkip>(alloc_class); });
SECTION("Inserting keys") {
auto &sl = *rootRef.skiplist;
for(int i=0; i<10; ++i) {
sl.insert(i, i*i);
}
REQUIRE(sl.search(5) != nullptr);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment