diff --git a/tests/chunkers/srcs/BuzhashTest.cpp b/tests/chunkers/srcs/BuzhashTest.cpp index c293527..881f5d3 100644 --- a/tests/chunkers/srcs/BuzhashTest.cpp +++ b/tests/chunkers/srcs/BuzhashTest.cpp @@ -26,11 +26,11 @@ TEST(BuzhashTest, SimpleTest) { for (int i = 0; i < loremipsum.length(); i++) { b2.feed((uint8_t) loremipsum[i]); if (b2.get() == h1) { - EXPECT_EQ(i, loremipsum.find("e eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non p")); + ASSERT_EQ(i, loremipsum.find("e eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non p")); h1found = true; break; } } - EXPECT_EQ(h1found, true); + ASSERT_EQ(h1found, true); } } diff --git a/tests/clitests/srcs/CLITestWrapper.cpp b/tests/clitests/srcs/CLITestWrapper.cpp index 9af8a0c..8504649 100644 --- a/tests/clitests/srcs/CLITestWrapper.cpp +++ b/tests/clitests/srcs/CLITestWrapper.cpp @@ -9,15 +9,15 @@ TEST(CLITest, Backup) { int ret = system("../../../tests/clitests/scripts/backup.sh"); - EXPECT_EQ(WEXITSTATUS(ret), 0); + ASSERT_EQ(WEXITSTATUS(ret), 0); } TEST(CLITest, Ignore) { int ret = system("../../../tests/clitests/scripts/ignore.sh"); - EXPECT_EQ(WEXITSTATUS(ret), 0); + ASSERT_EQ(WEXITSTATUS(ret), 0); } TEST(CLITest, Diff) { int ret = system("../../../tests/clitests/scripts/diff.sh"); - EXPECT_EQ(WEXITSTATUS(ret), 0); + ASSERT_EQ(WEXITSTATUS(ret), 0); } \ No newline at end of file diff --git a/tests/crypto/srcs/CryptoTests.cpp b/tests/crypto/srcs/CryptoTests.cpp index 29ecd46..867382e 100644 --- a/tests/crypto/srcs/CryptoTests.cpp +++ b/tests/crypto/srcs/CryptoTests.cpp @@ -11,32 +11,32 @@ TEST(CryptoTests, AES) { std::string in = "hello1"; auto enc = AES::encrypt(std::vector(in.begin(), in.end()), "p1", "e"); auto dec = AES::decrypt(enc, "p1", "e"); - EXPECT_EQ(in, std::string(dec.begin(), dec.end())); + ASSERT_EQ(in, std::string(dec.begin(), dec.end())); in = ""; enc = AES::encrypt(std::vector(in.begin(), in.end()), "p1", "e"); dec = AES::decrypt(enc, "p1", "e"); - EXPECT_EQ(in, std::string(dec.begin(), dec.end())); + ASSERT_EQ(in, std::string(dec.begin(), dec.end())); in = "1234567890asdfg"; enc = AES::encrypt(std::vector(in.begin(), in.end()), "p1", "e"); dec = AES::decrypt(enc, "p1", "e"); - EXPECT_EQ(in, std::string(dec.begin(), dec.end())); + ASSERT_EQ(in, std::string(dec.begin(), dec.end())); in = "1234567890asdfgh"; enc = AES::encrypt(std::vector(in.begin(), in.end()), "p1", "e"); dec = AES::decrypt(enc, "p1", "e"); - EXPECT_EQ(in, std::string(dec.begin(), dec.end())); + ASSERT_EQ(in, std::string(dec.begin(), dec.end())); in = "1234567890asdfghe"; enc = AES::encrypt(std::vector(in.begin(), in.end()), "p1", "e"); dec = AES::decrypt(enc, "p1", "e"); - EXPECT_EQ(in, std::string(dec.begin(), dec.end())); + ASSERT_EQ(in, std::string(dec.begin(), dec.end())); in = "1234567890asdfgheq"; enc = AES::encrypt(std::vector(in.begin(), in.end()), "p1", "e"); dec = AES::decrypt(enc, "p1", "e"); - EXPECT_EQ(in, std::string(dec.begin(), dec.end())); + ASSERT_EQ(in, std::string(dec.begin(), dec.end())); } TEST(CryptoTests, SHA) { @@ -47,6 +47,6 @@ TEST(CryptoTests, SHA) { auto out = SHA::calculate(data); - EXPECT_EQ(out.size(), 32); - for (int i = 0; i < out.size(); i++) { EXPECT_EQ(static_cast(out[i]), excepted[i]); } + ASSERT_EQ(out.size(), 32); + for (int i = 0; i < out.size(); i++) { ASSERT_EQ(static_cast(out[i]), excepted[i]); } } diff --git a/tests/fulltests/srcs/FullTest.cpp b/tests/fulltests/srcs/FullTest.cpp index 05741fe..dd7ca16 100644 --- a/tests/fulltests/srcs/FullTest.cpp +++ b/tests/fulltests/srcs/FullTest.cpp @@ -61,7 +61,7 @@ TEST(FullTest, Simple) { } { try { - EXPECT_EQ(std::filesystem::is_directory("Simple/testtores/testdir"), true); + ASSERT_EQ(std::filesystem::is_directory("Simple/testtores/testdir"), true); } catch (...) { std::cerr << "Empty directory doesn't exist!" << std::endl; throw; @@ -71,11 +71,11 @@ TEST(FullTest, Simple) { 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); + ASSERT_EQ(o.is_open(), true); for (int j = 0; j < i; j++) { char c; - EXPECT_EQ(o.get(c).operator bool(), true); - EXPECT_EQ(static_cast(j % 256), c); + ASSERT_EQ(o.get(c).operator bool(), true); + ASSERT_EQ(static_cast(j % 256), c); } } catch (...) { std::cerr << "Error comparing file " << i << std::endl; @@ -150,16 +150,16 @@ TEST(FullTest, SimpleWithIgnore) { cmd.run(Context{&logger, repo.get()}); } { - EXPECT_EQ(std::filesystem::is_directory("SimpleWithIgnore/testtores/testdir"), true); + ASSERT_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); - EXPECT_EQ(o.is_open(), true); + ASSERT_EQ(o.is_open(), true); for (int j = 0; j < i; j++) { char c; - EXPECT_EQ(o.get(c).operator bool(), true); - EXPECT_EQ(static_cast(j % 256), c); + ASSERT_EQ(o.get(c).operator bool(), true); + ASSERT_EQ(static_cast(j % 256), c); } } @@ -167,31 +167,31 @@ TEST(FullTest, SimpleWithIgnore) { std::ifstream file("SimpleWithIgnore/testtores/testdir2/.ignore"); std::string s; file >> s; - EXPECT_EQ(s, "hello.txt"); + ASSERT_EQ(s, "hello.txt"); } { std::ifstream file("SimpleWithIgnore/testtores/testdir2/testdir3/.ignore"); std::string s; file >> s; - EXPECT_EQ(s, ".*\\.txt"); + ASSERT_EQ(s, ".*\\.txt"); } { std::ifstream file("SimpleWithIgnore/testtores/testdir2/hello.txt"); - EXPECT_EQ(!file, true); + ASSERT_EQ(!file, true); } { std::ifstream file("SimpleWithIgnore/testtores/testdir2/testdir3/hello.txt"); - EXPECT_EQ(!file, true); + ASSERT_EQ(!file, true); } { std::ifstream file("SimpleWithIgnore/testtores/testdir2/testdir3/asdf.txt"); - EXPECT_EQ(!file, true); + ASSERT_EQ(!file, true); } { std::ifstream file("SimpleWithIgnore/testtores/testdir2/testdir4/asdf.txt"); std::string s; file >> s; - EXPECT_EQ(s, "asdf2"); + ASSERT_EQ(s, "asdf2"); } } } @@ -237,16 +237,16 @@ TEST(FullTest, SimpleWithCompress) { cmd.run(Context{&logger, repo.get()}); } { - EXPECT_EQ(std::filesystem::is_directory("SimpleWithCompress/testtores/testdir"), true); + ASSERT_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); - EXPECT_EQ(o.is_open(), true); + ASSERT_EQ(o.is_open(), true); for (int j = 0; j < i; j++) { char c; - EXPECT_EQ(o.get(c).operator bool(), true); - EXPECT_EQ(static_cast(j % 256), c); + ASSERT_EQ(o.get(c).operator bool(), true); + ASSERT_EQ(static_cast(j % 256), c); } } } @@ -290,10 +290,10 @@ TEST(FullTest, SimpleWithCompEnd) { bool ok = true; try { - EXPECT_EQ(repo->open(), false); + ASSERT_EQ(repo->open(), false); ok = false; } catch (...) {} - EXPECT_EQ(ok, true); + ASSERT_EQ(ok, true); } { Config conf; @@ -312,16 +312,16 @@ TEST(FullTest, SimpleWithCompEnd) { cmd.run(Context{&logger, repo.get()}); } { - EXPECT_EQ(std::filesystem::is_directory("SimpleWithCompEnd/testtores/testdir"), true); + ASSERT_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); - EXPECT_EQ(o.is_open(), true); + ASSERT_EQ(o.is_open(), true); for (int j = 0; j < i; j++) { char c; - EXPECT_EQ(o.get(c).operator bool(), true); - EXPECT_EQ(static_cast(j % 256), c); + ASSERT_EQ(o.get(c).operator bool(), true); + ASSERT_EQ(static_cast(j % 256), c); } } } @@ -440,7 +440,7 @@ TEST(FullTest, Fuzz) { auto outstr = runnerout.str(); if (outstr.find("Error") == std::string::npos) ok = false; } catch (...) {} - EXPECT_EQ(ok, true); + ASSERT_EQ(ok, true); } } } diff --git a/tests/repo/srcs/ChunkTest.cpp b/tests/repo/srcs/ChunkTest.cpp index 1cea161..b8507f6 100644 --- a/tests/repo/srcs/ChunkTest.cpp +++ b/tests/repo/srcs/ChunkTest.cpp @@ -29,18 +29,18 @@ TEST(Chunk, Deserialize) { std::vector data2{'q', 'w', 'e', 'r', 'b'}; Chunk o2e(777, {1}, data2); - EXPECT_EQ(o1.id, o1e.id); - EXPECT_EQ(o2.id, o2e.id); - EXPECT_EQ((int) o1.type, (int) o1e.type); - EXPECT_EQ((int) o2.type, (int) o2e.type); + ASSERT_EQ(o1.id, o1e.id); + ASSERT_EQ(o2.id, o2e.id); + ASSERT_EQ((int) o1.type, (int) o1e.type); + ASSERT_EQ((int) o2.type, (int) o2e.type); - 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]); } + ASSERT_EQ(o1.data.size(), o1e.data.size()); + ASSERT_EQ(o2.data.size(), o2e.data.size()); + for (int i = 0; i < o1.data.size(); i++) { ASSERT_EQ(o1.data[i], o1e.data[i]); } + for (int i = 0; i < o2.data.size(); i++) { ASSERT_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++) { ASSERT_EQ(o1.SHA[i], o1e.SHA[i]); } + for (int i = 0; i < o2.SHA.size(); i++) { ASSERT_EQ(o2.SHA[i], o2e.SHA[i]); } } } diff --git a/tests/repo/srcs/FileRepositoryTest.cpp b/tests/repo/srcs/FileRepositoryTest.cpp index 1d92aea..9f754ca 100644 --- a/tests/repo/srcs/FileRepositoryTest.cpp +++ b/tests/repo/srcs/FileRepositoryTest.cpp @@ -32,8 +32,8 @@ TEST(FileRepository, Deserialize) { repo.putObject(o2); - EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o1k), 666); - EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 777); + ASSERT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o1k), 666); + ASSERT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 777); } { Config conf; @@ -45,8 +45,8 @@ TEST(FileRepository, Deserialize) { std::string o2k(16, '\0'); o2k[0] = 1; o2k[1] = 2; - EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o1k), 666); - EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 777); + ASSERT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o1k), 666); + ASSERT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 777); auto o1o = repo.getObject(666); auto o2o = repo.getObject(777); @@ -61,18 +61,18 @@ TEST(FileRepository, Deserialize) { std::vector data2{'q', 'w', 'e', 'r', static_cast(255)}; Chunk o2e(777, o2k, data2); - EXPECT_EQ(o1.id, o1e.id); - EXPECT_EQ(o2.id, o2e.id); - EXPECT_EQ((int) o1.type, (int) o1e.type); - EXPECT_EQ((int) o2.type, (int) o2e.type); + ASSERT_EQ(o1.id, o1e.id); + ASSERT_EQ(o2.id, o2e.id); + ASSERT_EQ((int) o1.type, (int) o1e.type); + ASSERT_EQ((int) o2.type, (int) o2e.type); auto o1d = o1.data; auto o1ed = o1e.data; auto o2d = o2.data; 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]); } + ASSERT_EQ(o1.data.size(), o1e.data.size()); + ASSERT_EQ(o2.data.size(), o2e.data.size()); + for (int i = 0; i < o1.data.size(); i++) { ASSERT_EQ(o1.data[i], o1e.data[i]); } + for (int i = 0; i < o2.data.size(); i++) { ASSERT_EQ(o2.data[i], o2e.data[i]); } } } @@ -103,8 +103,8 @@ TEST(FileRepository, Filters) { repo.putObject(o2); - EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o1k), 666); - EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 777); + ASSERT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o1k), 666); + ASSERT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 777); } { Config conf; @@ -160,8 +160,8 @@ TEST(FileRepository, Filters) { std::string o2k(16, '\0'); o2k[0] = 1; o2k[1] = 2; - EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o1k), 666); - EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 777); + ASSERT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o1k), 666); + ASSERT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 777); auto o1o = repo.getObject(666); auto o2o = repo.getObject(777); @@ -176,18 +176,18 @@ TEST(FileRepository, Filters) { std::vector data2{'q', 'w', 'e', 'r', 'b'}; Chunk o2e(777, o2k, data2); - EXPECT_EQ(o1.id, o1e.id); - EXPECT_EQ(o2.id, o2e.id); - EXPECT_EQ((int) o1.type, (int) o1e.type); - EXPECT_EQ((int) o2.type, (int) o2e.type); + ASSERT_EQ(o1.id, o1e.id); + ASSERT_EQ(o2.id, o2e.id); + ASSERT_EQ((int) o1.type, (int) o1e.type); + ASSERT_EQ((int) o2.type, (int) o2e.type); auto o1d = o1.data; auto o1ed = o1e.data; auto o2d = o2.data; 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]); } + ASSERT_EQ(o1.data.size(), o1e.data.size()); + ASSERT_EQ(o2.data.size(), o2e.data.size()); + for (int i = 0; i < o1.data.size(); i++) { ASSERT_EQ(o1.data[i], o1e.data[i]); } + for (int i = 0; i < o2.data.size(); i++) { ASSERT_EQ(o2.data[i], o2e.data[i]); } } } @@ -209,15 +209,15 @@ TEST(FileRepository, IDsDisabled) { std::vector data2{'q', 'w', 'e', 'r', 'b'}; Chunk o2(repo.getId(), o2k, data2); - EXPECT_EQ(o1.id, 1); - EXPECT_EQ(o2.id, 2); + ASSERT_EQ(o1.id, 1); + ASSERT_EQ(o2.id, 2); repo.putObject(o1); repo.putObject(o2); - EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o1k), 1); - EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 2); + ASSERT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o1k), 1); + ASSERT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 2); } { Config conf; @@ -239,22 +239,22 @@ TEST(FileRepository, IDsDisabled) { std::vector data2{'q', 'w', 'e', 'r', 'b'}; Chunk o2e(2, o2k, data2); - EXPECT_EQ(o1.id, o1e.id); - EXPECT_EQ(o2.id, o2e.id); - EXPECT_EQ((int) o1.type, (int) o1e.type); - EXPECT_EQ((int) o2.type, (int) o2e.type); + ASSERT_EQ(o1.id, o1e.id); + ASSERT_EQ(o2.id, o2e.id); + ASSERT_EQ((int) o1.type, (int) o1e.type); + ASSERT_EQ((int) o2.type, (int) o2e.type); auto o1d = o1.data; auto o1ed = o1e.data; auto o2d = o2.data; 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]); } + ASSERT_EQ(o1.data.size(), o1e.data.size()); + ASSERT_EQ(o2.data.size(), o2e.data.size()); + for (int i = 0; i < o1.data.size(); i++) { ASSERT_EQ(o1.data[i], o1e.data[i]); } + for (int i = 0; i < o2.data.size(); i++) { ASSERT_EQ(o2.data[i], o2e.data[i]); } - EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o1k), 1); - EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 2); + ASSERT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o1k), 1); + ASSERT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 2); repo.deleteObject(o1); @@ -267,12 +267,12 @@ TEST(FileRepository, IDsDisabled) { std::string o2k(16, '\0'); o2k[0] = 1; - EXPECT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 2); + ASSERT_EQ(repo.getObjectId(Object::ObjectType::Chunk, o2k), 2); auto id = repo.getId(); - EXPECT_EQ(id, 1); + ASSERT_EQ(id, 1); std::vector data1{'a', 'b', 'c', 'e'}; Chunk o1(id, o2k, data1); - EXPECT_EQ(repo.getId(), 3); + ASSERT_EQ(repo.getId(), 3); } }