Summary:
- Removed ReadEntireFile - ZipWriter now writes directly to a file when possible - Added GetIndex to geometry - Moved Usd and Obj generators to different files - Removed unused procedures - Deduplicated obj generators - Updated tests for ZipWriter
This commit is contained in:
@@ -10,25 +10,31 @@
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
#include "Base/Utils.hpp"
|
||||
#include "IO/Archive/ZipWriter.hpp"
|
||||
#include "IO/AppFolders.hpp"
|
||||
|
||||
using namespace OpenVulkano;
|
||||
|
||||
TEST_CASE("Empty zip file", "[ZipWriter]")
|
||||
{
|
||||
ZipWriter writer;
|
||||
auto mem = writer.GetMemory();
|
||||
|
||||
const auto emptyZipPath = AppFolders::GetAppTempDir() / "empty.zip";
|
||||
ZipWriter writer(emptyZipPath);
|
||||
writer.Close();
|
||||
auto mem = Utils::ReadFile(emptyZipPath);
|
||||
const int expectSize = 22;
|
||||
std::vector<uint8_t> expect = {0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
Array<uint8_t> expect = {0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
CHECK(mem.size() == expectSize);
|
||||
CHECK(mem.Size() == expectSize);
|
||||
CHECK(mem == expect);
|
||||
|
||||
std::filesystem::remove(emptyZipPath);
|
||||
}
|
||||
|
||||
TEST_CASE("Zip with one file(AAA.txt that has 'AAA')", "[ZipWriter]")
|
||||
{
|
||||
ZipWriter writer;
|
||||
const auto oneFileZipPath = AppFolders::GetAppTempDir() / "one_file.zip";
|
||||
ZipWriter writer(oneFileZipPath);
|
||||
|
||||
FileDescription desc = FileDescription::MakeDescriptionForFile("AAA.txt", 3);
|
||||
desc.modTime = {};
|
||||
@@ -36,11 +42,12 @@ TEST_CASE("Zip with one file(AAA.txt that has 'AAA')", "[ZipWriter]")
|
||||
char buffer[] = {'A', 'A', 'A'};
|
||||
|
||||
writer.AddFile(desc, buffer);
|
||||
writer.Close();
|
||||
|
||||
auto mem = writer.GetMemory();
|
||||
auto mem = Utils::ReadFile(oneFileZipPath);
|
||||
|
||||
const int expectSize = 151;
|
||||
std::vector<uint8_t> expect =
|
||||
Array<uint8_t> expect =
|
||||
{
|
||||
0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xec, 0xa7, 0x31, 0xa0, 0x66, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00,
|
||||
0x00, 0x00, 0x41, 0x41, 0x41, 0x2e, 0x74, 0x78, 0x74, 0x41, 0x41, 0x41, 0x50, 0x4b, 0x01, 0x02, 0x1f, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xec,
|
||||
@@ -50,14 +57,17 @@ TEST_CASE("Zip with one file(AAA.txt that has 'AAA')", "[ZipWriter]")
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
CHECK(mem.size() == expectSize);
|
||||
CHECK(mem.Size() == expectSize);
|
||||
CHECK(mem == expect);
|
||||
|
||||
std::filesystem::remove(oneFileZipPath);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Zip with two files(AAA.txt that has 'AAA', BBB.bin that has 'BBB')", "[ZipWriter]")
|
||||
{
|
||||
ZipWriter writer;
|
||||
const auto twoFilesZipPath = AppFolders::GetAppTempDir() / "two_files.zip";
|
||||
ZipWriter writer(twoFilesZipPath);
|
||||
|
||||
FileDescription aaa = FileDescription::MakeDescriptionForFile("AAA.txt", 3);
|
||||
aaa.modTime = {};
|
||||
@@ -71,11 +81,12 @@ TEST_CASE("Zip with two files(AAA.txt that has 'AAA', BBB.bin that has 'BBB')",
|
||||
|
||||
writer.AddFile(aaa, aaaBuffer);
|
||||
writer.AddFile(bbb, bbbBuffer);
|
||||
writer.Close();
|
||||
|
||||
auto mem = writer.GetMemory();
|
||||
auto mem = Utils::ReadFile(twoFilesZipPath);
|
||||
|
||||
const int expectSize = 280;
|
||||
std::vector<uint8_t> expect =
|
||||
Array<uint8_t> expect =
|
||||
{
|
||||
0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xec, 0xa7, 0x31, 0xa0, 0x66, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00,
|
||||
0x00, 0x00, 0x41, 0x41, 0x41, 0x2e, 0x74, 0x78, 0x74, 0x41, 0x41, 0x41, 0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xec, 0x87, 0x8d,
|
||||
@@ -89,8 +100,10 @@ TEST_CASE("Zip with two files(AAA.txt that has 'AAA', BBB.bin that has 'BBB')",
|
||||
0x3e, 0xd5, 0xde, 0xb1, 0x9d, 0x01, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
CHECK(mem.size() == expectSize);
|
||||
CHECK(mem.Size() == expectSize);
|
||||
CHECK(mem == expect);
|
||||
|
||||
std::filesystem::remove(twoFilesZipPath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user