Browse Source

Test basic Caves and Nests levels

pull/4661/head
Anders Jenbo 4 years ago
parent
commit
29a66f69e2
  1. 1
      test/CMakeLists.txt
  2. 10
      test/Fixtures.cmake
  3. 8
      test/drlg_l2_test.cpp
  4. 124
      test/drlg_l3_test.cpp
  5. 6
      test/drlg_l4_test.cpp
  6. BIN
      test/fixtures/diablo/10-1630062353.dun
  7. BIN
      test/fixtures/diablo/11-384626536.dun
  8. BIN
      test/fixtures/diablo/12-2104541047.dun
  9. BIN
      test/fixtures/diablo/9-262005438.dun
  10. BIN
      test/fixtures/hellfire/17-19770182.dun
  11. BIN
      test/fixtures/hellfire/18-1522546307.dun
  12. BIN
      test/fixtures/hellfire/19-125121312.dun
  13. BIN
      test/fixtures/hellfire/20-1511478689.dun

1
test/CMakeLists.txt

@ -21,6 +21,7 @@ set(tests
drlg_common_test
drlg_l1_test
drlg_l2_test
drlg_l3_test
drlg_l4_test
effects_test
file_util_test

10
test/Fixtures.cmake

@ -11,14 +11,22 @@ set(devilutionx_fixtures
diablo/6-2034738122.dun
diablo/7-680552750.dun
diablo/8-1999936419.dun
diablo/9-262005438.dun
diablo/10-1630062353.dun
diablo/11-384626536.dun
diablo/12-2104541047.dun
diablo/13-428074402.dun
diablo/14-717625719.dun
diablo/15-1583642716.dun
diablo/15-1583642716-changed.dun
diablo/15-1583642716.dun
hellfire/1-401921334.dun
hellfire/2-128964898.dun
hellfire/3-1799396623.dun
hellfire/4-1190318991.dun
hellfire/17-19770182.dun
hellfire/18-1522546307.dun
hellfire/19-125121312.dun
hellfire/20-1511478689.dun
hellfire/21-2122696790.dun
hellfire/22-1191662129.dun
hellfire/23-97055268.dun

8
test/drlg_l2_test.cpp

@ -47,7 +47,7 @@ void TestCreateL2Dungeon(int level, uint32_t seed, lvl_entry entry)
}
}
TEST(Drlg_l1, CreateL2Dungeon_diablo_5_1677631846)
TEST(Drlg_l2, CreateL2Dungeon_diablo_5_1677631846)
{
TestCreateL2Dungeon(5, 1677631846, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(27, 28));
@ -55,7 +55,7 @@ TEST(Drlg_l1, CreateL2Dungeon_diablo_5_1677631846)
EXPECT_EQ(ViewPosition, Point(26, 62));
}
TEST(Drlg_l1, CreateL2Dungeon_diablo_6_2034738122)
TEST(Drlg_l2, CreateL2Dungeon_diablo_6_2034738122)
{
TestCreateL2Dungeon(6, 2034738122, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(33, 26));
@ -63,7 +63,7 @@ TEST(Drlg_l1, CreateL2Dungeon_diablo_6_2034738122)
EXPECT_EQ(ViewPosition, Point(34, 52));
}
TEST(Drlg_l1, CreateL2Dungeon_diablo_7_680552750)
TEST(Drlg_l2, CreateL2Dungeon_diablo_7_680552750)
{
TestCreateL2Dungeon(7, 680552750, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(27, 26));
@ -71,7 +71,7 @@ TEST(Drlg_l1, CreateL2Dungeon_diablo_7_680552750)
EXPECT_EQ(ViewPosition, Point(78, 52));
}
TEST(Drlg_l1, CreateL2Dungeon_diablo_8_1999936419)
TEST(Drlg_l2, CreateL2Dungeon_diablo_8_1999936419)
{
TestCreateL2Dungeon(8, 1999936419, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(39, 74));

124
test/drlg_l3_test.cpp

@ -0,0 +1,124 @@
#include <fmt/format.h>
#include <gtest/gtest.h>
#include "drlg_l3.h"
#include "engine/load_file.hpp"
#include "gendung.h"
#include "quests.h"
#include "utils/paths.h"
using namespace devilution;
namespace {
void TestCreateL3Dungeon(int level, uint32_t seed, lvl_entry entry)
{
paths::SetPrefPath(paths::BasePath());
std::string dunPath;
if (level >= 9 && level <= 12) {
dunPath = fmt::format("test/fixtures/diablo/{}-{}.dun", level, seed);
pMegaTiles = std::make_unique<MegaTile[]>(206);
leveltype = DTYPE_CAVES;
} else if (level >= 17 && level <= 20) {
dunPath = fmt::format("test/fixtures/hellfire/{}-{}.dun", level, seed);
pMegaTiles = std::make_unique<MegaTile[]>(166);
leveltype = DTYPE_NEST;
}
currlevel = level;
CreateL3Dungeon(seed, entry);
auto dunData = LoadFileInMem<uint16_t>(dunPath.c_str());
ASSERT_NE(dunData, nullptr) << "Unable to load test fixture " << dunPath;
ASSERT_EQ(Size(DMAXX, DMAXY), Size(dunData[0], dunData[1]));
const uint16_t *tileLayer = &dunData[2];
for (int y = 0; y < DMAXY; y++) {
for (int x = 0; x < DMAXX; x++) {
auto tileId = static_cast<uint8_t>(SDL_SwapLE16(*tileLayer));
tileLayer++;
ASSERT_EQ(dungeon[x][y], tileId) << "Tiles don't match at " << x << "x" << y;
}
}
const uint16_t *transparentLayer = &dunData[2 + DMAXX * DMAXY * 13];
for (int y = 16; y < 16 + DMAXY * 2; y++) {
for (int x = 16; x < 16 + DMAXX * 2; x++) {
auto sectorId = static_cast<uint8_t>(SDL_SwapLE16(*transparentLayer));
transparentLayer++;
ASSERT_EQ(dTransVal[x][y], sectorId) << "Room/region indexes don't match at " << x << "x" << y;
}
}
}
TEST(Drlg_l3, CreateL3Dungeon_diablo_9_262005438)
{
TestCreateL3Dungeon(9, 262005438, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(41, 73));
TestCreateL3Dungeon(9, 262005438, ENTRY_PREV);
EXPECT_EQ(ViewPosition, Point(73, 59));
}
TEST(Drlg_l3, CreateL3Dungeon_diablo_10_1630062353)
{
Quests[Q_ANVIL]._qactive = QUEST_NOTAVAIL;
TestCreateL3Dungeon(10, 1630062353, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(55, 37));
TestCreateL3Dungeon(10, 1630062353, ENTRY_PREV);
EXPECT_EQ(ViewPosition, Point(19, 47));
}
TEST(Drlg_l3, CreateL3Dungeon_diablo_11_384626536)
{
TestCreateL3Dungeon(11, 384626536, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(29, 19));
TestCreateL3Dungeon(11, 384626536, ENTRY_PREV);
EXPECT_EQ(ViewPosition, Point(65, 65));
}
TEST(Drlg_l3, CreateL3Dungeon_diablo_12_2104541047)
{
TestCreateL3Dungeon(12, 2104541047, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(35, 23));
TestCreateL3Dungeon(12, 2104541047, ENTRY_PREV);
EXPECT_EQ(ViewPosition, Point(21, 83));
}
TEST(Drlg_l3, CreateL3Dungeon_hive_1_19770182)
{
TestCreateL3Dungeon(17, 19770182, ENTRY_TWARPUP);
EXPECT_EQ(ViewPosition, Point(75, 81));
TestCreateL3Dungeon(17, 19770182, ENTRY_PREV);
EXPECT_EQ(ViewPosition, Point(59, 41));
}
TEST(Drlg_l3, CreateL3Dungeon_hive_2_1522546307)
{
TestCreateL3Dungeon(18, 1522546307, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(47, 19));
TestCreateL3Dungeon(18, 1522546307, ENTRY_PREV);
EXPECT_EQ(ViewPosition, Point(33, 35));
}
TEST(Drlg_l3, CreateL3Dungeon_hive_3_125121312)
{
TestCreateL3Dungeon(19, 125121312, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(61, 25));
TestCreateL3Dungeon(19, 125121312, ENTRY_PREV);
EXPECT_EQ(ViewPosition, Point(21, 85));
}
TEST(Drlg_l3, CreateL3Dungeon_hive_4_1511478689)
{
TestCreateL3Dungeon(20, 1511478689, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(65, 41));
TestCreateL3Dungeon(20, 1511478689, ENTRY_PREV);
EXPECT_EQ(ViewPosition, Point(65, 41));
}
} // namespace

6
test/drlg_l4_test.cpp

@ -52,7 +52,7 @@ void TestCreateL4Dungeon(bool changed, int level, uint32_t seed, lvl_entry entry
}
}
TEST(Drlg_l1, CreateL4Dungeon_diablo_13_428074402)
TEST(Drlg_l4, CreateL4Dungeon_diablo_13_428074402)
{
TestCreateL4Dungeon(false, 13, 428074402, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(26, 64));
@ -60,7 +60,7 @@ TEST(Drlg_l1, CreateL4Dungeon_diablo_13_428074402)
EXPECT_EQ(ViewPosition, Point(47, 79));
}
TEST(Drlg_l1, CreateL4Dungeon_diablo_14_717625719)
TEST(Drlg_l4, CreateL4Dungeon_diablo_14_717625719)
{
TestCreateL4Dungeon(false, 14, 717625719, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(90, 64));
@ -68,7 +68,7 @@ TEST(Drlg_l1, CreateL4Dungeon_diablo_14_717625719)
EXPECT_EQ(ViewPosition, Point(49, 31));
}
TEST(Drlg_l1, CreateL4Dungeon_diablo_15_1583642716)
TEST(Drlg_l4, CreateL4Dungeon_diablo_15_1583642716)
{
Quests[Q_DIABLO]._qactive = QUEST_INIT;
TestCreateL4Dungeon(false, 15, 1583642716, ENTRY_MAIN);

BIN
test/fixtures/diablo/10-1630062353.dun vendored

Binary file not shown.

BIN
test/fixtures/diablo/11-384626536.dun vendored

Binary file not shown.

BIN
test/fixtures/diablo/12-2104541047.dun vendored

Binary file not shown.

BIN
test/fixtures/diablo/9-262005438.dun vendored

Binary file not shown.

BIN
test/fixtures/hellfire/17-19770182.dun vendored

Binary file not shown.

BIN
test/fixtures/hellfire/18-1522546307.dun vendored

Binary file not shown.

BIN
test/fixtures/hellfire/19-125121312.dun vendored

Binary file not shown.

BIN
test/fixtures/hellfire/20-1511478689.dun vendored

Binary file not shown.
Loading…
Cancel
Save