summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2015-06-12 16:30:29 +0200
committerJustin Worthe <justin.worthe@gmail.com>2015-06-12 16:30:29 +0200
commit63ab384440a6e6813196b914813914bc43674fa8 (patch)
tree7b62e33239b477b058991160d48edbaf2c10ac9b /test
parent72eaaeb60916e736de6c1aaa3d1047663bce19d9 (diff)
Added new tests
Diffstat (limited to 'test')
-rw-r--r--test/game_state.cpp39
-rw-r--r--test/move_string_mapper.cpp23
2 files changed, 58 insertions, 4 deletions
diff --git a/test/game_state.cpp b/test/game_state.cpp
index 0887b05..467a665 100644
--- a/test/game_state.cpp
+++ b/test/game_state.cpp
@@ -19,7 +19,7 @@ SCENARIO("game state is read from istream")
file << "# VVV #" << std::endl;
file << "# --- --- #" << std::endl;
file << "# --- --- #" << std::endl;
- file << "# --- --- #" << std::endl;
+ file << "# --- i --- #" << std::endl;
file << "# #" << std::endl;
file << "# #" << std::endl;
file << "# #" << std::endl;
@@ -29,10 +29,10 @@ SCENARIO("game state is read from istream")
file << "# #" << std::endl;
file << "# x x x #" << std::endl;
file << "# #" << std::endl;
+ file << "# | #" << std::endl;
file << "# #" << std::endl;
file << "# #" << std::endl;
- file << "# #" << std::endl;
- file << "# #" << std::endl;
+ file << "# ! #" << std::endl;
file << "# --- --- #" << std::endl;
file << "# --- --- #" << std::endl;
file << "# --- --- #" << std::endl;
@@ -49,10 +49,41 @@ SCENARIO("game state is read from istream")
WHEN ("the game state is initilized")
{
GameState state(std::move(file));
- THEN("the map is read correctly")
+
+ THEN("the aliens are read correctly")
{
auto aliens = state.aliens();
REQUIRE(aliens.size() == 6);
+ REQUIRE(aliens[0].x() == 10);
+ REQUIRE(aliens[0].y() == 11);
+ REQUIRE(aliens[5].x() == 16);
+ REQUIRE(aliens[5].y() == 13);
+ }
+
+ THEN("the shields are read correctly")
+ {
+ auto shields = state.shields();
+ REQUIRE(shields.size() == 36);
+ }
+
+ THEN("the enemy bullets are read correctly")
+ {
+ auto bullets = state.bullets();
+ REQUIRE(bullets.size() == 2);
+ }
+
+ THEN("the player missiles are read correctly")
+ {
+ auto missiles = state.missiles();
+ REQUIRE(missiles.size() == 1);
+ REQUIRE(missiles[0].x() == 11);
+ REQUIRE(missiles[0].y() == 18);
+ }
+
+ THEN("the spaceships are read correctly")
+ {
+ auto spaceships = state.spaceships();
+ REQUIRE(spaceships.size() == 2);
}
}
}
diff --git a/test/move_string_mapper.cpp b/test/move_string_mapper.cpp
new file mode 100644
index 0000000..ab167e3
--- /dev/null
+++ b/test/move_string_mapper.cpp
@@ -0,0 +1,23 @@
+#include "catch.hpp"
+#include "move.h"
+#include <string>
+#include "move_string_mapper.h"
+
+SCENARIO("Writing a move")
+{
+ GIVEN("A Move")
+ {
+ Move move = Move::MOVE_LEFT;
+
+ WHEN("It is mapped to a string")
+ {
+ std::string moveString = MoveStringMapper().toString(move);
+
+ THEN("The string is correct")
+ {
+ REQUIRE(moveString == "MoveLeft");
+ }
+ }
+
+ }
+}