Crusader_Decomp/rebuild/remorse/tests/fixed_map_tests.cpp

37 lines
1.1 KiB
C++
Raw Normal View History

#include "remorse/file_system.h"
#include "remorse/fixed_map.h"
#include <cassert>
#include <filesystem>
int main()
{
const auto root = remorse::findGameDataRoot(std::filesystem::current_path());
assert(root.has_value());
const auto fixedPath = remorse::resolveGameDataPath(*root, std::filesystem::path("STATIC") / "FIXED.DAT");
assert(fixedPath.has_value());
const auto archive = remorse::loadFixedMapArchive(*fixedPath);
assert(archive.has_value());
assert(archive->mapCount > 0);
const auto firstMap = remorse::loadFixedMap(*archive, 0);
assert(firstMap.has_value());
assert(firstMap->index == 0);
bool foundNonEmptyMap = false;
for (remorse::u32 index = 0; index < archive->mapCount; ++index) {
const auto map = remorse::loadFixedMap(*archive, index);
assert(map.has_value());
if (!map->entries.empty()) {
foundNonEmptyMap = true;
break;
}
}
assert(foundNonEmptyMap);
const auto outOfRange = remorse::loadFixedMap(*archive, archive->mapCount);
assert(!outOfRange.has_value());
return 0;
}