code review refactoring

This commit is contained in:
ohyzha
2024-12-21 17:11:29 +02:00
parent 9d6756bbad
commit d3750f2b8a
10 changed files with 88 additions and 117 deletions

View File

@@ -12,7 +12,7 @@ if (NOT ENABLE_CURL)
endif()
if (APPLE)
list(FILTER SOURCES EXCLUDE REGEX "ExeAppendedZipLoader")
list(FILTER SOURCES EXCLUDE REGEX "ExeAppendedZipResourceLoader")
endif()
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${SOURCES})
@@ -21,7 +21,7 @@ list(APPEND SOURCES ${RESOURCES})
add_executable(OpenVulkano_Tests ${SOURCES})
# append zip file at the end of executable file
if (WIN32 OR (LINUX AND NOT APPLE))
if (WIN32 OR LINUX)
set(ZIP_FILE ${ROOT_FOLDER}/resources/arch.zip)
add_custom_command(TARGET OpenVulkano_Tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E cat ${ZIP_FILE} >> $<TARGET_FILE:OpenVulkano_Tests>)
endif()

View File

@@ -7,9 +7,9 @@
#include <catch2/catch_all.hpp>
#ifdef _WIN32
#include "Host/Windows/ExeAppendedZipLoaderWindows.hpp"
#include "Host/Windows/ExeAppendedZipResourceLoaderWindows.hpp"
#else
#include "Host/Linux/ExeAppendedZipLoaderLinux.hpp"
#include "Host/Linux/ExeAppendedZipResourceLoaderLinux.hpp"
#endif
#include "Base/Logger.hpp"
@@ -23,30 +23,16 @@ TEST_CASE("Load zip from exe")
{
Logger::SetupLogger("", "tests.log");
#ifdef _WIN32
ExeAppendedZipLoaderWindows loader;
ExeAppendedZipResourceLoaderWindows loader;
#else
ExeAppendedZipLoaderLinux loader;
ExeAppendedZipResourceLoaderLinux loader;
#endif
Array<char> zipData = loader.GetResource(loader.GetCurrentExecutablePath());
REQUIRE(!zipData.Empty());
auto iconData = loader.GetResource("madvoxel_icon.ico");
REQUIRE(!iconData.Empty());
auto files = loader.GetZipArchiveFiles(loader.GetCurrentExecutablePath());
REQUIRE(files.size() == 2);
int i = 0;
for (const auto& [fileDesc, fileData] : files)
{
if (i == 0)
{
REQUIRE(fileDesc.path == "madvoxel_icon.ico");
}
else if (i == 1)
{
REQUIRE(fileDesc.path == "text.txt");
std::string s(fileData.Data(), fileData.Size());
REQUIRE(s == "Hello world!");
}
i++;
}
auto txtFile = loader.GetResource("text.txt");
REQUIRE(!txtFile.Empty());
std::string s(txtFile.Data(), txtFile.Size());
REQUIRE(s == "Hello world!");
}