#include #include "Core/EventBroker.h" #include "Core/World.h" #include "Core/CTemplate.h" using namespace dd; struct TestComponent : public Component { int Int = 5; float Float = 1.33333f; double Double = 1.33333; std::string String = "Hello World"; }; BOOST_AUTO_TEST_CASE(EntityCloneTest) { // Setup world std::shared_ptr eventBroker = std::make_shared(); World world(eventBroker); world.ComponentFactory.Register(); world.ComponentFactory.Register(); // Create our original entity EntityID entOriginal = world.CreateEntity(); world.AddComponent(entOriginal); world.AddComponent(entOriginal); // Clone it EntityID entClone = world.CloneEntity(entOriginal); // Check // EntityID of clone should not be same as original (obviously) BOOST_CHECK(entOriginal != entClone); // Template component SHOULD be in clone auto templateComponentClone = world.GetComponent(entClone); BOOST_REQUIRE(templateComponentClone != nullptr); // Values should be the same across the clone auto testComponentOriginal = world.GetComponent(entOriginal); BOOST_REQUIRE(testComponentOriginal != nullptr); auto testComponentClone = world.GetComponent(entClone); BOOST_REQUIRE(testComponentClone != nullptr); BOOST_CHECK(testComponentClone->Int == testComponentOriginal->Int); BOOST_CHECK(testComponentClone->Float == testComponentOriginal->Float); BOOST_CHECK(testComponentClone->Double == testComponentOriginal->Double); BOOST_CHECK(testComponentClone->String == testComponentOriginal->String); }