/* * Copyright (C) 2013 Alec Thomas * All rights reserved. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. * * Author: Alec Thomas */ #define CATCH_CONFIG_MAIN #include "entityx/3rdparty/catch.hpp" #include "entityx/deps/Dependencies.h" #include "entityx/quick.h" namespace deps = entityx::deps; struct A : public entityx::Component {}; struct B : public entityx::Component { explicit B(bool b = false) : b(b) {} bool b; }; struct C : public entityx::Component {}; TEST_CASE_METHOD(entityx::EntityX, "TestSingleDependency") { systems.add>(); systems.configure(); entityx::Entity e = entities.create(); REQUIRE(!static_cast(e.component())); REQUIRE(!static_cast(e.component())); e.assign(); REQUIRE(static_cast(e.component())); REQUIRE(static_cast(e.component())); } TEST_CASE_METHOD(entityx::EntityX, "TestMultipleDependencies") { systems.add>(); systems.configure(); entityx::Entity e = entities.create(); REQUIRE(!static_cast(e.component())); REQUIRE(!static_cast(e.component())); REQUIRE(!static_cast(e.component())); e.assign(); REQUIRE(static_cast(e.component())); REQUIRE(static_cast(e.component())); REQUIRE(static_cast(e.component())); } TEST_CASE_METHOD(entityx::EntityX, "TestDependencyDoesNotRecreateComponent") { systems.add>(); systems.configure(); entityx::Entity e = entities.create(); e.assign(true); REQUIRE(e.component()->b); e.assign(); REQUIRE(e.component()->b); }