aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Pensjö <lars.pensjo@gmail.com>2013-02-27 07:38:47 +0100
committerLars Pensjö <lars.pensjo@gmail.com>2013-02-27 07:38:47 +0100
commit4653a437cdc9f3b305b238b86ad71bfd1e21cf1f (patch)
tree972475c2ba67ac3f26570cd891054aa6268af54c
parent584812b6054a95f4346bbadcbbb54b5e72c2d746 (diff)
Enable testing for Linux with gcc.
Resolve namespace std clash with boost. struct NullDeleter can't be local. Remove surplus ';'.
-rw-r--r--README.md18
-rw-r--r--entityx/Entity_test.cc16
-rw-r--r--entityx/System_test.cc5
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> {
Collision(Entity left, Entity right) : left(left), right(right) {}
-
+
Entity left, right;
};
```
@@ -181,7 +181,7 @@ class GameManager : public Manager {
system_manager.add<MovementSystem>();
system_manager.add<CollisionSystem>();
}
-
+
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<Direction>((rand() % 10) - 5, (rand() % 10) - 5);
}
}
-
+
void update(double dt) {
system_manager.update<MovementSystem>(dt);
system_manager.update<CollisionSystem>(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 <alec@swapoff.org>
*/
@@ -16,10 +16,12 @@
#include <gtest/gtest.h>
#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 <typename T>
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<typename T> void operator()(T*) {} };
+
TEST_F(EntityManagerTest, TestUnpackNullMissing) {
Entity::Id e = em.create();
auto p = em.assign<Position>(e);
- struct NullDeleter {template<typename T> void operator()(T*) {} };
shared_ptr<Position> up(reinterpret_cast<Position*>(0Xdeadbeef), NullDeleter());
shared_ptr<Direction> ud(reinterpret_cast<Direction*>(0Xdeadbeef), NullDeleter());
em.unpack<Position, Direction>(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<EntityDestroyedEventReceiver> {
@@ -249,7 +253,7 @@ TEST_F(EntityManagerTest, TestEntityDestroyedEvent) {
em.destroy(e);
}
ASSERT_TRUE(entities == receiver.destroyed);
-};
+}
TEST_F(EntityManagerTest, TestComponentAddedEvent) {
struct ComponentAddedEventReceiver : public Receiver<ComponentAddedEventReceiver> {
@@ -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 <alec@swapoff.org>
*/
@@ -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> {
Position(float x = 0.0f, float y = 0.0f) : x(x), y(y) {}