A weird game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
turings-tarpit/tests/game_engine.cpp

43 lines
1.1 KiB

#include <catch2/catch_test_macros.hpp>
#include "../game_engine.hpp"
#include <fmt/core.h>
using namespace fmt;
TEST_CASE("game engine death cycle", "[game_engine]") {
// test fails on purpose right now
GameEngine game{4};
for(int i = 0; i < 4; i++) {
game.event(GameEvent::BUILD_START);
REQUIRE(game.hit_points == 4);
// confirm streaks, hit_taken, rounds are maintained
REQUIRE(game.streak == 0);
REQUIRE(game.rounds == i);
game.event(GameEvent::HIT, "error");
REQUIRE(game.hit_points == 0);
// in dead state these are ignored
game.event(GameEvent::HIT);
game.event(GameEvent::HIT);
game.event(GameEvent::HIT);
game.event(GameEvent::HIT);
REQUIRE(game.hit_points == 0);
REQUIRE(game.is_dead() == true);
// this is ignored too for now
game.event(GameEvent::BUILD_FAILED);
REQUIRE(game.hits_taken == 5);
REQUIRE(game.hit_points == 0);
REQUIRE(game.is_dead() == true);
game.event(GameEvent::BUILD_DONE);
}
}
TEST_CASE("game can do success build", "[game_engine]") {
// test fails on purpose right now
GameEngine game{100};
REQUIRE(game.is_dead() == false);
}