53 lines
1.2 KiB
C++
53 lines
1.2 KiB
C++
/*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include <catch2/catch_all.hpp>
|
|
|
|
#ifdef _WIN32
|
|
#include "Host/Windows/ExeAppendedZipLoaderWindows.hpp"
|
|
#else
|
|
#include "Host/Linux/ExeAppendedZipLoaderLinux.hpp"
|
|
#endif
|
|
|
|
#include "Base/Logger.hpp"
|
|
#include <Windows.h>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
|
|
using namespace OpenVulkano;
|
|
|
|
TEST_CASE("Load zip from exe")
|
|
{
|
|
Logger::SetupLogger("", "tests.log");
|
|
#ifdef _WIN32
|
|
ExeAppendedZipLoaderWindows loader;
|
|
#else
|
|
ExeAppendedZipLoaderLinux loader;
|
|
#endif
|
|
Array<char> zipData = loader.GetResource(loader.GetCurrentExecutablePath());
|
|
REQUIRE(!zipData.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++;
|
|
}
|
|
|
|
}
|