2a59ed8906
Importes now use logger. Refactored order of constrution of objects in Db. Moved index creation/removing from Db to Indexes. Completed Garbage class. Cleaner now calls garbage.clean() for databases. Renamed List to ConcurrentList which better names it.
76 lines
1.3 KiB
C++
76 lines
1.3 KiB
C++
#define CATCH_CONFIG_MAIN
|
|
#include "catch.hpp"
|
|
|
|
#include "data_structures/concurrent/concurrent_list.hpp"
|
|
|
|
TEST_CASE("Conncurent List insert")
|
|
{
|
|
ConcurrentList<int> list;
|
|
auto it = list.begin();
|
|
it.push(32);
|
|
it.reset();
|
|
REQUIRE(*it == 32);
|
|
}
|
|
|
|
TEST_CASE("Conncurent List iterate")
|
|
{
|
|
ConcurrentList<int> list;
|
|
auto it = list.begin();
|
|
it.push(32);
|
|
it.push(7);
|
|
it.push(9);
|
|
it.push(0);
|
|
it.reset();
|
|
|
|
REQUIRE(*it == 0);
|
|
it++;
|
|
REQUIRE(*it == 9);
|
|
it++;
|
|
REQUIRE(*it == 7);
|
|
it++;
|
|
REQUIRE(*it == 32);
|
|
it++;
|
|
REQUIRE(it == list.end());
|
|
}
|
|
|
|
TEST_CASE("Conncurent List head remove")
|
|
{
|
|
ConcurrentList<int> list;
|
|
auto it = list.begin();
|
|
it.push(32);
|
|
it.reset();
|
|
|
|
REQUIRE(it.remove());
|
|
REQUIRE(it.is_removed());
|
|
REQUIRE(!it.remove());
|
|
|
|
it.reset();
|
|
REQUIRE(it == list.end());
|
|
}
|
|
|
|
TEST_CASE("Conncurent List remove")
|
|
{
|
|
ConcurrentList<int> list;
|
|
auto it = list.begin();
|
|
it.push(32);
|
|
it.push(7);
|
|
it.push(9);
|
|
it.push(0);
|
|
it.reset();
|
|
|
|
it++;
|
|
it++;
|
|
REQUIRE(it.remove());
|
|
REQUIRE(it.is_removed());
|
|
REQUIRE(!it.remove());
|
|
|
|
it.reset();
|
|
REQUIRE(*it == 0);
|
|
it++;
|
|
REQUIRE(*it == 9);
|
|
it++;
|
|
REQUIRE(*it == 32);
|
|
it++;
|
|
REQUIRE(it == list.end());
|
|
}
|