From 4653a437cdc9f3b305b238b86ad71bfd1e21cf1f Mon Sep 17 00:00:00 2001 From: Lars Pensjö Date: Wed, 27 Feb 2013 07:38:47 +0100 Subject: Enable testing for Linux with gcc. Resolve namespace std clash with boost. struct NullDeleter can't be local. Remove surplus ';'. --- README.md | 18 +++++++++++------- entityx/Entity_test.cc | 16 ++++++++++------ entityx/System_test.cc | 5 +++-- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 611dc98..428adfe 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ First, we define the event type, which for our example is simply the two entitie ```c++ struct Collision : public Event { Collision(Entity left, Entity right) : left(left), right(right) {} - + Entity left, right; }; ``` @@ -181,7 +181,7 @@ class GameManager : public Manager { system_manager.add(); system_manager.add(); } - + void initialize() { // Create some entities in random locations heading in random directions for (int i = 0; i < 100; ++i) { @@ -190,7 +190,7 @@ class GameManager : public Manager { entity.assign((rand() % 10) - 5, (rand() % 10) - 5); } } - + void update(double dt) { system_manager.update(dt); system_manager.update(dt); @@ -206,12 +206,16 @@ EntityX has the following build and runtime requirements: - [CMake](http://cmake.org/) - [Boost](http://boost.org) `1.48.0` or higher (links against `boost::signals`). - [Glog](http://code.google.com/p/google-glog/) (tested with `0.3.2`). -- [GTest](http://code.google.com/p/googletest/) +- [GTest](http://code.google.com/p/googletest/) (needed for testing only) -Once these dependencies are installed you should be able to build and install EntityX with: +Once these dependencies are installed you should be able to build and install EntityX as follows. BUILD_TESTING is false by default. ```c++ -mkdir build && cd build && cmake .. && make && make test && make install +mkdir build +cd build +cmake [-DBUILD_TESTING=true] .. +make +make install ``` -EntityX has currently only been tested on Mac OSX (Lion and Mountain Lion). Reports and patches for builds on other platforms are welcome. +EntityX has currently only been tested on Mac OSX (Lion and Mountain Lion), and Linux Debian. Reports and patches for builds on other platforms are welcome. diff --git a/entityx/Entity_test.cc b/entityx/Entity_test.cc index 55da405..67026e8 100644 --- a/entityx/Entity_test.cc +++ b/entityx/Entity_test.cc @@ -4,7 +4,7 @@ * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. - * + * * Author: Alec Thomas */ @@ -16,10 +16,12 @@ #include #include "entityx/Entity.h" -using namespace std; +// using namespace std; // This will give name space conflicts with boost using namespace boost; using namespace entityx; +using std::ostream; +using std::vector; template int size(const T &t) { @@ -192,11 +194,13 @@ TEST_F(EntityManagerTest, TestUnpack) { ASSERT_EQ(d, ud); } +// gcc 4.7.2 does not allow this struct to be declared locally inside the TEST_F. +struct NullDeleter {template void operator()(T*) {} }; + TEST_F(EntityManagerTest, TestUnpackNullMissing) { Entity::Id e = em.create(); auto p = em.assign(e); - struct NullDeleter {template void operator()(T*) {} }; shared_ptr up(reinterpret_cast(0Xdeadbeef), NullDeleter()); shared_ptr ud(reinterpret_cast(0Xdeadbeef), NullDeleter()); em.unpack(e, up, ud); @@ -225,7 +229,7 @@ TEST_F(EntityManagerTest, TestEntityCreatedEvent) { em.create(); } ASSERT_EQ(10, receiver.created.size()); -}; +} TEST_F(EntityManagerTest, TestEntityDestroyedEvent) { struct EntityDestroyedEventReceiver : public Receiver { @@ -249,7 +253,7 @@ TEST_F(EntityManagerTest, TestEntityDestroyedEvent) { em.destroy(e); } ASSERT_TRUE(entities == receiver.destroyed); -}; +} TEST_F(EntityManagerTest, TestComponentAddedEvent) { struct ComponentAddedEventReceiver : public Receiver { @@ -289,4 +293,4 @@ TEST_F(EntityManagerTest, TestComponentAddedEvent) { } ASSERT_EQ(10, receiver.position_events); ASSERT_EQ(10, receiver.direction_events); -}; +} diff --git a/entityx/System_test.cc b/entityx/System_test.cc index 63da01f..c529bd1 100644 --- a/entityx/System_test.cc +++ b/entityx/System_test.cc @@ -4,7 +4,7 @@ * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. - * + * * Author: Alec Thomas */ @@ -16,9 +16,10 @@ #include "entityx/System.h" -using namespace std; +// using namespace std; // This will give name space conflicts with boost using namespace boost; using namespace entityx; +using std::string; struct Position : Component { Position(float x = 0.0f, float y = 0.0f) : x(x), y(y) {} -- cgit v1.2.3