test(overworld): align integration expectations

This commit is contained in:
scawful
2025-12-22 14:56:31 -05:00
parent 326594f3e6
commit 1d297d5228
3 changed files with 20 additions and 16 deletions

View File

@@ -1,11 +1,11 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <filesystem>
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
#include "rom/rom.h" #include "rom/rom.h"
#include "test/test_utils.h"
#include "testing.h" #include "testing.h"
#include "zelda3/overworld/overworld.h" #include "zelda3/overworld/overworld.h"
#include "zelda3/overworld/overworld_map.h" #include "zelda3/overworld/overworld_map.h"
@@ -32,17 +32,16 @@ class OverworldIntegrationTest : public ::testing::Test {
#endif #endif
// Check if we should use real ROM or mock data // Check if we should use real ROM or mock data
const char* rom_path_env = getenv("YAZE_TEST_ROM_PATH"); if (std::getenv("YAZE_SKIP_ROM_TESTS")) {
const char* skip_rom_tests = getenv("YAZE_SKIP_ROM_TESTS");
if (skip_rom_tests) {
GTEST_SKIP() << "ROM tests disabled"; GTEST_SKIP() << "ROM tests disabled";
} }
if (rom_path_env && std::filesystem::exists(rom_path_env)) { const std::string rom_path =
yaze::test::TestRomManager::GetRomPath(yaze::test::RomRole::kVanilla);
if (!rom_path.empty()) {
// Use real ROM for testing // Use real ROM for testing
rom_ = std::make_unique<Rom>(); rom_ = std::make_unique<Rom>();
auto status = rom_->LoadFromFile(rom_path_env); auto status = rom_->LoadFromFile(rom_path);
if (status.ok()) { if (status.ok()) {
use_real_rom_ = true; use_real_rom_ = true;
overworld_ = std::make_unique<Overworld>(rom_.get()); overworld_ = std::make_unique<Overworld>(rom_.get());
@@ -181,7 +180,7 @@ TEST_F(OverworldIntegrationTest, DISABLED_EntranceCoordinateCalculation) {
// Test exit loading matches ZScream data structure // Test exit loading matches ZScream data structure
TEST_F(OverworldIntegrationTest, ExitDataLoading) { TEST_F(OverworldIntegrationTest, ExitDataLoading) {
auto status = overworld_->Load(rom_.get()); auto status = overworld_->Load(rom_.get());
ASSERT_TRUE(status.ok()); ASSERT_TRUE(status.ok()) << status.ToString();
const auto& exits = overworld_->exits(); const auto& exits = overworld_->exits();
EXPECT_EQ(exits->size(), 0x4F); EXPECT_EQ(exits->size(), 0x4F);
@@ -298,8 +297,9 @@ TEST_F(OverworldIntegrationTest, RomDependentTestSuiteCompatibility) {
// Test that sprite data is accessible (matches RomDependentTestSuite // Test that sprite data is accessible (matches RomDependentTestSuite
// expectations) // expectations)
const auto& sprites = overworld_->sprites(0); const auto all_sprites = overworld_->all_sprites();
EXPECT_EQ(sprites.size(), 3); // Three game states EXPECT_EQ(all_sprites.size(), 3); // Three game states
EXPECT_GT(all_sprites[0].size(), 0);
// Test that item data is accessible // Test that item data is accessible
const auto& items = overworld_->all_items(); const auto& items = overworld_->all_items();
@@ -420,4 +420,4 @@ TEST_F(OverworldIntegrationTest, ZScreamCoordinateCompatibility) {
} }
} // namespace zelda3 } // namespace zelda3
} // namespace yaze } // namespace yaze

View File

@@ -39,6 +39,10 @@ class OverworldRegressionTest : public ::testing::Test {
for (int i = 0; i < 160; i++) { for (int i = 0; i < 160; i++) {
mock_rom_data[0x1788D + i] = 0x01; mock_rom_data[0x1788D + i] = 0x01;
} }
// Parent table - identity for LW so DW mirrors correctly (+0x40)
for (int i = 0; i < 64; i++) {
mock_rom_data[0x125EC + i] = static_cast<uint8_t>(i);
}
// Sprite sets/palettes // Sprite sets/palettes
for (int i = 0; i < 160; i++) { for (int i = 0; i < 160; i++) {
mock_rom_data[0x7A41 + i] = 0x00; mock_rom_data[0x7A41 + i] = 0x00;

View File

@@ -249,12 +249,12 @@ TEST_F(OverworldTest, OverworldMapDestroy) {
map.set_main_palette(5); map.set_main_palette(5);
map.SetAreaSize(AreaSizeEnum::LargeArea); map.SetAreaSize(AreaSizeEnum::LargeArea);
// Destroy and verify reset // Destroy and verify identity fields are preserved for rebuild
map.Destroy(); map.Destroy();
EXPECT_EQ(map.area_graphics(), 0); EXPECT_EQ(map.area_graphics(), 10);
EXPECT_EQ(map.main_palette(), 0); EXPECT_EQ(map.main_palette(), 5);
EXPECT_EQ(map.area_size(), AreaSizeEnum::SmallArea); EXPECT_EQ(map.area_size(), AreaSizeEnum::LargeArea);
EXPECT_FALSE(map.is_initialized()); EXPECT_FALSE(map.is_initialized());
} }
@@ -296,4 +296,4 @@ TEST_F(OverworldTest, WorldBasedSpriteFiltering) {
} }
} // namespace zelda3 } // namespace zelda3
} // namespace yaze } // namespace yaze