[libc-commits] [libc] [libc] adjust printf macro test to use all 64 bits (PR #98195)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Tue Jul 9 10:46:56 PDT 2024
https://github.com/michaelrj-google created https://github.com/llvm/llvm-project/pull/98195
The previous printf macro test for 64 bit octal used the number 0123,
which is not large enough to ensure that the macro is actually reading a
64 bit number. This patch enlarges the number, and also makes sure the
return value of sprintf is correct for the macro tests.
>From 75a19ba4dbfe8a99ce7f722a36f9524635fea4da Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Tue, 9 Jul 2024 10:43:38 -0700
Subject: [PATCH] [libc] adjust printf macro test to use all 64 bits
The previous printf macro test for 64 bit octal used the number 0123,
which is not large enough to ensure that the macro is actually reading a
64 bit number. This patch enlarges the number, and also makes sure the
return value of sprintf is correct for the macro tests.
---
libc/test/src/stdio/sprintf_test.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libc/test/src/stdio/sprintf_test.cpp b/libc/test/src/stdio/sprintf_test.cpp
index 8e9870f71a959..7ccc0a2652e2b 100644
--- a/libc/test/src/stdio/sprintf_test.cpp
+++ b/libc/test/src/stdio/sprintf_test.cpp
@@ -39,18 +39,19 @@ using LIBC_NAMESPACE::fputil::testing::RoundingMode;
for (char &c : buff) { \
c = 0; \
} \
- LIBC_NAMESPACE::sprintf(buff, "%" FMT, X); \
- ASSERT_STREQ(buff, expected); \
+ written = LIBC_NAMESPACE::sprintf(buff, "%" FMT, X); \
+ ASSERT_STREQ_LEN(written, buff, expected); \
} while (0)
TEST(LlvmLibcSPrintfTest, Macros) {
char buff[128];
+ int written;
macro_test(PRIu8, 1, "1");
macro_test(PRIX16, 0xAA, "AA");
macro_test(PRId32, -123, "-123");
macro_test(PRIX32, 0xFFFFFF85, "FFFFFF85");
macro_test(PRIo8, 0xFF, "377");
- macro_test(PRIo64, 0123, "123");
+ macro_test(PRIo64, 0123456712345671234567ll, "123456712345671234567");
}
TEST(LlvmLibcSPrintfTest, SimpleNoConv) {
More information about the libc-commits
mailing list