Browse Source

Test LineClearSolid

LineClear-test
Anders Jenbo 5 years ago
parent
commit
14a22612b5
  1. 1
      CMakeLists.txt
  2. 2
      Source/monster.cpp
  3. 26
      test/monster_test.cpp

1
CMakeLists.txt

@ -506,6 +506,7 @@ if(RUN_TESTS)
test/lighting_test.cpp
test/main.cpp
test/missiles_test.cpp
test/monster_test.cpp
test/pack_test.cpp
test/player_test.cpp
test/scrollrt_test.cpp

2
Source/monster.cpp

@ -4783,7 +4783,7 @@ bool LineClear(bool (*Clear)(int, Point), int entity, Point startPoint, Point en
dincH = 2 * (dx + dy);
yincD = -1;
}
while (position != endPoint) {
while (!done && position != endPoint) {
if ((d <= 0) ^ (yincD < 0)) {
d += dincD;
} else {

26
test/monster_test.cpp

@ -0,0 +1,26 @@
#include <gtest/gtest.h>
#include "cursor.h"
#include "inv.h"
#include "player.h"
using namespace devilution;
bool TestGrid[5][5];
bool CheckNoSolid(int entity, Point position)
{
SDL_Log("%ix%i", position.x, position.y);
return true;//TestGrid[position.x][position.y];
}
TEST(Monster, LineClearSolid)
{
SDL_Log("05");
EXPECT_EQ(LineClear(CheckNoSolid, 0, { 0, 0 }, { 5, 1 }), true);
SDL_Log("50");
EXPECT_EQ(LineClear(CheckNoSolid, 0, { 5, 1 }, { 0, 0 }), true);
SDL_Log("05,2");
EXPECT_EQ(LineClear(CheckNoSolid, 0, { 0, 0 }, { 5, 2 }), true);
}
Loading…
Cancel
Save