[libc-commits] [libc] 91eb99b - [libc][NFC] fix sprintf test on 32 bit systems
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Wed Jul 26 11:33:58 PDT 2023
Author: Michael Jones
Date: 2023-07-26T11:33:53-07:00
New Revision: 91eb99b8417398f0edc7a6124b0606c13d1b2245
URL: https://github.com/llvm/llvm-project/commit/91eb99b8417398f0edc7a6124b0606c13d1b2245
DIFF: https://github.com/llvm/llvm-project/commit/91eb99b8417398f0edc7a6124b0606c13d1b2245.diff
LOG: [libc][NFC] fix sprintf test on 32 bit systems
The expected number for the max ptrdiff value was expected to be exactly
4294967296 (2**32) for 32 bit systems, when it should be
4294967295 (2**32 - 1). This also adds a second test to check for this
case on non-32 bit systems.
Reviewed By: lntue, mikhail.ramalho
Differential Revision: https://reviews.llvm.org/D156257
Added:
Modified:
libc/test/src/stdio/sprintf_test.cpp
Removed:
################################################################################
diff --git a/libc/test/src/stdio/sprintf_test.cpp b/libc/test/src/stdio/sprintf_test.cpp
index e5552742207e4e..7214233220a1fb 100644
--- a/libc/test/src/stdio/sprintf_test.cpp
+++ b/libc/test/src/stdio/sprintf_test.cpp
@@ -122,13 +122,19 @@ TEST(LlvmLibcSPrintfTest, IntConv) {
EXPECT_EQ(written, 20);
ASSERT_STREQ(buff, "18446744073709551615"); // ull max
+ written = __llvm_libc::sprintf(buff, "%u", ~0);
+ if (sizeof(int) == 4) {
+ EXPECT_EQ(written, 10);
+ ASSERT_STREQ(buff, "4294967295");
+ }
+
written = __llvm_libc::sprintf(buff, "%tu", ~ptr
diff _t(0));
if (sizeof(ptr
diff _t) == 8) {
EXPECT_EQ(written, 20);
ASSERT_STREQ(buff, "18446744073709551615");
} else if (sizeof(ptr
diff _t) == 4) {
EXPECT_EQ(written, 10);
- ASSERT_STREQ(buff, "4294967296");
+ ASSERT_STREQ(buff, "4294967295");
}
written = __llvm_libc::sprintf(buff, "%lld", -9223372036854775807ll - 1ll);
More information about the libc-commits
mailing list