[libc-commits] [libc] 72f6dfb - [libc][windows] fix strlcpy tests
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Wed May 18 14:11:56 PDT 2022
Author: Michael Jones
Date: 2022-05-18T14:11:53-07:00
New Revision: 72f6dfb378751fd48bcd70fefd57e7a31bea501d
URL: https://github.com/llvm/llvm-project/commit/72f6dfb378751fd48bcd70fefd57e7a31bea501d
DIFF: https://github.com/llvm/llvm-project/commit/72f6dfb378751fd48bcd70fefd57e7a31bea501d.diff
LOG: [libc][windows] fix strlcpy tests
Generally, size_t is an alias for unsigned long long. In the strlcpy
tests, the return value of strlcpy (a size_t) is compared to an unsigned
long. On Linux unsigned long and unsigned long long are both 64 bits,
but on windows unsigned long is 32 bits. Since the macros require
identical types for both sides, this caused a build failure on windows.
This patch changes the constants to be explicit size_t values.
Differential Revision: https://reviews.llvm.org/D125917
Added:
Modified:
libc/test/src/string/strlcpy_test.cpp
Removed:
################################################################################
diff --git a/libc/test/src/string/strlcpy_test.cpp b/libc/test/src/string/strlcpy_test.cpp
index 1dabcfa918505..a37a7e0f9b418 100644
--- a/libc/test/src/string/strlcpy_test.cpp
+++ b/libc/test/src/string/strlcpy_test.cpp
@@ -13,17 +13,17 @@
TEST(LlvmLibcStrlcpyTest, TooBig) {
const char *str = "abc";
char buf[2];
- EXPECT_EQ(__llvm_libc::strlcpy(buf, str, 2), 3ul);
+ EXPECT_EQ(__llvm_libc::strlcpy(buf, str, 2), size_t(3));
EXPECT_STREQ(buf, "a");
- EXPECT_EQ(__llvm_libc::strlcpy(nullptr, str, 0), 3ul);
+ EXPECT_EQ(__llvm_libc::strlcpy(nullptr, str, 0), size_t(3));
}
TEST(LlvmLibcStrlcpyTest, Smaller) {
const char *str = "abc";
char buf[7]{"111111"};
- EXPECT_EQ(__llvm_libc::strlcpy(buf, str, 7), 3ul);
+ EXPECT_EQ(__llvm_libc::strlcpy(buf, str, 7), size_t(3));
EXPECT_STREQ(buf, "abc");
for (const char *p = buf + 3; p < buf + 7; p++)
EXPECT_EQ(*p, '\0');
More information about the libc-commits
mailing list