DarkflameServer/tests/dGameTests/EntityTests.cpp

64 lines
1.9 KiB
C++
Raw Normal View History

2023-06-10 06:02:28 +00:00
#include <gtest/gtest.h>
#include <memory>
#include "Entity.h"
#include "GameDependencies.h"
#include "dCommonVars.h"
#include "eReplicaComponentType.h"
class EntityTests : public GameDependenciesTest {
protected:
std::unique_ptr<Entity> entity;
virtual void SetUp() {
entity = std::move(std::make_unique<Entity>(LWOOBJID_EMPTY, EntityInfo()));
this->SetUpDependencies();
}
virtual void TearDown() {
this->TearDownDependencies();
}
void RunWhitelistTest(const int32_t componentIndex, std::vector<eReplicaComponentType>& whitelist) {
entity->SetVar<int32_t>(u"componentWhitelist", componentIndex);
entity->ApplyComponentWhitelist(whitelist);
const auto whitelists = Entity::GetComponentWhitelists();
for (const auto& component : whitelists.at(componentIndex)) {
EXPECT_FALSE(std::find(whitelist.begin(), whitelist.end(), component) != whitelist.end());
}
}
};
TEST_F(EntityTests, WhitelistTest) {
const auto whitelists = Entity::GetComponentWhitelists();
std::vector<eReplicaComponentType> whitelist = {
2023-06-10 06:05:44 +00:00
eReplicaComponentType::CONTROLLABLE_PHYSICS,
2023-06-10 06:02:28 +00:00
eReplicaComponentType::SIMPLE_PHYSICS,
2023-06-10 06:05:44 +00:00
eReplicaComponentType::MODEL_BEHAVIOR,
eReplicaComponentType::SPAWN,
eReplicaComponentType::RENDER,
eReplicaComponentType::ITEM,
eReplicaComponentType::BLUEPRINT,
eReplicaComponentType::PET,
eReplicaComponentType::SKILL,
eReplicaComponentType::DESTROYABLE,
2023-06-10 06:02:28 +00:00
eReplicaComponentType::CONTROLLABLE_PHYSICS,
2023-06-10 06:05:44 +00:00
eReplicaComponentType::SIMPLE_PHYSICS,
eReplicaComponentType::MODEL_BEHAVIOR,
eReplicaComponentType::SPAWN,
2023-06-10 06:02:28 +00:00
eReplicaComponentType::RENDER,
2023-06-10 06:05:44 +00:00
eReplicaComponentType::ITEM,
eReplicaComponentType::BLUEPRINT,
eReplicaComponentType::PET,
eReplicaComponentType::SKILL,
2023-06-10 06:02:28 +00:00
eReplicaComponentType::DESTROYABLE,
};
RunWhitelistTest(0, whitelist);
RunWhitelistTest(1, whitelist);
RunWhitelistTest(2, whitelist);
RunWhitelistTest(3, whitelist);
RunWhitelistTest(4, whitelist);
}