Merge "Write files in a temporary directory"
This commit is contained in:
commit
22ecce0658
1 changed files with 12 additions and 5 deletions
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "ZipAlign.h"
|
#include "ZipAlign.h"
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -16,9 +17,15 @@ static std::string GetTestPath(const std::string& filename) {
|
||||||
return test_data_dir + filename;
|
return test_data_dir + filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string GetTempPath(const std::string& filename) {
|
||||||
|
std::filesystem::path temp_path = std::filesystem::path(testing::TempDir());
|
||||||
|
temp_path += filename;
|
||||||
|
return temp_path.string();
|
||||||
|
}
|
||||||
|
|
||||||
TEST(Align, Unaligned) {
|
TEST(Align, Unaligned) {
|
||||||
const std::string src = GetTestPath("unaligned.zip");
|
const std::string src = GetTestPath("unaligned.zip");
|
||||||
const std::string dst = GetTestPath("unaligned_out.zip");
|
const std::string dst = GetTempPath("unaligned_out.zip");
|
||||||
|
|
||||||
int processed = process(src.c_str(), dst.c_str(), 4, true, false, 4096);
|
int processed = process(src.c_str(), dst.c_str(), 4, true, false, 4096);
|
||||||
ASSERT_EQ(0, processed);
|
ASSERT_EQ(0, processed);
|
||||||
|
@ -29,8 +36,8 @@ TEST(Align, Unaligned) {
|
||||||
|
|
||||||
TEST(Align, DoubleAligment) {
|
TEST(Align, DoubleAligment) {
|
||||||
const std::string src = GetTestPath("unaligned.zip");
|
const std::string src = GetTestPath("unaligned.zip");
|
||||||
const std::string tmp = GetTestPath("da_aligned.zip");
|
const std::string tmp = GetTempPath("da_aligned.zip");
|
||||||
const std::string dst = GetTestPath("da_d_aligner.zip");
|
const std::string dst = GetTempPath("da_d_aligner.zip");
|
||||||
|
|
||||||
int processed = process(src.c_str(), tmp.c_str(), 4, true, false, 4096);
|
int processed = process(src.c_str(), tmp.c_str(), 4, true, false, 4096);
|
||||||
ASSERT_EQ(0, processed);
|
ASSERT_EQ(0, processed);
|
||||||
|
@ -60,7 +67,7 @@ TEST(Align, DoubleAligment) {
|
||||||
// Directory.
|
// Directory.
|
||||||
TEST(Align, Holes) {
|
TEST(Align, Holes) {
|
||||||
const std::string src = GetTestPath("holes.zip");
|
const std::string src = GetTestPath("holes.zip");
|
||||||
const std::string dst = GetTestPath("holes_out.zip");
|
const std::string dst = GetTempPath("holes_out.zip");
|
||||||
|
|
||||||
int processed = process(src.c_str(), dst.c_str(), 4, true, false, 4096);
|
int processed = process(src.c_str(), dst.c_str(), 4, true, false, 4096);
|
||||||
ASSERT_EQ(0, processed);
|
ASSERT_EQ(0, processed);
|
||||||
|
@ -72,7 +79,7 @@ TEST(Align, Holes) {
|
||||||
// Align a zip where LFH order and CD entries differ.
|
// Align a zip where LFH order and CD entries differ.
|
||||||
TEST(Align, DifferenteOrders) {
|
TEST(Align, DifferenteOrders) {
|
||||||
const std::string src = GetTestPath("diffOrders.zip");
|
const std::string src = GetTestPath("diffOrders.zip");
|
||||||
const std::string dst = GetTestPath("diffOrders_out.zip");
|
const std::string dst = GetTempPath("diffOrders_out.zip");
|
||||||
|
|
||||||
int processed = process(src.c_str(), dst.c_str(), 4, true, false, 4096);
|
int processed = process(src.c_str(), dst.c_str(), 4, true, false, 4096);
|
||||||
ASSERT_EQ(0, processed);
|
ASSERT_EQ(0, processed);
|
||||||
|
|
Loading…
Reference in a new issue