[libc-commits] [libc] 2e3b8b3 - [libc][NFC] Use ASSERT instead of EXPECT in tests
Guillaume Chatelet via libc-commits
libc-commits at lists.llvm.org
Tue Oct 18 07:32:49 PDT 2022
Author: Guillaume Chatelet
Date: 2022-10-18T14:32:39Z
New Revision: 2e3b8b31ce688d5a3db51ab13fb9488aa68444f5
URL: https://github.com/llvm/llvm-project/commit/2e3b8b31ce688d5a3db51ab13fb9488aa68444f5
DIFF: https://github.com/llvm/llvm-project/commit/2e3b8b31ce688d5a3db51ab13fb9488aa68444f5.diff
LOG: [libc][NFC] Use ASSERT instead of EXPECT in tests
Added:
Modified:
libc/test/src/string/bcmp_test.cpp
libc/test/src/string/memmove_test.cpp
Removed:
################################################################################
diff --git a/libc/test/src/string/bcmp_test.cpp b/libc/test/src/string/bcmp_test.cpp
index 19df7ad2637a2..8f0fe5262f22d 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 26b4d9e9d675d..451ccdb0a89b9 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);
}
}
}
More information about the libc-commits
mailing list