mirror of
https://github.com/usatiuk/backup.git
synced 2025-10-26 17:37:47 +01:00
clang format 120 length
This commit is contained in:
@@ -7,7 +7,12 @@
|
||||
|
||||
// Demonstrate some basic assertions.
|
||||
TEST(BuzhashTest, SimpleTest) {
|
||||
std::string loremipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
|
||||
std::string loremipsum =
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et "
|
||||
"dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip "
|
||||
"ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu "
|
||||
"fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
|
||||
"mollit anim id est laborum.";
|
||||
|
||||
for (int i = 15; i < 49; i++) {
|
||||
Buzhash b(i);
|
||||
|
||||
@@ -12,7 +12,7 @@ TEST(CryptoTests, AES) {
|
||||
auto enc = AES::encrypt(std::vector<char>(in.begin(), in.end()), "p1", "e");
|
||||
auto dec = AES::decrypt(enc, "p1", "e");
|
||||
EXPECT_EQ(in, std::string(dec.begin(), dec.end()));
|
||||
|
||||
|
||||
in = "";
|
||||
enc = AES::encrypt(std::vector<char>(in.begin(), in.end()), "p1", "e");
|
||||
dec = AES::decrypt(enc, "p1", "e");
|
||||
@@ -41,12 +41,12 @@ TEST(CryptoTests, AES) {
|
||||
|
||||
TEST(CryptoTests, SHA) {
|
||||
std::vector<char> data{'h', 'e', 'l', 'l', 'o'};
|
||||
std::array<unsigned char, 32> excepted{0x2c, 0xf2, 0x4d, 0xba, 0x5f, 0xb0, 0xa3, 0x0e, 0x26, 0xe8, 0x3b, 0x2a, 0xc5, 0xb9, 0xe2, 0x9e, 0x1b, 0x16, 0x1e, 0x5c, 0x1f, 0xa7, 0x42, 0x5e, 0x73, 0x04, 0x33, 0x62, 0x93, 0x8b, 0x98, 0x24};
|
||||
std::array<unsigned char, 32> excepted{0x2c, 0xf2, 0x4d, 0xba, 0x5f, 0xb0, 0xa3, 0x0e, 0x26, 0xe8, 0x3b,
|
||||
0x2a, 0xc5, 0xb9, 0xe2, 0x9e, 0x1b, 0x16, 0x1e, 0x5c, 0x1f, 0xa7,
|
||||
0x42, 0x5e, 0x73, 0x04, 0x33, 0x62, 0x93, 0x8b, 0x98, 0x24};
|
||||
|
||||
auto out = SHA::calculate(data);
|
||||
|
||||
EXPECT_EQ(out.size(), 32);
|
||||
for (int i = 0; i < out.size(); i++) {
|
||||
EXPECT_EQ(static_cast<uint8_t>(out[i]), excepted[i]);
|
||||
}
|
||||
for (int i = 0; i < out.size(); i++) { EXPECT_EQ(static_cast<uint8_t>(out[i]), excepted[i]); }
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ TEST(FullTest, Simple) {
|
||||
{
|
||||
std::filesystem::create_directories("Simple/testfrom");
|
||||
for (int i = 0; i < 257; i++) {
|
||||
std::ofstream o(std::filesystem::path("Simple/testfrom") / ("f" + std::to_string(i)), std::ios::binary | std::ios::out | std::ios::trunc);
|
||||
std::ofstream o(std::filesystem::path("Simple/testfrom") / ("f" + std::to_string(i)),
|
||||
std::ios::binary | std::ios::out | std::ios::trunc);
|
||||
for (int j = 0; j < i; j++) o.put(static_cast<char>(j % 256));
|
||||
}
|
||||
std::filesystem::create_directories("Simple/testfrom/testdir");
|
||||
@@ -67,7 +68,8 @@ TEST(FullTest, Simple) {
|
||||
}
|
||||
|
||||
for (int i = 0; i < 257; i++) {
|
||||
std::ifstream o(std::filesystem::path("Simple/testtores") / ("f" + std::to_string(i)), std::ios::binary | std::ios::in);
|
||||
std::ifstream o(std::filesystem::path("Simple/testtores") / ("f" + std::to_string(i)),
|
||||
std::ios::binary | std::ios::in);
|
||||
try {
|
||||
EXPECT_EQ(o.is_open(), true);
|
||||
for (int j = 0; j < i; j++) {
|
||||
@@ -89,7 +91,8 @@ TEST(FullTest, SimpleWithIgnore) {
|
||||
{
|
||||
std::filesystem::create_directories("SimpleWithIgnore/testfrom");
|
||||
for (int i = 0; i < 257; i++) {
|
||||
std::ofstream o(std::filesystem::path("SimpleWithIgnore/testfrom") / ("f" + std::to_string(i)), std::ios::binary | std::ios::out | std::ios::trunc);
|
||||
std::ofstream o(std::filesystem::path("SimpleWithIgnore/testfrom") / ("f" + std::to_string(i)),
|
||||
std::ios::binary | std::ios::out | std::ios::trunc);
|
||||
for (int j = 0; j < i; j++) o.put(static_cast<char>(j % 256));
|
||||
}
|
||||
std::filesystem::create_directories("SimpleWithIgnore/testfrom/testdir");
|
||||
@@ -134,7 +137,9 @@ TEST(FullTest, SimpleWithIgnore) {
|
||||
}
|
||||
{
|
||||
Config conf;
|
||||
conf.add("repo", "SimpleWithIgnore/testto").add("aid", std::to_string(aid)).add("to", "SimpleWithIgnore/testtores");
|
||||
conf.add("repo", "SimpleWithIgnore/testto")
|
||||
.add("aid", std::to_string(aid))
|
||||
.add("to", "SimpleWithIgnore/testtores");
|
||||
|
||||
auto repo = std::make_unique<FileRepository>(conf);
|
||||
repo->open();
|
||||
@@ -148,7 +153,8 @@ TEST(FullTest, SimpleWithIgnore) {
|
||||
EXPECT_EQ(std::filesystem::is_directory("SimpleWithIgnore/testtores/testdir"), true);
|
||||
|
||||
for (int i = 0; i < 257; i++) {
|
||||
std::ifstream o(std::filesystem::path("SimpleWithIgnore/testtores") / ("f" + std::to_string(i)), std::ios::binary | std::ios::in);
|
||||
std::ifstream o(std::filesystem::path("SimpleWithIgnore/testtores") / ("f" + std::to_string(i)),
|
||||
std::ios::binary | std::ios::in);
|
||||
EXPECT_EQ(o.is_open(), true);
|
||||
for (int j = 0; j < i; j++) {
|
||||
char c;
|
||||
@@ -196,13 +202,16 @@ TEST(FullTest, SimpleWithCompress) {
|
||||
{
|
||||
std::filesystem::create_directories("SimpleWithCompress/testfrom");
|
||||
for (int i = 0; i < 257; i++) {
|
||||
std::ofstream o(std::filesystem::path("SimpleWithCompress/testfrom") / ("f" + std::to_string(i)), std::ios::binary | std::ios::out | std::ios::trunc);
|
||||
std::ofstream o(std::filesystem::path("SimpleWithCompress/testfrom") / ("f" + std::to_string(i)),
|
||||
std::ios::binary | std::ios::out | std::ios::trunc);
|
||||
for (int j = 0; j < i; j++) o.put(static_cast<char>(j % 256));
|
||||
}
|
||||
std::filesystem::create_directories("SimpleWithCompress/testfrom/testdir");
|
||||
|
||||
Config conf;
|
||||
conf.add("repo", "SimpleWithCompress/testto").add("compression", "zlib").add("from", "SimpleWithCompress/testfrom");
|
||||
conf.add("repo", "SimpleWithCompress/testto")
|
||||
.add("compression", "zlib")
|
||||
.add("from", "SimpleWithCompress/testfrom");
|
||||
|
||||
auto repo = std::make_unique<FileRepository>(conf);
|
||||
repo->init();
|
||||
@@ -215,7 +224,9 @@ TEST(FullTest, SimpleWithCompress) {
|
||||
}
|
||||
{
|
||||
Config conf;
|
||||
conf.add("repo", "SimpleWithCompress/testto").add("aid", std::to_string(aid)).add("to", "SimpleWithCompress/testtores");
|
||||
conf.add("repo", "SimpleWithCompress/testto")
|
||||
.add("aid", std::to_string(aid))
|
||||
.add("to", "SimpleWithCompress/testtores");
|
||||
|
||||
auto repo = std::make_unique<FileRepository>(conf);
|
||||
repo->open();
|
||||
@@ -229,7 +240,8 @@ TEST(FullTest, SimpleWithCompress) {
|
||||
EXPECT_EQ(std::filesystem::is_directory("SimpleWithCompress/testtores/testdir"), true);
|
||||
|
||||
for (int i = 0; i < 257; i++) {
|
||||
std::ifstream o(std::filesystem::path("SimpleWithCompress/testtores") / ("f" + std::to_string(i)), std::ios::binary | std::ios::in);
|
||||
std::ifstream o(std::filesystem::path("SimpleWithCompress/testtores") / ("f" + std::to_string(i)),
|
||||
std::ios::binary | std::ios::in);
|
||||
EXPECT_EQ(o.is_open(), true);
|
||||
for (int j = 0; j < i; j++) {
|
||||
char c;
|
||||
@@ -246,13 +258,19 @@ TEST(FullTest, SimpleWithCompEnd) {
|
||||
{
|
||||
std::filesystem::create_directories("SimpleWithCompEnd/testfrom");
|
||||
for (int i = 0; i < 257; i++) {
|
||||
std::ofstream o(std::filesystem::path("SimpleWithCompEnd/testfrom") / ("f" + std::to_string(i)), std::ios::binary | std::ios::out | std::ios::trunc);
|
||||
std::ofstream o(std::filesystem::path("SimpleWithCompEnd/testfrom") / ("f" + std::to_string(i)),
|
||||
std::ios::binary | std::ios::out | std::ios::trunc);
|
||||
for (int j = 0; j < i; j++) o.put(static_cast<char>(j % 256));
|
||||
}
|
||||
std::filesystem::create_directories("SimpleWithCompEnd/testfrom/testdir");
|
||||
|
||||
Config conf;
|
||||
conf.add("repo", "SimpleWithCompEnd/testto").add("compression", "zlib").add("from", "SimpleWithCompEnd/testfrom").add("encryption", "aes").add("password", "testp").add("salt", "tests");
|
||||
conf.add("repo", "SimpleWithCompEnd/testto")
|
||||
.add("compression", "zlib")
|
||||
.add("from", "SimpleWithCompEnd/testfrom")
|
||||
.add("encryption", "aes")
|
||||
.add("password", "testp")
|
||||
.add("salt", "tests");
|
||||
|
||||
auto repo = std::make_unique<FileRepository>(conf);
|
||||
repo->init();
|
||||
@@ -279,7 +297,10 @@ TEST(FullTest, SimpleWithCompEnd) {
|
||||
}
|
||||
{
|
||||
Config conf;
|
||||
conf.add("repo", "SimpleWithCompEnd/testto").add("password", "testp").add("aid", std::to_string(aid)).add("to", "SimpleWithCompEnd/testtores");
|
||||
conf.add("repo", "SimpleWithCompEnd/testto")
|
||||
.add("password", "testp")
|
||||
.add("aid", std::to_string(aid))
|
||||
.add("to", "SimpleWithCompEnd/testtores");
|
||||
|
||||
auto repo = std::make_unique<FileRepository>(conf);
|
||||
repo->open();
|
||||
@@ -294,7 +315,8 @@ TEST(FullTest, SimpleWithCompEnd) {
|
||||
EXPECT_EQ(std::filesystem::is_directory("SimpleWithCompEnd/testtores/testdir"), true);
|
||||
|
||||
for (int i = 0; i < 257; i++) {
|
||||
std::ifstream o(std::filesystem::path("SimpleWithCompEnd/testtores") / ("f" + std::to_string(i)), std::ios::binary | std::ios::in);
|
||||
std::ifstream o(std::filesystem::path("SimpleWithCompEnd/testtores") / ("f" + std::to_string(i)),
|
||||
std::ios::binary | std::ios::in);
|
||||
EXPECT_EQ(o.is_open(), true);
|
||||
for (int j = 0; j < i; j++) {
|
||||
char c;
|
||||
@@ -310,16 +332,40 @@ TEST(FullTest, Fuzz) {
|
||||
srand(time(nullptr));
|
||||
std::vector<Config> confs;
|
||||
Config conf;
|
||||
conf.add("repo", "Fuzz/testto").add("compression", "none").add("from", "Fuzz/testfrom").add("encryption", "none").add("password", "testp").add("salt", "tests").add("progress", "none");
|
||||
conf.add("repo", "Fuzz/testto")
|
||||
.add("compression", "none")
|
||||
.add("from", "Fuzz/testfrom")
|
||||
.add("encryption", "none")
|
||||
.add("password", "testp")
|
||||
.add("salt", "tests")
|
||||
.add("progress", "none");
|
||||
confs.emplace_back(conf);
|
||||
conf = Config();
|
||||
conf.add("repo", "Fuzz/testto").add("compression", "zlib").add("from", "Fuzz/testfrom").add("encryption", "none").add("password", "testp").add("salt", "tests").add("progress", "none");
|
||||
conf.add("repo", "Fuzz/testto")
|
||||
.add("compression", "zlib")
|
||||
.add("from", "Fuzz/testfrom")
|
||||
.add("encryption", "none")
|
||||
.add("password", "testp")
|
||||
.add("salt", "tests")
|
||||
.add("progress", "none");
|
||||
confs.emplace_back(conf);
|
||||
conf = Config();
|
||||
conf.add("repo", "Fuzz/testto").add("compression", "none").add("from", "Fuzz/testfrom").add("encryption", "zlib").add("password", "testp").add("salt", "tests").add("progress", "none");
|
||||
conf.add("repo", "Fuzz/testto")
|
||||
.add("compression", "none")
|
||||
.add("from", "Fuzz/testfrom")
|
||||
.add("encryption", "zlib")
|
||||
.add("password", "testp")
|
||||
.add("salt", "tests")
|
||||
.add("progress", "none");
|
||||
confs.emplace_back(conf);
|
||||
conf = Config();
|
||||
conf.add("repo", "Fuzz/testto").add("compression", "zlib").add("from", "Fuzz/testfrom").add("encryption", "aes").add("password", "testp").add("salt", "tests").add("progress", "none");
|
||||
conf.add("repo", "Fuzz/testto")
|
||||
.add("compression", "zlib")
|
||||
.add("from", "Fuzz/testfrom")
|
||||
.add("encryption", "aes")
|
||||
.add("password", "testp")
|
||||
.add("salt", "tests")
|
||||
.add("progress", "none");
|
||||
confs.emplace_back(conf);
|
||||
|
||||
for (auto const &conf: confs) {
|
||||
@@ -332,7 +378,8 @@ TEST(FullTest, Fuzz) {
|
||||
{
|
||||
std::filesystem::create_directories("Fuzz/testfrom");
|
||||
for (int i = 0; i < 2; i++) {
|
||||
std::ofstream o(std::filesystem::path("Fuzz/testfrom") / ("f" + std::to_string(i)), std::ios::binary | std::ios::out | std::ios::trunc);
|
||||
std::ofstream o(std::filesystem::path("Fuzz/testfrom") / ("f" + std::to_string(i)),
|
||||
std::ios::binary | std::ios::out | std::ios::trunc);
|
||||
for (int j = 0; j < i; j++) o.put(j % 2);
|
||||
}
|
||||
|
||||
@@ -350,28 +397,28 @@ TEST(FullTest, Fuzz) {
|
||||
|
||||
{
|
||||
if (filetobreak & 0b00000001) {
|
||||
for (int i = 0; i < cutoff; i++)
|
||||
randomChange("Fuzz/testto/1");
|
||||
for (int i = 0; i < cutoff; i++) randomChange("Fuzz/testto/1");
|
||||
if (cutoff > 5)
|
||||
std::filesystem::resize_file("Fuzz/testto/1", std::filesystem::file_size("Fuzz/testto/1") - cutoff);
|
||||
std::filesystem::resize_file("Fuzz/testto/1",
|
||||
std::filesystem::file_size("Fuzz/testto/1") - cutoff);
|
||||
}
|
||||
if (filetobreak & 0b00000010) {
|
||||
for (int i = 0; i < cutoff; i++)
|
||||
randomChange("Fuzz/testto/index");
|
||||
for (int i = 0; i < cutoff; i++) randomChange("Fuzz/testto/index");
|
||||
if (cutoff > 5)
|
||||
std::filesystem::resize_file("Fuzz/testto/index", std::filesystem::file_size("Fuzz/testto/index") - cutoff);
|
||||
std::filesystem::resize_file("Fuzz/testto/index",
|
||||
std::filesystem::file_size("Fuzz/testto/index") - cutoff);
|
||||
}
|
||||
if (filetobreak & 0b00000100) {
|
||||
for (int i = 0; i < cutoff; i++)
|
||||
randomChange("Fuzz/testto/offsets");
|
||||
for (int i = 0; i < cutoff; i++) randomChange("Fuzz/testto/offsets");
|
||||
if (cutoff > 5)
|
||||
std::filesystem::resize_file("Fuzz/testto/offsets", std::filesystem::file_size("Fuzz/testto/offsets") - cutoff);
|
||||
std::filesystem::resize_file("Fuzz/testto/offsets",
|
||||
std::filesystem::file_size("Fuzz/testto/offsets") - cutoff);
|
||||
}
|
||||
if (filetobreak & 0b00001000) {
|
||||
for (int i = 0; i < cutoff; i++)
|
||||
randomChange("Fuzz/testto/info");
|
||||
for (int i = 0; i < cutoff; i++) randomChange("Fuzz/testto/info");
|
||||
if (cutoff > 5)
|
||||
std::filesystem::resize_file("Fuzz/testto/info", std::filesystem::file_size("Fuzz/testto/info") - cutoff);
|
||||
std::filesystem::resize_file("Fuzz/testto/info",
|
||||
std::filesystem::file_size("Fuzz/testto/info") - cutoff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,8 +438,7 @@ TEST(FullTest, Fuzz) {
|
||||
CommandRestore cmd;
|
||||
cmd.run(Context{&logger, repo.get()});
|
||||
auto outstr = runnerout.str();
|
||||
if (outstr.find("Error") == std::string::npos)
|
||||
ok = false;
|
||||
if (outstr.find("Error") == std::string::npos) ok = false;
|
||||
} catch (...) {}
|
||||
EXPECT_EQ(ok, true);
|
||||
}
|
||||
|
||||
@@ -36,19 +36,11 @@ TEST(Chunk, Deserialize) {
|
||||
|
||||
EXPECT_EQ(o1.data.size(), o1e.data.size());
|
||||
EXPECT_EQ(o2.data.size(), o2e.data.size());
|
||||
for (int i = 0; i < o1.data.size(); i++) {
|
||||
EXPECT_EQ(o1.data[i], o1e.data[i]);
|
||||
}
|
||||
for (int i = 0; i < o2.data.size(); i++) {
|
||||
EXPECT_EQ(o2.data[i], o2e.data[i]);
|
||||
}
|
||||
for (int i = 0; i < o1.data.size(); i++) { EXPECT_EQ(o1.data[i], o1e.data[i]); }
|
||||
for (int i = 0; i < o2.data.size(); i++) { EXPECT_EQ(o2.data[i], o2e.data[i]); }
|
||||
|
||||
for (int i = 0; i < o1.SHA.size(); i++) {
|
||||
EXPECT_EQ(o1.SHA[i], o1e.SHA[i]);
|
||||
}
|
||||
for (int i = 0; i < o2.SHA.size(); i++) {
|
||||
EXPECT_EQ(o2.SHA[i], o2e.SHA[i]);
|
||||
}
|
||||
for (int i = 0; i < o1.SHA.size(); i++) { EXPECT_EQ(o1.SHA[i], o1e.SHA[i]); }
|
||||
for (int i = 0; i < o2.SHA.size(); i++) { EXPECT_EQ(o2.SHA[i], o2e.SHA[i]); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +49,7 @@ TEST(Chunk, Garbage) {
|
||||
auto eb = e.cbegin();
|
||||
try {
|
||||
Chunk o1(eb, e.cend());
|
||||
} catch (...) {
|
||||
return;
|
||||
}
|
||||
} catch (...) { return; }
|
||||
FAIL() << "Object constructed with garbage data!";
|
||||
}
|
||||
|
||||
@@ -68,9 +58,7 @@ TEST(Chunk, Garbage2) {
|
||||
auto eb = e.cbegin();
|
||||
try {
|
||||
Chunk o1(eb, e.cend());
|
||||
} catch (...) {
|
||||
return;
|
||||
}
|
||||
} catch (...) { return; }
|
||||
FAIL() << "Object constructed with garbage data!";
|
||||
}
|
||||
|
||||
@@ -93,16 +81,13 @@ TEST(Chunk, Garbage3) {
|
||||
try {
|
||||
Chunk o1 = Serialize::deserialize<Chunk>(s1);
|
||||
fail = true;
|
||||
} catch (...) {
|
||||
}
|
||||
} catch (...) {}
|
||||
|
||||
try {
|
||||
Chunk o2 = Serialize::deserialize<Chunk>(s2);
|
||||
fail = true;
|
||||
} catch (...) {
|
||||
}
|
||||
} catch (...) {}
|
||||
|
||||
if (fail)
|
||||
FAIL() << "Object constructed with garbage data!";
|
||||
if (fail) FAIL() << "Object constructed with garbage data!";
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,7 @@ TEST(FileRepository, Deserialize) {
|
||||
conf.add("repo", "Deserizlize/testrepo");
|
||||
FileRepository repo(conf);
|
||||
repo.init();
|
||||
std::vector<char>
|
||||
data1{'a', 'b', 'c', 'e'};
|
||||
std::vector<char> data1{'a', 'b', 'c', 'e'};
|
||||
|
||||
std::string o1k(16, '\0');
|
||||
std::string o2k(16, '\0');
|
||||
@@ -72,12 +71,8 @@ TEST(FileRepository, Deserialize) {
|
||||
auto o2ed = o2e.data;
|
||||
EXPECT_EQ(o1.data.size(), o1e.data.size());
|
||||
EXPECT_EQ(o2.data.size(), o2e.data.size());
|
||||
for (int i = 0; i < o1.data.size(); i++) {
|
||||
EXPECT_EQ(o1.data[i], o1e.data[i]);
|
||||
}
|
||||
for (int i = 0; i < o2.data.size(); i++) {
|
||||
EXPECT_EQ(o2.data[i], o2e.data[i]);
|
||||
}
|
||||
for (int i = 0; i < o1.data.size(); i++) { EXPECT_EQ(o1.data[i], o1e.data[i]); }
|
||||
for (int i = 0; i < o2.data.size(); i++) { EXPECT_EQ(o2.data[i], o2e.data[i]); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,8 +94,7 @@ TEST(FileRepository, Filters) {
|
||||
std::string o2k(16, '\0');
|
||||
o2k[0] = 1;
|
||||
o2k[1] = 2;
|
||||
std::vector<char>
|
||||
data1{'a', 'b', 'c', 'e'};
|
||||
std::vector<char> data1{'a', 'b', 'c', 'e'};
|
||||
Chunk o1(666, o1k, data1);
|
||||
std::vector<char> data2{'q', 'w', 'e', 'r', 'b'};
|
||||
Chunk o2(777, o2k, data2);
|
||||
@@ -147,8 +141,7 @@ TEST(FileRepository, Filters) {
|
||||
err = true;
|
||||
} catch (...) {}
|
||||
|
||||
if (err)
|
||||
throw Exception("Object constructed with garbage data!");
|
||||
if (err) throw Exception("Object constructed with garbage data!");
|
||||
}
|
||||
{
|
||||
Config conf;
|
||||
@@ -193,12 +186,8 @@ TEST(FileRepository, Filters) {
|
||||
auto o2ed = o2e.data;
|
||||
EXPECT_EQ(o1.data.size(), o1e.data.size());
|
||||
EXPECT_EQ(o2.data.size(), o2e.data.size());
|
||||
for (int i = 0; i < o1.data.size(); i++) {
|
||||
EXPECT_EQ(o1.data[i], o1e.data[i]);
|
||||
}
|
||||
for (int i = 0; i < o2.data.size(); i++) {
|
||||
EXPECT_EQ(o2.data[i], o2e.data[i]);
|
||||
}
|
||||
for (int i = 0; i < o1.data.size(); i++) { EXPECT_EQ(o1.data[i], o1e.data[i]); }
|
||||
for (int i = 0; i < o2.data.size(); i++) { EXPECT_EQ(o2.data[i], o2e.data[i]); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,8 +204,7 @@ TEST(FileRepository, IDsDisabled) {
|
||||
std::string o2k(16, '\0');
|
||||
o2k[0] = 1;
|
||||
|
||||
std::vector<char>
|
||||
data1{'a', 'b', 'c', 'e'};
|
||||
std::vector<char> data1{'a', 'b', 'c', 'e'};
|
||||
Chunk o1(repo.getId(), o1k, data1);
|
||||
std::vector<char> data2{'q', 'w', 'e', 'r', 'b'};
|
||||
Chunk o2(repo.getId(), o2k, data2);
|
||||
@@ -261,12 +249,8 @@ TEST(FileRepository, IDsDisabled) {
|
||||
auto o2ed = o2e.data;
|
||||
EXPECT_EQ(o1.data.size(), o1e.data.size());
|
||||
EXPECT_EQ(o2.data.size(), o2e.data.size());
|
||||
for (int i = 0; i < o1.data.size(); i++) {
|
||||
EXPECT_EQ(o1.data[i], o1e.data[i]);
|
||||
}
|
||||
for (int i = 0; i < o2.data.size(); i++) {
|
||||
EXPECT_EQ(o2.data[i], o2e.data[i]);
|
||||
}
|
||||
for (int i = 0; i < o1.data.size(); i++) { EXPECT_EQ(o1.data[i], o1e.data[i]); }
|
||||
for (int i = 0; i < o2.data.size(); i++) { EXPECT_EQ(o2.data[i], o2e.data[i]); }
|
||||
|
||||
|
||||
EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o1k), 1);
|
||||
@@ -287,8 +271,7 @@ TEST(FileRepository, IDsDisabled) {
|
||||
|
||||
auto id = repo.getId();
|
||||
EXPECT_EQ(id, 1);
|
||||
std::vector<char>
|
||||
data1{'a', 'b', 'c', 'e'};
|
||||
std::vector<char> data1{'a', 'b', 'c', 'e'};
|
||||
Chunk o1(id, o2k, data1);
|
||||
EXPECT_EQ(repo.getId(), 3);
|
||||
}
|
||||
|
||||
@@ -5,13 +5,9 @@
|
||||
#include "Cleaner.h"
|
||||
|
||||
Cleaner::Cleaner(std::vector<std::filesystem::path> toClean) : toClean(std::move(toClean)) {
|
||||
for (const auto &p: this->toClean) {
|
||||
std::filesystem::remove_all(p);
|
||||
}
|
||||
for (const auto &p: this->toClean) { std::filesystem::remove_all(p); }
|
||||
}
|
||||
|
||||
Cleaner::~Cleaner() {
|
||||
for (const auto &p: toClean) {
|
||||
std::filesystem::remove_all(p);
|
||||
}
|
||||
for (const auto &p: toClean) { std::filesystem::remove_all(p); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user