Remove dependency on GTest for UnitTests
All checks were successful
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 2s
Run UnitTests / build-and-run-unittests (push) Successful in 35s

This commit is contained in:
Stephen Seo 2024-07-15 13:12:24 +09:00
parent 33855ff2d7
commit 6778f570d9
7 changed files with 530 additions and 337 deletions

View file

@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Install dependencies - name: Install dependencies
run: sudo /usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get install libgtest-dev cmake run: sudo /usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get install cmake
- name: Get sources - name: Get sources
run: git clone --depth=1 --no-single-branch https://github.com/Stephen-Seo/EntityComponentMetaSystem.git ECMS && cd ECMS && git checkout $GITHUB_REF_NAME run: git clone --depth=1 --no-single-branch https://github.com/Stephen-Seo/EntityComponentMetaSystem.git ECMS && cd ECMS && git checkout $GITHUB_REF_NAME
- name: Build UnitTests - name: Build UnitTests

View file

@ -47,8 +47,6 @@ endif()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/EC DESTINATION include) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/EC DESTINATION include)
find_package(GTest)
if(GTEST_FOUND)
set(UnitTests_SOURCES set(UnitTests_SOURCES
test/MetaTest.cpp test/MetaTest.cpp
test/ECTest.cpp test/ECTest.cpp
@ -57,13 +55,11 @@ if(GTEST_FOUND)
) )
add_executable(UnitTests ${UnitTests_SOURCES}) add_executable(UnitTests ${UnitTests_SOURCES})
target_link_libraries(UnitTests EntityComponentSystem ${GTEST_LIBRARIES}) target_link_libraries(UnitTests EntityComponentSystem)
target_include_directories(UnitTests PUBLIC ${GTEST_INCLUDE_DIR})
target_compile_features(UnitTests PUBLIC cxx_std_14) target_compile_features(UnitTests PUBLIC cxx_std_14)
enable_testing() enable_testing()
add_test(NAME UnitTests COMMAND UnitTests) add_test(NAME UnitTests COMMAND UnitTests)
endif()
add_executable(WillFailCompile ${WillFailCompile_SOURCES}) add_executable(WillFailCompile ${WillFailCompile_SOURCES})
set_target_properties(WillFailCompile PROPERTIES set_target_properties(WillFailCompile PROPERTIES

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,44 @@
#include "test_helpers.h"
#include <gtest/gtest.h> int checks_checked = 0;
int checks_passed = 0;
int main(int argc, char** argv) int main() {
{ TEST_EC_Bitset();
::testing::InitGoogleTest(&argc, argv); TEST_EC_Manager();
return RUN_ALL_TESTS(); TEST_EC_MoveComponentWithUniquePtr();
TEST_EC_DeletedEntities();
TEST_EC_FunctionStorage();
TEST_EC_DeletedEntityID();
TEST_EC_MultiThreaded();
TEST_EC_ForMatchingSignatures();
TEST_EC_forMatchingPtrs();
TEST_EC_context();
TEST_EC_FunctionStorageOrder();
TEST_EC_forMatchingSimple();
TEST_EC_forMatchingIterableFn();
TEST_EC_MultiThreadedForMatching();
TEST_EC_ManagerWithLowThreadCount();
TEST_EC_ManagerDeferredDeletions();
TEST_EC_NestedThreadPoolTasks();
TEST_Meta_Contains();
TEST_Meta_ContainsAll();
TEST_Meta_IndexOf();
TEST_Meta_Bitset();
TEST_Meta_Combine();
TEST_Meta_Morph();
TEST_Meta_TypeListGet();
TEST_Meta_ForEach();
TEST_Meta_Matching();
TEST_ECThreadPool_OneThread();
TEST_ECThreadPool_Simple();
TEST_ECThreadPool_QueryCount();
TEST_ECThreadPool_easyStartAndWait();
std::cout << "checks_checked: " << checks_checked << '\n'
<< "checks_passed: " << checks_passed << std::endl;
return checks_checked == checks_passed ? 0 : 1;
} }

View file

@ -1,5 +1,4 @@
#include "test_helpers.h"
#include <gtest/gtest.h>
#include <tuple> #include <tuple>
#include <EC/Meta/Meta.hpp> #include <EC/Meta/Meta.hpp>
@ -28,179 +27,179 @@ struct Storage
using type = std::tuple<std::vector<STypes>... >; using type = std::tuple<std::vector<STypes>... >;
}; };
TEST(Meta, Contains) void TEST_Meta_Contains()
{ {
int size = ListComponentsAll::size; int size = ListComponentsAll::size;
EXPECT_EQ(size, 4); CHECK_EQ(size, 4);
bool result = EC::Meta::Contains<C0, ListComponentsAll>::value; bool result = EC::Meta::Contains<C0, ListComponentsAll>::value;
EXPECT_TRUE(result); CHECK_TRUE(result);
result = EC::Meta::Contains<C1, ListComponentsAll>::value; result = EC::Meta::Contains<C1, ListComponentsAll>::value;
EXPECT_TRUE(result); CHECK_TRUE(result);
result = EC::Meta::Contains<C2, ListComponentsAll>::value; result = EC::Meta::Contains<C2, ListComponentsAll>::value;
EXPECT_TRUE(result); CHECK_TRUE(result);
result = EC::Meta::Contains<C3, ListComponentsAll>::value; result = EC::Meta::Contains<C3, ListComponentsAll>::value;
EXPECT_TRUE(result); CHECK_TRUE(result);
size = ListComponentsSome::size; size = ListComponentsSome::size;
EXPECT_EQ(size, 2); CHECK_EQ(size, 2);
result = EC::Meta::Contains<C0, ListComponentsSome>::value; result = EC::Meta::Contains<C0, ListComponentsSome>::value;
EXPECT_FALSE(result); CHECK_FALSE(result);
result = EC::Meta::Contains<C1, ListComponentsSome>::value; result = EC::Meta::Contains<C1, ListComponentsSome>::value;
EXPECT_TRUE(result); CHECK_TRUE(result);
result = EC::Meta::Contains<C2, ListComponentsSome>::value; result = EC::Meta::Contains<C2, ListComponentsSome>::value;
EXPECT_FALSE(result); CHECK_FALSE(result);
result = EC::Meta::Contains<C3, ListComponentsSome>::value; result = EC::Meta::Contains<C3, ListComponentsSome>::value;
EXPECT_TRUE(result); CHECK_TRUE(result);
} }
TEST(Meta, ContainsAll) void TEST_Meta_ContainsAll()
{ {
bool contains = EC::Meta::ContainsAll<ListComponentsSome, ListComponentsAll>::value; bool contains = EC::Meta::ContainsAll<ListComponentsSome, ListComponentsAll>::value;
EXPECT_TRUE(contains); CHECK_TRUE(contains);
contains = EC::Meta::ContainsAll<ListComponentsAll, ListComponentsSome>::value; contains = EC::Meta::ContainsAll<ListComponentsAll, ListComponentsSome>::value;
EXPECT_FALSE(contains); CHECK_FALSE(contains);
contains = EC::Meta::ContainsAll<ListComponentsAll, ListComponentsAll>::value; contains = EC::Meta::ContainsAll<ListComponentsAll, ListComponentsAll>::value;
EXPECT_TRUE(contains); CHECK_TRUE(contains);
} }
TEST(Meta, IndexOf) void TEST_Meta_IndexOf()
{ {
int index = EC::Meta::IndexOf<C0, ListComponentsAll>::value; int index = EC::Meta::IndexOf<C0, ListComponentsAll>::value;
EXPECT_EQ(index, 0); CHECK_EQ(index, 0);
index = EC::Meta::IndexOf<C1, ListComponentsAll>::value; index = EC::Meta::IndexOf<C1, ListComponentsAll>::value;
EXPECT_EQ(index, 1); CHECK_EQ(index, 1);
index = EC::Meta::IndexOf<C2, ListComponentsAll>::value; index = EC::Meta::IndexOf<C2, ListComponentsAll>::value;
EXPECT_EQ(index, 2); CHECK_EQ(index, 2);
index = EC::Meta::IndexOf<C3, ListComponentsAll>::value; index = EC::Meta::IndexOf<C3, ListComponentsAll>::value;
EXPECT_EQ(index, 3); CHECK_EQ(index, 3);
index = EC::Meta::IndexOf<T0, ListComponentsAll>::value; index = EC::Meta::IndexOf<T0, ListComponentsAll>::value;
EXPECT_EQ(index, 4); CHECK_EQ(index, 4);
index = EC::Meta::IndexOf<C1, ListComponentsSome>::value; index = EC::Meta::IndexOf<C1, ListComponentsSome>::value;
EXPECT_EQ(index, 0); CHECK_EQ(index, 0);
index = EC::Meta::IndexOf<C3, ListComponentsSome>::value; index = EC::Meta::IndexOf<C3, ListComponentsSome>::value;
EXPECT_EQ(index, 1); CHECK_EQ(index, 1);
index = EC::Meta::IndexOf<C2, ListComponentsSome>::value; index = EC::Meta::IndexOf<C2, ListComponentsSome>::value;
EXPECT_EQ(index, 2); CHECK_EQ(index, 2);
} }
TEST(Meta, Bitset) void TEST_Meta_Bitset()
{ {
EC::Bitset<ListComponentsAll, ListTagsAll> bitset; EC::Bitset<ListComponentsAll, ListTagsAll> bitset;
EXPECT_EQ(bitset.size(), ListComponentsAll::size + ListTagsAll::size + 1); CHECK_EQ(bitset.size(), ListComponentsAll::size + ListTagsAll::size + 1);
bitset[EC::Meta::IndexOf<C1, ListComponentsAll>::value] = true; bitset[EC::Meta::IndexOf<C1, ListComponentsAll>::value] = true;
EXPECT_TRUE(bitset.getComponentBit<C1>()); CHECK_TRUE(bitset.getComponentBit<C1>());
bitset.flip(); bitset.flip();
EXPECT_FALSE(bitset.getComponentBit<C1>()); CHECK_FALSE(bitset.getComponentBit<C1>());
bitset.reset(); bitset.reset();
bitset[ListComponentsAll::size + EC::Meta::IndexOf<T0, ListTagsAll>::value] = true; bitset[ListComponentsAll::size + EC::Meta::IndexOf<T0, ListTagsAll>::value] = true;
EXPECT_TRUE(bitset.getTagBit<T0>()); CHECK_TRUE(bitset.getTagBit<T0>());
bitset.flip(); bitset.flip();
EXPECT_FALSE(bitset.getTagBit<T0>()); CHECK_FALSE(bitset.getTagBit<T0>());
} }
TEST(Meta, Combine) void TEST_Meta_Combine()
{ {
using CombinedAll = EC::Meta::Combine<ListComponentsAll, ListTagsAll>; using CombinedAll = EC::Meta::Combine<ListComponentsAll, ListTagsAll>;
int listAllTemp = ListAll::size; int listAllTemp = ListAll::size;
int combinedAllTemp = CombinedAll::size; int combinedAllTemp = CombinedAll::size;
EXPECT_EQ(combinedAllTemp, listAllTemp); CHECK_EQ(combinedAllTemp, listAllTemp);
listAllTemp = EC::Meta::IndexOf<C0, ListAll>::value; listAllTemp = EC::Meta::IndexOf<C0, ListAll>::value;
combinedAllTemp = EC::Meta::IndexOf<C0, CombinedAll>::value; combinedAllTemp = EC::Meta::IndexOf<C0, CombinedAll>::value;
EXPECT_EQ(combinedAllTemp, listAllTemp); CHECK_EQ(combinedAllTemp, listAllTemp);
listAllTemp = EC::Meta::IndexOf<C1, ListAll>::value; listAllTemp = EC::Meta::IndexOf<C1, ListAll>::value;
combinedAllTemp = EC::Meta::IndexOf<C1, CombinedAll>::value; combinedAllTemp = EC::Meta::IndexOf<C1, CombinedAll>::value;
EXPECT_EQ(combinedAllTemp, listAllTemp); CHECK_EQ(combinedAllTemp, listAllTemp);
listAllTemp = EC::Meta::IndexOf<C2, ListAll>::value; listAllTemp = EC::Meta::IndexOf<C2, ListAll>::value;
combinedAllTemp = EC::Meta::IndexOf<C2, CombinedAll>::value; combinedAllTemp = EC::Meta::IndexOf<C2, CombinedAll>::value;
EXPECT_EQ(combinedAllTemp, listAllTemp); CHECK_EQ(combinedAllTemp, listAllTemp);
listAllTemp = EC::Meta::IndexOf<C3, ListAll>::value; listAllTemp = EC::Meta::IndexOf<C3, ListAll>::value;
combinedAllTemp = EC::Meta::IndexOf<C3, CombinedAll>::value; combinedAllTemp = EC::Meta::IndexOf<C3, CombinedAll>::value;
EXPECT_EQ(combinedAllTemp, listAllTemp); CHECK_EQ(combinedAllTemp, listAllTemp);
listAllTemp = EC::Meta::IndexOf<T0, ListAll>::value; listAllTemp = EC::Meta::IndexOf<T0, ListAll>::value;
combinedAllTemp = EC::Meta::IndexOf<T0, CombinedAll>::value; combinedAllTemp = EC::Meta::IndexOf<T0, CombinedAll>::value;
EXPECT_EQ(combinedAllTemp, listAllTemp); CHECK_EQ(combinedAllTemp, listAllTemp);
listAllTemp = EC::Meta::IndexOf<T1, ListAll>::value; listAllTemp = EC::Meta::IndexOf<T1, ListAll>::value;
combinedAllTemp = EC::Meta::IndexOf<T1, CombinedAll>::value; combinedAllTemp = EC::Meta::IndexOf<T1, CombinedAll>::value;
EXPECT_EQ(combinedAllTemp, listAllTemp); CHECK_EQ(combinedAllTemp, listAllTemp);
bool same = std::is_same<CombinedAll, ListAll>::value; bool same = std::is_same<CombinedAll, ListAll>::value;
EXPECT_TRUE(same); CHECK_TRUE(same);
} }
TEST(Meta, Morph) void TEST_Meta_Morph()
{ {
using TupleAll = std::tuple<C0, C1, C2, C3>; using TupleAll = std::tuple<C0, C1, C2, C3>;
using MorphedTuple = EC::Meta::Morph<TupleAll, EC::Meta::TypeList<> >; using MorphedTuple = EC::Meta::Morph<TupleAll, EC::Meta::TypeList<> >;
int morphedTupleTemp = MorphedTuple::size; int morphedTupleTemp = MorphedTuple::size;
int componentsTemp = ListComponentsAll::size; int componentsTemp = ListComponentsAll::size;
EXPECT_EQ(morphedTupleTemp, componentsTemp); CHECK_EQ(morphedTupleTemp, componentsTemp);
morphedTupleTemp = EC::Meta::IndexOf<C0, MorphedTuple>::value; morphedTupleTemp = EC::Meta::IndexOf<C0, MorphedTuple>::value;
componentsTemp = EC::Meta::IndexOf<C0, ListComponentsAll>::value; componentsTemp = EC::Meta::IndexOf<C0, ListComponentsAll>::value;
EXPECT_EQ(morphedTupleTemp, componentsTemp); CHECK_EQ(morphedTupleTemp, componentsTemp);
morphedTupleTemp = EC::Meta::IndexOf<C1, MorphedTuple>::value; morphedTupleTemp = EC::Meta::IndexOf<C1, MorphedTuple>::value;
componentsTemp = EC::Meta::IndexOf<C1, ListComponentsAll>::value; componentsTemp = EC::Meta::IndexOf<C1, ListComponentsAll>::value;
EXPECT_EQ(morphedTupleTemp, componentsTemp); CHECK_EQ(morphedTupleTemp, componentsTemp);
morphedTupleTemp = EC::Meta::IndexOf<C2, MorphedTuple>::value; morphedTupleTemp = EC::Meta::IndexOf<C2, MorphedTuple>::value;
componentsTemp = EC::Meta::IndexOf<C2, ListComponentsAll>::value; componentsTemp = EC::Meta::IndexOf<C2, ListComponentsAll>::value;
EXPECT_EQ(morphedTupleTemp, componentsTemp); CHECK_EQ(morphedTupleTemp, componentsTemp);
morphedTupleTemp = EC::Meta::IndexOf<C3, MorphedTuple>::value; morphedTupleTemp = EC::Meta::IndexOf<C3, MorphedTuple>::value;
componentsTemp = EC::Meta::IndexOf<C3, ListComponentsAll>::value; componentsTemp = EC::Meta::IndexOf<C3, ListComponentsAll>::value;
EXPECT_EQ(morphedTupleTemp, componentsTemp); CHECK_EQ(morphedTupleTemp, componentsTemp);
using MorphedComponents = EC::Meta::Morph<ListComponentsAll, std::tuple<> >; using MorphedComponents = EC::Meta::Morph<ListComponentsAll, std::tuple<> >;
bool isSame = std::is_same<MorphedComponents, TupleAll>::value; bool isSame = std::is_same<MorphedComponents, TupleAll>::value;
EXPECT_TRUE(isSame); CHECK_TRUE(isSame);
using ComponentsStorage = EC::Meta::Morph<ListComponentsAll, Storage<> >; using ComponentsStorage = EC::Meta::Morph<ListComponentsAll, Storage<> >;
isSame = std::is_same<ComponentsStorage::type, isSame = std::is_same<ComponentsStorage::type,
std::tuple<std::vector<C0>, std::vector<C1>, std::vector<C2>, std::vector<C3> > >::value; std::tuple<std::vector<C0>, std::vector<C1>, std::vector<C2>, std::vector<C3> > >::value;
EXPECT_TRUE(isSame); CHECK_TRUE(isSame);
} }
TEST(Meta, TypeListGet) void TEST_Meta_TypeListGet()
{ {
bool isSame = std::is_same<C0, EC::Meta::TypeListGet<ListAll, 0> >::value; bool isSame = std::is_same<C0, EC::Meta::TypeListGet<ListAll, 0> >::value;
EXPECT_TRUE(isSame); CHECK_TRUE(isSame);
isSame = std::is_same<C1, EC::Meta::TypeListGet<ListAll, 1> >::value; isSame = std::is_same<C1, EC::Meta::TypeListGet<ListAll, 1> >::value;
EXPECT_TRUE(isSame); CHECK_TRUE(isSame);
isSame = std::is_same<C2, EC::Meta::TypeListGet<ListAll, 2> >::value; isSame = std::is_same<C2, EC::Meta::TypeListGet<ListAll, 2> >::value;
EXPECT_TRUE(isSame); CHECK_TRUE(isSame);
isSame = std::is_same<C3, EC::Meta::TypeListGet<ListAll, 3> >::value; isSame = std::is_same<C3, EC::Meta::TypeListGet<ListAll, 3> >::value;
EXPECT_TRUE(isSame); CHECK_TRUE(isSame);
const unsigned int temp = 4; const unsigned int temp = 4;
isSame = std::is_same<T0, EC::Meta::TypeListGet<ListAll, temp> >::value; isSame = std::is_same<T0, EC::Meta::TypeListGet<ListAll, temp> >::value;
EXPECT_TRUE(isSame); CHECK_TRUE(isSame);
isSame = std::is_same<T1, EC::Meta::TypeListGet<ListAll, 5> >::value; isSame = std::is_same<T1, EC::Meta::TypeListGet<ListAll, 5> >::value;
EXPECT_TRUE(isSame); CHECK_TRUE(isSame);
} }
TEST(Meta, ForEach) void TEST_Meta_ForEach()
{ {
EC::Bitset<ListComponentsAll, ListTagsAll> bitset; EC::Bitset<ListComponentsAll, ListTagsAll> bitset;
@ -210,32 +209,32 @@ TEST(Meta, ForEach)
EC::Meta::forEach<ListComponentsSome>(setBits); EC::Meta::forEach<ListComponentsSome>(setBits);
EXPECT_FALSE(bitset[0]); CHECK_FALSE(bitset[0]);
EXPECT_TRUE(bitset[1]); CHECK_TRUE(bitset[1]);
EXPECT_FALSE(bitset[2]); CHECK_FALSE(bitset[2]);
EXPECT_TRUE(bitset[3]); CHECK_TRUE(bitset[3]);
EXPECT_FALSE(bitset[4]); CHECK_FALSE(bitset[4]);
EXPECT_FALSE(bitset[5]); CHECK_FALSE(bitset[5]);
} }
TEST(Meta, Matching) void TEST_Meta_Matching()
{ {
{ {
using Matched = EC::Meta::Matching<ListComponentsSome, ListComponentsAll>::type; using Matched = EC::Meta::Matching<ListComponentsSome, ListComponentsAll>::type;
bool isSame = std::is_same<ListComponentsSome, Matched>::value; bool isSame = std::is_same<ListComponentsSome, Matched>::value;
EXPECT_TRUE(isSame); CHECK_TRUE(isSame);
} }
{ {
using Matched = EC::Meta::Matching<ListSome, ListAll>::type; using Matched = EC::Meta::Matching<ListSome, ListAll>::type;
bool isSame = std::is_same<ListSome, Matched>::value; bool isSame = std::is_same<ListSome, Matched>::value;
EXPECT_TRUE(isSame); CHECK_TRUE(isSame);
} }
{ {
using Matched = EC::Meta::Matching<ListTagsAll, ListComponentsAll>::type; using Matched = EC::Meta::Matching<ListTagsAll, ListComponentsAll>::type;
bool isSame = std::is_same<EC::Meta::TypeList<>, Matched>::value; bool isSame = std::is_same<EC::Meta::TypeList<>, Matched>::value;
EXPECT_TRUE(isSame); CHECK_TRUE(isSame);
} }
} }

View file

@ -1,11 +1,11 @@
#include <gtest/gtest.h> #include "test_helpers.h"
#include <EC/ThreadPool.hpp> #include <EC/ThreadPool.hpp>
using OneThreadPool = EC::ThreadPool<1>; using OneThreadPool = EC::ThreadPool<1>;
using ThreeThreadPool = EC::ThreadPool<3>; using ThreeThreadPool = EC::ThreadPool<3>;
TEST(ECThreadPool, OneThread) { void TEST_ECThreadPool_OneThread() {
OneThreadPool p; OneThreadPool p;
std::atomic_int data; std::atomic_int data;
data.store(0); data.store(0);
@ -36,7 +36,7 @@ TEST(ECThreadPool, OneThread) {
ASSERT_EQ(data.load(), 11); ASSERT_EQ(data.load(), 11);
} }
TEST(ECThreadPool, Simple) { void TEST_ECThreadPool_Simple() {
ThreeThreadPool p; ThreeThreadPool p;
std::atomic_int data; std::atomic_int data;
data.store(0); data.store(0);
@ -67,7 +67,7 @@ TEST(ECThreadPool, Simple) {
ASSERT_EQ(data.load(), 11); ASSERT_EQ(data.load(), 11);
} }
TEST(ECThreadPool, QueryCount) { void TEST_ECThreadPool_QueryCount() {
{ {
OneThreadPool oneP; OneThreadPool oneP;
ASSERT_EQ(1, oneP.getMaxThreadCount()); ASSERT_EQ(1, oneP.getMaxThreadCount());
@ -78,7 +78,7 @@ TEST(ECThreadPool, QueryCount) {
} }
} }
TEST(ECThreadPool, easyStartAndWait) { void TEST_ECThreadPool_easyStartAndWait() {
std::atomic_int data; std::atomic_int data;
data.store(0); data.store(0);
{ {
@ -90,7 +90,7 @@ TEST(ECThreadPool, easyStartAndWait) {
}, &data); }, &data);
} }
oneP.easyStartAndWait(); oneP.easyStartAndWait();
EXPECT_EQ(20, data.load()); CHECK_EQ(20, data.load());
} }
{ {
ThreeThreadPool threeP; ThreeThreadPool threeP;
@ -101,6 +101,6 @@ TEST(ECThreadPool, easyStartAndWait) {
}, &data); }, &data);
} }
threeP.easyStartAndWait(); threeP.easyStartAndWait();
EXPECT_EQ(40, data.load()); CHECK_EQ(40, data.load());
} }
} }

163
src/test/test_helpers.h Normal file
View file

@ -0,0 +1,163 @@
#ifndef SEODISPARATE_COM_ENTITY_COMPONENT_META_SYSTEM_TEST_HELPERS_H_
#define SEODISPARATE_COM_ENTITY_COMPONENT_META_SYSTEM_TEST_HELPERS_H_
#include <cstring>
#include <iostream>
extern int checks_checked;
extern int checks_passed;
// Macros for unit testing.
#define CHECK_TRUE(x) \
do { \
++checks_checked; \
if (!(x)) { \
std::cout << "CHECK_TRUE at line " << __LINE__ << " failed: " << #x \
<< '\n'; \
} else { \
++checks_passed; \
} \
} while (false);
#define ASSERT_TRUE(x) \
do { \
++checks_checked; \
if (!(x)) { \
std::cout << "CHECK_TRUE at line " << __LINE__ << " failed: " << #x \
<< '\n'; \
return; \
} else { \
++checks_passed; \
} \
} while (false);
#define CHECK_FALSE(x) \
do { \
++checks_checked; \
if (x) { \
std::cout << "CHECK_FALSE at line " << __LINE__ << " failed: " << #x \
<< '\n'; \
} else { \
++checks_passed; \
} \
} while (false);
#define ASSERT_FALSE(x) \
do { \
++checks_checked; \
if (x) { \
std::cout << "CHECK_FALSE at line " << __LINE__ << " failed: " << #x \
<< '\n'; \
return; \
} else { \
++checks_passed; \
} \
} while (false);
#define CHECK_FLOAT(var, value) \
do { \
++checks_checked; \
if ((var) > (value) - 0.0001F && (var) < (value) + 0.0001F) { \
++checks_passed; \
} else { \
std::cout << "CHECK_FLOAT at line " << __LINE__ << " failed: " << #var \
<< " != " << #value << '\n'; \
} \
} while (false);
#define CHECK_EQ(var, value) \
do { \
++checks_checked; \
if ((var) == (value)) { \
++checks_passed; \
} else { \
std::cout << "CHECK_EQ at line " << __LINE__ << " failed: " << #var \
<< " != " << #value << '\n'; \
} \
} while (false);
#define ASSERT_EQ(var, value) \
do { \
++checks_checked; \
if ((var) == (value)) { \
++checks_passed; \
} else { \
std::cout << "ASSERT_EQ at line " << __LINE__ << " failed: " << #var \
<< " != " << #value << '\n'; \
return; \
} \
} while (false);
#define CHECK_NE(var, value) \
do { \
++checks_checked; \
if ((var) != (value)) { \
++checks_passed; \
} else { \
std::cout << "CHECK_NE at line " << __LINE__ << " failed: " << #var \
<< " == " << #value << '\n'; \
} \
} while (false);
#define CHECK_GE(var, value) \
do { \
++checks_checked; \
if ((var) >= (value)) { \
++checks_passed; \
} else { \
std::cout << "CHECK_GE at line " << __LINE__ << " failed: " << #var \
<< " < " << #value << '\n'; \
} \
} while (false);
#define CHECK_LE(var, value) \
do { \
++checks_checked; \
if ((var) <= (value)) { \
++checks_passed; \
} else { \
std::cout << "CHECK_LE at line " << __LINE__ << " failed: " << #var \
<< " > " << #value << '\n'; \
} \
} while (false);
#define CHECK_STREQ(str_a, str_b) \
do { \
++checks_checked; \
if (std::strcmp((str_a), (str_b)) == 0) { \
++checks_passed; \
} else { \
std::cout << "CHECK_STREQ at line " << __LINE__ << "failed: " << #str_a \
<< " != " << #str_b << '\n'; \
} \
} while (false);
// Tests.
void TEST_EC_Bitset();
void TEST_EC_Manager();
void TEST_EC_MoveComponentWithUniquePtr();
void TEST_EC_DeletedEntities();
void TEST_EC_FunctionStorage();
void TEST_EC_DeletedEntityID();
void TEST_EC_MultiThreaded();
void TEST_EC_ForMatchingSignatures();
void TEST_EC_forMatchingPtrs();
void TEST_EC_context();
void TEST_EC_FunctionStorageOrder();
void TEST_EC_forMatchingSimple();
void TEST_EC_forMatchingIterableFn();
void TEST_EC_MultiThreadedForMatching();
void TEST_EC_ManagerWithLowThreadCount();
void TEST_EC_ManagerDeferredDeletions();
void TEST_EC_NestedThreadPoolTasks();
void TEST_Meta_Contains();
void TEST_Meta_ContainsAll();
void TEST_Meta_IndexOf();
void TEST_Meta_Bitset();
void TEST_Meta_Combine();
void TEST_Meta_Morph();
void TEST_Meta_TypeListGet();
void TEST_Meta_ForEach();
void TEST_Meta_Matching();
void TEST_ECThreadPool_OneThread();
void TEST_ECThreadPool_Simple();
void TEST_ECThreadPool_QueryCount();
void TEST_ECThreadPool_easyStartAndWait();
#endif