memgraph/tests/unit/skiplist_suffix.cpp
Matej Ferencevic 75950664a7 Separate distributed from single node storage
Summary:
This diff splits single node and distributed storage from each other.
Currently all of the storage code is copied into two directories (one single
node, one distributed).  The logic used in the storage implementation isn't
touched, it will be refactored in following diffs.

To clean the working directory after this diff you should execute:
```
rm database/state_delta.capnp
rm database/state_delta.hpp
rm storage/concurrent_id_mapper_rpc_messages.capnp
rm storage/concurrent_id_mapper_rpc_messages.hpp
```

Reviewers: teon.banek, buda, msantl

Reviewed By: teon.banek, msantl

Subscribers: teon.banek, pullbot

Differential Revision: https://phabricator.memgraph.io/D1625
2018-10-05 09:19:33 +02:00

43 lines
1.1 KiB
C++

#include <algorithm>
#include <iterator>
#include <vector>
#include <gtest/gtest.h>
#include "data_structures/concurrent/skiplist.hpp"
#include "storage/common/index.hpp"
template <class TIterable>
int Count(TIterable &collection) {
int ret = 0;
for (__attribute__((unused)) auto it : collection) ret += 1;
return ret;
}
TEST(SkipListSuffix, EmptyRange) {
SkipList<int> V;
auto access = V.access();
auto r1 = database::index::SkipListSuffix<typename SkipList<int>::Iterator,
int, SkipList<int>>(
access.begin(), std::move(access));
EXPECT_EQ(Count(r1), 0);
}
TEST(SkipListSuffix, NonEmptyRange) {
SkipList<int> V;
auto access = V.access();
access.insert(1);
access.insert(5);
access.insert(3);
auto r1 = database::index::SkipListSuffix<typename SkipList<int>::Iterator,
int, SkipList<int>>(
access.begin(), std::move(access));
EXPECT_EQ(Count(r1), 3);
auto iter = r1.begin();
EXPECT_EQ(*iter, 1);
++iter;
EXPECT_EQ(*iter, 3);
++iter;
EXPECT_EQ(*iter, 5);
}