Files
OpenAssetTools/test/SystemTests/Game/IW4/SimpleZoneIW4.cpp
T

72 lines
2.3 KiB
C++

#include "Game/IW4/IW4.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
{
void PerformTest(const std::string& zoneFileName, GameVariantId expectedGameVariantId)
{
const auto assetSearchPath = (oat::paths::GetSystemTestsDirectory() / "Game/IW4/Simple").string();
const auto sourceSearchPath = (oat::paths::GetSystemTestsDirectory() / "Game/IW4/Simple").string();
const auto outputPath = oat::paths::GetTempDirectory("SimpleZoneIW4").string();
const char* argStrings[]{
"SystemTests", // bin
"--verbose",
"--asset-search-path",
assetSearchPath.c_str(),
"--source-search-path",
sourceSearchPath.c_str(),
"--output-folder",
outputPath.c_str(),
zoneFileName.c_str(),
};
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);
const auto expectedZonePath = (fs::path(outputPath) / "SimpleZoneIW4.ff").string();
auto maybeZone = ZoneLoading::LoadZone(expectedZonePath, std::nullopt);
REQUIRE(maybeZone);
auto zone = std::move(*maybeZone);
REQUIRE(zone->m_game_id == GameId::IW4);
REQUIRE(zone->m_variant_id == expectedGameVariantId);
REQUIRE(zone->m_name == "SimpleZoneIW4");
REQUIRE(zone->m_pools.GetTotalAssetCount() == 1);
REQUIRE(zone->m_pools.GetAsset<IW4::AssetRawFile>("SimpleZone.txt"));
}
TEST_CASE("Simple Zone(IW4|pc32)", "[iw4][pc32][system][simple]")
{
PerformTest("SimpleZoneIW4_32", GameVariantId::IW4_PC32);
}
TEST_CASE("Simple Zone(IW4|pc64)", "[iw4][pc64][system][simple]")
{
PerformTest("SimpleZoneIW4_64", GameVariantId::IW4_PC64);
}
} // namespace