2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-12-27 20:41:49 +00:00
Files
OpenAssetTools/test/SystemTests/Game/T5/SimpleZoneT5.cpp
2025-12-23 16:47:42 +01:00

66 lines
2.1 KiB
C++

#include "Game/T5/GameAssetPoolT5.h"
#include "Linker.h"
#include "OatTestPaths.h"
#include "SystemTestsPaths.h"
#include "ZoneLoading.h"
#include <catch2/catch_test_macros.hpp>
#include <filesystem>
#include <format>
#include <memory>
#include <string>
namespace fs = std::filesystem;
using namespace std::literals;
namespace
{
TEST_CASE("Simple Zone(T5)", "[t5][system][simple]")
{
const auto assetSearchPath = (oat::paths::GetSystemTestsDirectory() / "Game/T5/simple").string();
const auto sourceSearchPath = (oat::paths::GetSystemTestsDirectory() / "Game/T5/simple").string();
const auto outputPath = oat::paths::GetTempDirectory("t5_simple").string();
const char* argStrings[]{
"SystemTests", // bin
"--verbose",
"--asset-search-path",
assetSearchPath.c_str(),
"--source-search-path",
sourceSearchPath.c_str(),
"--output-folder",
outputPath.c_str(),
"SimpleZoneT5",
};
LinkerArgs args;
bool shouldContinue = true;
const auto couldParseArgs = args.ParseArgs(std::extent_v<decltype(argStrings)>, argStrings, shouldContinue);
REQUIRE(couldParseArgs);
REQUIRE(shouldContinue);
const auto linker = Linker::Create(std::move(args));
const auto linkerResult = linker->Start();
REQUIRE(linkerResult);
// x64 for now produces invalid zones, don't try to load them yet
#ifdef ARCH_x86
const auto expectedZonePath = (fs::path(outputPath) / "SimpleZoneT5.ff").string();
auto maybeZone = ZoneLoading::LoadZone(expectedZonePath, std::nullopt);
REQUIRE(maybeZone);
auto zone = std::move(*maybeZone);
auto pools = dynamic_cast<GameAssetPoolT5*>(zone->m_pools.get());
REQUIRE(zone->m_game_id == GameId::T5);
REQUIRE(zone->m_platform == GamePlatform::PC);
REQUIRE(zone->m_name == "SimpleZoneT5");
REQUIRE(pools->GetTotalAssetCount() == 1);
REQUIRE(pools->m_raw_file->GetAsset("SimpleZone.txt"));
#endif
}
} // namespace