Skip to content

Commit c372ebe

Browse files
authored
fix(ellens-alien-game): add check for hit requirement
There is a requirement for hit() method which states: "Make sure that the health points do not drop below zero." Adding a "get_health() == 0" at the end of the hit test now tests whether this is the case.
1 parent a224a68 commit c372ebe

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

exercises/concept/ellens-alien-game/ellens_alien_game_test.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ TEST_CASE("Alien is always hit", "[task_2]") {
3232
REQUIRE(alien.hit());
3333
}
3434

35-
TEST_CASE("Alien is alive while health is greater than 0 and stays dead afterwards", "[task_3]") {
35+
TEST_CASE(
36+
"Alien is alive while health is greater than 0 and stays dead afterwards",
37+
"[task_3]") {
3638
Alien alien{2, 54};
3739
REQUIRE(alien.is_alive());
3840
alien.hit();
@@ -43,6 +45,7 @@ TEST_CASE("Alien is alive while health is greater than 0 and stays dead afterwar
4345
REQUIRE(!alien.is_alive());
4446
alien.hit();
4547
REQUIRE(!alien.is_alive());
48+
REQUIRE(alien.get_health() == 0);
4649
}
4750

4851
TEST_CASE("Alien Teleports reports succesful", "[task_4]") {

0 commit comments

Comments
 (0)