test: add unit test for ImageIPakPostProcessor

This commit is contained in:
Jan
2025-01-07 23:48:17 +01:00
parent e0f8b3d3ca
commit 8c8ceae0bd
10 changed files with 378 additions and 12 deletions

View File

@ -394,6 +394,11 @@ void IPakToCreate::Build(ISearchPath& searchPath, IOutputPath& outPath)
std::cout << std::format("Created ipak {} with {} entries\n", m_name, m_image_names.size());
}
const std::vector<std::string>& IPakToCreate::GetImageNames() const
{
return m_image_names;
}
IPakCreator::IPakCreator()
: m_kvp_creator(nullptr)
{
@ -412,6 +417,7 @@ IPakToCreate* IPakCreator::GetOrAddIPak(const std::string& ipakName)
auto newIPak = std::make_unique<IPakToCreate>(ipakName);
auto* result = newIPak.get();
m_ipak_lookup.emplace(ipakName, result);
m_ipaks.emplace_back(std::move(newIPak));
assert(m_kvp_creator);

View File

@ -16,6 +16,7 @@ public:
void AddImage(std::string imageName);
void Build(ISearchPath& searchPath, IOutputPath& outPath);
[[nodiscard]] const std::vector<std::string>& GetImageNames() const;
private:
std::string m_name;

View File

@ -3,7 +3,6 @@
#include "IPak/IPakCreator.h"
#include <algorithm>
#include <ranges>
AbstractImageIPakPostProcessor::AbstractImageIPakPostProcessor(const ZoneDefinitionContext& zoneDefinition,
ISearchPath& searchPath,
@ -57,7 +56,7 @@ void AbstractImageIPakPostProcessor::PostProcessAsset(XAssetInfoGeneric& assetIn
while (m_current_ipak && m_zone_definition.m_asset_index_in_definition >= m_current_ipak_end_index)
FindNextObjContainer();
if (m_current_ipak && m_zone_definition.m_asset_index_in_definition <= m_current_ipak_start_index)
if (m_current_ipak && m_zone_definition.m_asset_index_in_definition >= m_current_ipak_start_index)
m_current_ipak->AddImage(assetInfo.m_name);
}

View File

@ -87,6 +87,7 @@ IwdToCreate* IwdCreator::GetOrAddIwd(const std::string& iwdName)
auto newIwd = std::make_unique<IwdToCreate>(iwdName);
auto* result = newIwd.get();
m_iwd_lookup.emplace(iwdName, result);
m_iwds.emplace_back(std::move(newIwd));
return result;