Compare commits

..

No commits in common. "c016fcdbd987e962b3514aece75a3ef9db01073f" and "b7117c09b33b6b97839a26b2d22feb799998c40c" have entirely different histories.

9 changed files with 338 additions and 552 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 cmake run: sudo /usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get install libgtest-dev 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

@ -1,6 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2016-2019,2021-2022,2024 Stephen Seo Copyright (c) 2016-2019,2021-2022 Stephen Seo
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -1,20 +0,0 @@
from conan import ConanFile
from conan.tools.files import copy
class ECMSConan(ConanFile):
name = "ecms"
version = "1.0"
# No settings/options are necessary, this is header only
exports_sources = "src/EC/*"
no_copy_source = True
def package(self):
# This will also copy the "include" folder
copy(self, "*.hpp", self.source_folder, self.package_folder)
def package_info(self):
# For header-only packages, libdirs and bindirs are not used
# so it's recommended to set those as empty.
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []

View file

@ -47,6 +47,8 @@ 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
@ -55,12 +57,13 @@ set(UnitTests_SOURCES
) )
add_executable(UnitTests ${UnitTests_SOURCES}) add_executable(UnitTests ${UnitTests_SOURCES})
target_link_libraries(UnitTests EntityComponentSystem) target_link_libraries(UnitTests EntityComponentSystem ${GTEST_LIBRARIES})
target_include_directories(UnitTests PUBLIC ${GTEST_INCLUDE_DIR})
target_compile_features(UnitTests PUBLIC cxx_std_17) target_compile_features(UnitTests PUBLIC cxx_std_17)
target_compile_options(UnitTests PRIVATE "-Wno-sign-compare")
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,44 +1,8 @@
#include "test_helpers.h"
int checks_checked = 0; #include <gtest/gtest.h>
int checks_passed = 0;
int main() { int main(int argc, char** argv)
TEST_EC_Bitset(); {
TEST_EC_Manager(); ::testing::InitGoogleTest(&argc, argv);
TEST_EC_MoveComponentWithUniquePtr(); return RUN_ALL_TESTS();
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,4 +1,5 @@
#include "test_helpers.h"
#include <gtest/gtest.h>
#include <tuple> #include <tuple>
#include <EC/Meta/Meta.hpp> #include <EC/Meta/Meta.hpp>
@ -27,179 +28,179 @@ struct Storage
using type = std::tuple<std::vector<STypes>... >; using type = std::tuple<std::vector<STypes>... >;
}; };
void TEST_Meta_Contains() TEST(Meta, Contains)
{ {
int size = ListComponentsAll::size; int size = ListComponentsAll::size;
CHECK_EQ(size, 4); EXPECT_EQ(size, 4);
bool result = EC::Meta::Contains<C0, ListComponentsAll>::value; bool result = EC::Meta::Contains<C0, ListComponentsAll>::value;
CHECK_TRUE(result); EXPECT_TRUE(result);
result = EC::Meta::Contains<C1, ListComponentsAll>::value; result = EC::Meta::Contains<C1, ListComponentsAll>::value;
CHECK_TRUE(result); EXPECT_TRUE(result);
result = EC::Meta::Contains<C2, ListComponentsAll>::value; result = EC::Meta::Contains<C2, ListComponentsAll>::value;
CHECK_TRUE(result); EXPECT_TRUE(result);
result = EC::Meta::Contains<C3, ListComponentsAll>::value; result = EC::Meta::Contains<C3, ListComponentsAll>::value;
CHECK_TRUE(result); EXPECT_TRUE(result);
size = ListComponentsSome::size; size = ListComponentsSome::size;
CHECK_EQ(size, 2); EXPECT_EQ(size, 2);
result = EC::Meta::Contains<C0, ListComponentsSome>::value; result = EC::Meta::Contains<C0, ListComponentsSome>::value;
CHECK_FALSE(result); EXPECT_FALSE(result);
result = EC::Meta::Contains<C1, ListComponentsSome>::value; result = EC::Meta::Contains<C1, ListComponentsSome>::value;
CHECK_TRUE(result); EXPECT_TRUE(result);
result = EC::Meta::Contains<C2, ListComponentsSome>::value; result = EC::Meta::Contains<C2, ListComponentsSome>::value;
CHECK_FALSE(result); EXPECT_FALSE(result);
result = EC::Meta::Contains<C3, ListComponentsSome>::value; result = EC::Meta::Contains<C3, ListComponentsSome>::value;
CHECK_TRUE(result); EXPECT_TRUE(result);
} }
void TEST_Meta_ContainsAll() TEST(Meta, ContainsAll)
{ {
bool contains = EC::Meta::ContainsAll<ListComponentsSome, ListComponentsAll>::value; bool contains = EC::Meta::ContainsAll<ListComponentsSome, ListComponentsAll>::value;
CHECK_TRUE(contains); EXPECT_TRUE(contains);
contains = EC::Meta::ContainsAll<ListComponentsAll, ListComponentsSome>::value; contains = EC::Meta::ContainsAll<ListComponentsAll, ListComponentsSome>::value;
CHECK_FALSE(contains); EXPECT_FALSE(contains);
contains = EC::Meta::ContainsAll<ListComponentsAll, ListComponentsAll>::value; contains = EC::Meta::ContainsAll<ListComponentsAll, ListComponentsAll>::value;
CHECK_TRUE(contains); EXPECT_TRUE(contains);
} }
void TEST_Meta_IndexOf() TEST(Meta, IndexOf)
{ {
int index = EC::Meta::IndexOf<C0, ListComponentsAll>::value; int index = EC::Meta::IndexOf<C0, ListComponentsAll>::value;
CHECK_EQ(index, 0); EXPECT_EQ(index, 0);
index = EC::Meta::IndexOf<C1, ListComponentsAll>::value; index = EC::Meta::IndexOf<C1, ListComponentsAll>::value;
CHECK_EQ(index, 1); EXPECT_EQ(index, 1);
index = EC::Meta::IndexOf<C2, ListComponentsAll>::value; index = EC::Meta::IndexOf<C2, ListComponentsAll>::value;
CHECK_EQ(index, 2); EXPECT_EQ(index, 2);
index = EC::Meta::IndexOf<C3, ListComponentsAll>::value; index = EC::Meta::IndexOf<C3, ListComponentsAll>::value;
CHECK_EQ(index, 3); EXPECT_EQ(index, 3);
index = EC::Meta::IndexOf<T0, ListComponentsAll>::value; index = EC::Meta::IndexOf<T0, ListComponentsAll>::value;
CHECK_EQ(index, 4); EXPECT_EQ(index, 4);
index = EC::Meta::IndexOf<C1, ListComponentsSome>::value; index = EC::Meta::IndexOf<C1, ListComponentsSome>::value;
CHECK_EQ(index, 0); EXPECT_EQ(index, 0);
index = EC::Meta::IndexOf<C3, ListComponentsSome>::value; index = EC::Meta::IndexOf<C3, ListComponentsSome>::value;
CHECK_EQ(index, 1); EXPECT_EQ(index, 1);
index = EC::Meta::IndexOf<C2, ListComponentsSome>::value; index = EC::Meta::IndexOf<C2, ListComponentsSome>::value;
CHECK_EQ(index, 2); EXPECT_EQ(index, 2);
} }
void TEST_Meta_Bitset() TEST(Meta, Bitset)
{ {
EC::Bitset<ListComponentsAll, ListTagsAll> bitset; EC::Bitset<ListComponentsAll, ListTagsAll> bitset;
CHECK_EQ(bitset.size(), ListComponentsAll::size + ListTagsAll::size + 1); EXPECT_EQ(bitset.size(), ListComponentsAll::size + ListTagsAll::size + 1);
bitset[EC::Meta::IndexOf<C1, ListComponentsAll>::value] = true; bitset[EC::Meta::IndexOf<C1, ListComponentsAll>::value] = true;
CHECK_TRUE(bitset.getComponentBit<C1>()); EXPECT_TRUE(bitset.getComponentBit<C1>());
bitset.flip(); bitset.flip();
CHECK_FALSE(bitset.getComponentBit<C1>()); EXPECT_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;
CHECK_TRUE(bitset.getTagBit<T0>()); EXPECT_TRUE(bitset.getTagBit<T0>());
bitset.flip(); bitset.flip();
CHECK_FALSE(bitset.getTagBit<T0>()); EXPECT_FALSE(bitset.getTagBit<T0>());
} }
void TEST_Meta_Combine() 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;
CHECK_EQ(combinedAllTemp, listAllTemp); EXPECT_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;
CHECK_EQ(combinedAllTemp, listAllTemp); EXPECT_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;
CHECK_EQ(combinedAllTemp, listAllTemp); EXPECT_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;
CHECK_EQ(combinedAllTemp, listAllTemp); EXPECT_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;
CHECK_EQ(combinedAllTemp, listAllTemp); EXPECT_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;
CHECK_EQ(combinedAllTemp, listAllTemp); EXPECT_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;
CHECK_EQ(combinedAllTemp, listAllTemp); EXPECT_EQ(combinedAllTemp, listAllTemp);
bool same = std::is_same<CombinedAll, ListAll>::value; bool same = std::is_same<CombinedAll, ListAll>::value;
CHECK_TRUE(same); EXPECT_TRUE(same);
} }
void TEST_Meta_Morph() 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;
CHECK_EQ(morphedTupleTemp, componentsTemp); EXPECT_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;
CHECK_EQ(morphedTupleTemp, componentsTemp); EXPECT_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;
CHECK_EQ(morphedTupleTemp, componentsTemp); EXPECT_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;
CHECK_EQ(morphedTupleTemp, componentsTemp); EXPECT_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;
CHECK_EQ(morphedTupleTemp, componentsTemp); EXPECT_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;
CHECK_TRUE(isSame); EXPECT_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;
CHECK_TRUE(isSame); EXPECT_TRUE(isSame);
} }
void TEST_Meta_TypeListGet() 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;
CHECK_TRUE(isSame); EXPECT_TRUE(isSame);
isSame = std::is_same<C1, EC::Meta::TypeListGet<ListAll, 1> >::value; isSame = std::is_same<C1, EC::Meta::TypeListGet<ListAll, 1> >::value;
CHECK_TRUE(isSame); EXPECT_TRUE(isSame);
isSame = std::is_same<C2, EC::Meta::TypeListGet<ListAll, 2> >::value; isSame = std::is_same<C2, EC::Meta::TypeListGet<ListAll, 2> >::value;
CHECK_TRUE(isSame); EXPECT_TRUE(isSame);
isSame = std::is_same<C3, EC::Meta::TypeListGet<ListAll, 3> >::value; isSame = std::is_same<C3, EC::Meta::TypeListGet<ListAll, 3> >::value;
CHECK_TRUE(isSame); EXPECT_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;
CHECK_TRUE(isSame); EXPECT_TRUE(isSame);
isSame = std::is_same<T1, EC::Meta::TypeListGet<ListAll, 5> >::value; isSame = std::is_same<T1, EC::Meta::TypeListGet<ListAll, 5> >::value;
CHECK_TRUE(isSame); EXPECT_TRUE(isSame);
} }
void TEST_Meta_ForEach() TEST(Meta, ForEach)
{ {
EC::Bitset<ListComponentsAll, ListTagsAll> bitset; EC::Bitset<ListComponentsAll, ListTagsAll> bitset;
@ -209,32 +210,32 @@ void TEST_Meta_ForEach()
EC::Meta::forEach<ListComponentsSome>(setBits); EC::Meta::forEach<ListComponentsSome>(setBits);
CHECK_FALSE(bitset[0]); EXPECT_FALSE(bitset[0]);
CHECK_TRUE(bitset[1]); EXPECT_TRUE(bitset[1]);
CHECK_FALSE(bitset[2]); EXPECT_FALSE(bitset[2]);
CHECK_TRUE(bitset[3]); EXPECT_TRUE(bitset[3]);
CHECK_FALSE(bitset[4]); EXPECT_FALSE(bitset[4]);
CHECK_FALSE(bitset[5]); EXPECT_FALSE(bitset[5]);
} }
void TEST_Meta_Matching() 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;
CHECK_TRUE(isSame); EXPECT_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;
CHECK_TRUE(isSame); EXPECT_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;
CHECK_TRUE(isSame); EXPECT_TRUE(isSame);
} }
} }

View file

@ -1,11 +1,11 @@
#include "test_helpers.h" #include <gtest/gtest.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>;
void TEST_ECThreadPool_OneThread() { 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 @@ void TEST_ECThreadPool_OneThread() {
ASSERT_EQ(data.load(), 11); ASSERT_EQ(data.load(), 11);
} }
void TEST_ECThreadPool_Simple() { 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 @@ void TEST_ECThreadPool_Simple() {
ASSERT_EQ(data.load(), 11); ASSERT_EQ(data.load(), 11);
} }
void TEST_ECThreadPool_QueryCount() { TEST(ECThreadPool, QueryCount) {
{ {
OneThreadPool oneP; OneThreadPool oneP;
ASSERT_EQ(1, oneP.getMaxThreadCount()); ASSERT_EQ(1, oneP.getMaxThreadCount());
@ -78,7 +78,7 @@ void TEST_ECThreadPool_QueryCount() {
} }
} }
void TEST_ECThreadPool_easyStartAndWait() { TEST(ECThreadPool, easyStartAndWait) {
std::atomic_int data; std::atomic_int data;
data.store(0); data.store(0);
{ {
@ -90,7 +90,7 @@ void TEST_ECThreadPool_easyStartAndWait() {
}, &data); }, &data);
} }
oneP.easyStartAndWait(); oneP.easyStartAndWait();
CHECK_EQ(20, data.load()); EXPECT_EQ(20, data.load());
} }
{ {
ThreeThreadPool threeP; ThreeThreadPool threeP;
@ -101,6 +101,6 @@ void TEST_ECThreadPool_easyStartAndWait() {
}, &data); }, &data);
} }
threeP.easyStartAndWait(); threeP.easyStartAndWait();
CHECK_EQ(40, data.load()); EXPECT_EQ(40, data.load());
} }
} }

View file

@ -1,163 +0,0 @@
#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