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();
|
|
|
|
}
|
|
|
|
|
2023-06-10 07:03:07 +00:00
|
|
|
void RunWhitelistTest(const int32_t whitelistIndex, std::vector<eReplicaComponentType> componentList) {
|
|
|
|
Game::logger->Log("EntityTests", "whitelist test %i", whitelistIndex);
|
|
|
|
entity->SetVar<int32_t>(u"componentWhitelist", whitelistIndex);
|
|
|
|
entity->ApplyComponentWhitelist(componentList);
|
|
|
|
const auto whitelist = Entity::GetComponentWhitelists().at(whitelistIndex);
|
|
|
|
std::for_each(whitelist.begin(), whitelist.end(), [&componentList](const eReplicaComponentType& keptComponent) {
|
|
|
|
EXPECT_EQ(std::count(componentList.begin(), componentList.end(), keptComponent), 2);
|
|
|
|
});
|
2023-06-10 06:02:28 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(EntityTests, WhitelistTest) {
|
|
|
|
const auto whitelists = Entity::GetComponentWhitelists();
|
2023-06-10 07:03:07 +00:00
|
|
|
std::vector<eReplicaComponentType> components = {
|
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,
|
|
|
|
};
|
2023-06-10 07:03:07 +00:00
|
|
|
RunWhitelistTest(0, components);
|
|
|
|
RunWhitelistTest(1, components);
|
|
|
|
RunWhitelistTest(2, components);
|
|
|
|
RunWhitelistTest(3, components);
|
|
|
|
RunWhitelistTest(4, components);
|
2023-06-10 06:02:28 +00:00
|
|
|
}
|