Adding a couple of Ghost tests.
This commit is contained in:
parent
aa45121bec
commit
cbe5798590
1 changed files with 54 additions and 0 deletions
54
test/testGhost.cpp
Normal file
54
test/testGhost.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include "Blinky.hpp"
|
||||
#include "Clyde.hpp"
|
||||
#include "Inky.hpp"
|
||||
#include "Pinky.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
template<typename T>
|
||||
static void ghostInitHelper(const T& ghost, const double x, const double y) {
|
||||
const pacman::Position pos{ x, y };
|
||||
EXPECT_EQ(ghost.position(), pos);
|
||||
|
||||
const pacman::GridPosition gridPos = pacman::positionToGridPosition(pos);
|
||||
EXPECT_EQ(ghost.positionInGrid(), gridPos);
|
||||
|
||||
EXPECT_FALSE(ghost.isEyes());
|
||||
EXPECT_FALSE(ghost.isFrightened());
|
||||
}
|
||||
|
||||
TEST(GhostTest, Init) {
|
||||
pacman::Blinky blinky;
|
||||
ghostInitHelper(blinky, 13.5, 11);
|
||||
|
||||
pacman::Clyde clyde;
|
||||
ghostInitHelper(clyde, 15.5, 14);
|
||||
|
||||
pacman::Inky inky;
|
||||
ghostInitHelper(inky, 13.5, 14);
|
||||
|
||||
pacman::Pinky pinky;
|
||||
ghostInitHelper(pinky, 11.5, 14);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static void ghostFrightenHelper(T& ghost) {
|
||||
EXPECT_FALSE(ghost.isFrightened());
|
||||
ghost.frighten();
|
||||
EXPECT_TRUE(ghost.isFrightened());
|
||||
ghost.reset();
|
||||
EXPECT_FALSE(ghost.isFrightened());
|
||||
}
|
||||
|
||||
TEST(GhostTest, Frighten) {
|
||||
pacman::Blinky blinky;
|
||||
ghostFrightenHelper(blinky);
|
||||
|
||||
pacman::Clyde clyde;
|
||||
ghostFrightenHelper(clyde);
|
||||
|
||||
pacman::Inky inky;
|
||||
ghostFrightenHelper(inky);
|
||||
|
||||
pacman::Pinky pinky;
|
||||
ghostFrightenHelper(pinky);
|
||||
}
|
Loading…
Reference in a new issue