e2f3aba332
Summary: http://rpg.ifi.uzh.ch/docs/glog.html Second phase before tests complete. Delete logging test. Finish relase loging. Reviewers: mislav.bradac, teon.banek, buda Reviewed By: teon.banek Subscribers: buda, pullbot Differential Revision: https://phabricator.memgraph.io/D500
54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
#include <iostream>
|
|
|
|
#include <glog/logging.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "data_structures/concurrent/concurrent_set.hpp"
|
|
#include "utils/assert.hpp"
|
|
|
|
void print_skiplist(const ConcurrentSet<int>::Accessor &skiplist) {
|
|
DLOG(INFO) << "Skiplist set now has:";
|
|
for (auto &item : skiplist) DLOG(INFO) << item;
|
|
}
|
|
|
|
TEST(ConcurrentSet, Mix) {
|
|
ConcurrentSet<int> set;
|
|
|
|
auto accessor = set.access();
|
|
|
|
permanent_assert(accessor.insert(1).second == true,
|
|
"added non-existing 1? (true)");
|
|
|
|
permanent_assert(accessor.insert(1).second == false,
|
|
"added already existing 1? (false)");
|
|
|
|
permanent_assert(accessor.insert(2).second == true,
|
|
"added non-existing 2? (true)");
|
|
|
|
permanent_assert(accessor.find(3) == accessor.end(),
|
|
"item 3 doesn't exist? (true)");
|
|
|
|
permanent_assert(accessor.contains(3) == false, "item 3 exists? (false)");
|
|
|
|
permanent_assert(accessor.find(2) != accessor.end(), "item 2 exists? (true)");
|
|
|
|
permanent_assert(*accessor.find(2) == 2, "find item 2");
|
|
|
|
permanent_assert(accessor.remove(1) == true, "removed existing 1? (true)");
|
|
|
|
permanent_assert(accessor.remove(3) == false,
|
|
"try to remove non existing element");
|
|
|
|
permanent_assert(accessor.insert(1).second == true, "add 1 again");
|
|
|
|
permanent_assert(accessor.insert(4).second == true, "add 4");
|
|
|
|
print_skiplist(accessor);
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
google::InitGoogleLogging(argv[0]);
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
return RUN_ALL_TESTS();
|
|
}
|