[libc-commits] [PATCH] D109588: [libc] Check signs instead of values in memcmp unittests.
Cheng Wang via Phabricator via libc-commits
libc-commits at lists.llvm.org
Fri Sep 10 03:35:34 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2fc1913505e3: [libc] Check signs instead of values in memcmp unittests. (authored by cheng.w).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109588/new/
https://reviews.llvm.org/D109588
Files:
libc/test/src/string/memcmp_test.cpp
Index: libc/test/src/string/memcmp_test.cpp
===================================================================
--- libc/test/src/string/memcmp_test.cpp
+++ libc/test/src/string/memcmp_test.cpp
@@ -11,7 +11,7 @@
TEST(LlvmLibcMemcmpTest, CmpZeroByte) {
const char *lhs = "ab";
- const char *rhs = "bc";
+ const char *rhs = "yz";
EXPECT_EQ(__llvm_libc::memcmp(lhs, rhs, 0), 0);
}
@@ -23,14 +23,14 @@
TEST(LlvmLibcMemcmpTest, LhsBeforeRhsLexically) {
const char *lhs = "ab";
- const char *rhs = "ac";
- EXPECT_EQ(__llvm_libc::memcmp(lhs, rhs, 2), -1);
+ const char *rhs = "az";
+ EXPECT_LT(__llvm_libc::memcmp(lhs, rhs, 2), 0);
}
TEST(LlvmLibcMemcmpTest, LhsAfterRhsLexically) {
- const char *lhs = "ac";
+ const char *lhs = "az";
const char *rhs = "ab";
- EXPECT_EQ(__llvm_libc::memcmp(lhs, rhs, 2), 1);
+ EXPECT_GT(__llvm_libc::memcmp(lhs, rhs, 2), 0);
}
TEST(LlvmLibcMemcmpTest, Sweep) {
@@ -51,8 +51,8 @@
reset(lhs);
reset(rhs);
for (size_t i = 0; i < kMaxSize; ++i) {
- rhs[i] = 'b';
- EXPECT_EQ(__llvm_libc::memcmp(lhs, rhs, kMaxSize), -1);
+ rhs[i] = 'z';
+ EXPECT_LT(__llvm_libc::memcmp(lhs, rhs, kMaxSize), 0);
rhs[i] = 'a';
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109588.371857.patch
Type: text/x-patch
Size: 1204 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210910/a9c6c2f0/attachment.bin>
More information about the libc-commits
mailing list