From 2e3b8b31ce688d5a3db51ab13fb9488aa68444f5 Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Tue, 18 Oct 2022 14:30:04 +0000 Subject: [PATCH] [libc][NFC] Use ASSERT instead of EXPECT in tests --- libc/test/src/string/bcmp_test.cpp | 12 ++++++------ libc/test/src/string/memmove_test.cpp | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libc/test/src/string/bcmp_test.cpp b/libc/test/src/string/bcmp_test.cpp index 19df7ad26..8f0fe52 100644 --- a/libc/test/src/string/bcmp_test.cpp +++ b/libc/test/src/string/bcmp_test.cpp @@ -12,25 +12,25 @@ TEST(LlvmLibcBcmpTest, CmpZeroByte) { const char *lhs = "ab"; const char *rhs = "bc"; - EXPECT_EQ(__llvm_libc::bcmp(lhs, rhs, 0), 0); + ASSERT_EQ(__llvm_libc::bcmp(lhs, rhs, 0), 0); } TEST(LlvmLibcBcmpTest, LhsRhsAreTheSame) { const char *lhs = "ab"; const char *rhs = "ab"; - EXPECT_EQ(__llvm_libc::bcmp(lhs, rhs, 2), 0); + ASSERT_EQ(__llvm_libc::bcmp(lhs, rhs, 2), 0); } TEST(LlvmLibcBcmpTest, LhsBeforeRhsLexically) { const char *lhs = "ab"; const char *rhs = "ac"; - EXPECT_NE(__llvm_libc::bcmp(lhs, rhs, 2), 0); + ASSERT_NE(__llvm_libc::bcmp(lhs, rhs, 2), 0); } TEST(LlvmLibcBcmpTest, LhsAfterRhsLexically) { const char *lhs = "ac"; const char *rhs = "ab"; - EXPECT_NE(__llvm_libc::bcmp(lhs, rhs, 2), 0); + ASSERT_NE(__llvm_libc::bcmp(lhs, rhs, 2), 0); } TEST(LlvmLibcBcmpTest, Sweep) { @@ -46,13 +46,13 @@ TEST(LlvmLibcBcmpTest, Sweep) { reset(lhs); reset(rhs); for (size_t i = 0; i < K_MAX_SIZE; ++i) - EXPECT_EQ(__llvm_libc::bcmp(lhs, rhs, i), 0); + ASSERT_EQ(__llvm_libc::bcmp(lhs, rhs, i), 0); reset(lhs); reset(rhs); for (size_t i = 0; i < K_MAX_SIZE; ++i) { rhs[i] = 'b'; - EXPECT_NE(__llvm_libc::bcmp(lhs, rhs, K_MAX_SIZE), 0); + ASSERT_NE(__llvm_libc::bcmp(lhs, rhs, K_MAX_SIZE), 0); rhs[i] = 'a'; } } diff --git a/libc/test/src/string/memmove_test.cpp b/libc/test/src/string/memmove_test.cpp index 26b4d9e..451ccdb 100644 --- a/libc/test/src/string/memmove_test.cpp +++ b/libc/test/src/string/memmove_test.cpp @@ -20,7 +20,7 @@ TEST(LlvmLibcMemmoveTest, MoveZeroByte) { void *const Dst = Buffer; void *const Ret = __llvm_libc::memmove(Dst, Buffer + 2, 0); EXPECT_EQ(Ret, Dst); - EXPECT_MEM_EQ(Buffer, Expected); + ASSERT_MEM_EQ(Buffer, Expected); } TEST(LlvmLibcMemmoveTest, DstAndSrcPointToSameAddress) { @@ -29,7 +29,7 @@ TEST(LlvmLibcMemmoveTest, DstAndSrcPointToSameAddress) { void *const Dst = Buffer; void *const Ret = __llvm_libc::memmove(Dst, Buffer, 1); EXPECT_EQ(Ret, Dst); - EXPECT_MEM_EQ(Buffer, Expected); + ASSERT_MEM_EQ(Buffer, Expected); } TEST(LlvmLibcMemmoveTest, DstStartsBeforeSrc) { @@ -40,7 +40,7 @@ TEST(LlvmLibcMemmoveTest, DstStartsBeforeSrc) { void *const Dst = Buffer + 1; void *const Ret = __llvm_libc::memmove(Dst, Buffer + 2, 2); EXPECT_EQ(Ret, Dst); - EXPECT_MEM_EQ(Buffer, Expected); + ASSERT_MEM_EQ(Buffer, Expected); } TEST(LlvmLibcMemmoveTest, DstStartsAfterSrc) { @@ -49,7 +49,7 @@ TEST(LlvmLibcMemmoveTest, DstStartsAfterSrc) { void *const Dst = Buffer + 2; void *const Ret = __llvm_libc::memmove(Dst, Buffer + 1, 2); EXPECT_EQ(Ret, Dst); - EXPECT_MEM_EQ(Buffer, Expected); + ASSERT_MEM_EQ(Buffer, Expected); } // e.g. `Dst` follow `src`. @@ -62,7 +62,7 @@ TEST(LlvmLibcMemmoveTest, SrcFollowDst) { void *const Dst = Buffer + 1; void *const Ret = __llvm_libc::memmove(Dst, Buffer + 2, 1); EXPECT_EQ(Ret, Dst); - EXPECT_MEM_EQ(Buffer, Expected); + ASSERT_MEM_EQ(Buffer, Expected); } TEST(LlvmLibcMemmoveTest, DstFollowSrc) { @@ -71,7 +71,7 @@ TEST(LlvmLibcMemmoveTest, DstFollowSrc) { void *const Dst = Buffer + 2; void *const Ret = __llvm_libc::memmove(Dst, Buffer + 1, 1); EXPECT_EQ(Ret, Dst); - EXPECT_MEM_EQ(Buffer, Expected); + ASSERT_MEM_EQ(Buffer, Expected); } static constexpr int kMaxSize = 512; @@ -106,7 +106,7 @@ TEST(LlvmLibcMemmoveTest, Thorough) { void *const Ret = __llvm_libc::memmove(Dst, Buffer.data() + SrcOffset, Size); EXPECT_EQ(Ret, Dst); - EXPECT_MEM_EQ(Buffer, Expected); + ASSERT_MEM_EQ(Buffer, Expected); } } } -- 2.7.4