mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 23:08:05 -05:00
test: add unit test for ImageIPakPostProcessor
This commit is contained in:
@ -5,13 +5,13 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
OutputPathFilesystem::OutputPathFilesystem(const fs::path& path)
|
||||
: m_path(fs::canonical(path))
|
||||
: m_path(fs::weakly_canonical(path))
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<std::ostream> OutputPathFilesystem::Open(const std::string& fileName)
|
||||
{
|
||||
const auto fullNewPath = fs::canonical(m_path / fileName);
|
||||
const auto fullNewPath = fs::weakly_canonical(m_path / fileName);
|
||||
|
||||
if (!fullNewPath.string().starts_with(m_path.string()))
|
||||
return nullptr;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -1,10 +1,15 @@
|
||||
#include "ZoneDefinition.h"
|
||||
|
||||
ZoneDefinitionObjContainer::ZoneDefinitionObjContainer(std::string name, const ZoneDefinitionObjContainerType type, const unsigned start)
|
||||
: ZoneDefinitionObjContainer(std::move(name), type, start, 0u)
|
||||
{
|
||||
}
|
||||
|
||||
ZoneDefinitionObjContainer::ZoneDefinitionObjContainer(std::string name, const ZoneDefinitionObjContainerType type, const unsigned start, const unsigned end)
|
||||
: m_name(std::move(name)),
|
||||
m_type(type),
|
||||
m_asset_start(start),
|
||||
m_asset_end(0u)
|
||||
m_asset_end(end)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
unsigned m_asset_end;
|
||||
|
||||
ZoneDefinitionObjContainer(std::string name, ZoneDefinitionObjContainerType type, unsigned start);
|
||||
ZoneDefinitionObjContainer(std::string name, ZoneDefinitionObjContainerType type, unsigned start, unsigned end);
|
||||
};
|
||||
|
||||
class ZoneDefinitionAsset
|
||||
|
Reference in New Issue
Block a user