summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2015-06-08 21:21:08 +0200
committerJustin Worthe <justin.worthe@gmail.com>2015-06-08 21:21:08 +0200
commit72eaaeb60916e736de6c1aaa3d1047663bce19d9 (patch)
tree9d11b011144c83f8d64ea6eb994573dfd9b83ae5 /test
parent0ef4646a9c19d3d88ffb7674123ccdc0a9012d98 (diff)
Started adding test for reading game state
Diffstat (limited to 'test')
-rw-r--r--test/game_state.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/game_state.cpp b/test/game_state.cpp
new file mode 100644
index 0000000..0887b05
--- /dev/null
+++ b/test/game_state.cpp
@@ -0,0 +1,59 @@
+#include "catch.hpp"
+#include <sstream>
+
+#include "game_state.h"
+
+SCENARIO("game state is read from istream")
+{
+ GIVEN("a valid map file")
+ {
+ std::stringstream file;
+ file << "###################" << std::endl;
+ file << "# Node Sample Bot #" << std::endl;
+ file << "# Round: 1 #" << std::endl;
+ file << "# Kills: 0 #" << std::endl;
+ file << "# Lives: 2 #" << std::endl;
+ file << "# Missiles: 0/1 #" << std::endl;
+ file << "###################" << std::endl;
+ file << "# #" << std::endl;
+ file << "# VVV #" << 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 << "# x x x #" << std::endl;
+ 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 << "# AAA #" << std::endl;
+ file << "# #" << std::endl;
+ file << "###################" << std::endl;
+ file << "# Missiles: 0/1 #" << std::endl;
+ file << "# Lives: 2 #" << std::endl;
+ file << "# Kills: 0 #" << std::endl;
+ file << "# Round: 1 #" << std::endl;
+ file << "# Node Sample Bot #" << std::endl;
+ file << "###################" << std::endl;
+
+ WHEN ("the game state is initilized")
+ {
+ GameState state(std::move(file));
+ THEN("the map is read correctly")
+ {
+ auto aliens = state.aliens();
+ REQUIRE(aliens.size() == 6);
+ }
+ }
+ }
+}