Skip to content

Commit 8492ad5

Browse files
[libc] adjust printf macro test to use all 64 bits (#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.
1 parent 7e2f961 commit 8492ad5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

libc/test/src/stdio/sprintf_test.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,19 @@ using LIBC_NAMESPACE::fputil::testing::RoundingMode;
3939
for (char &c : buff) { \
4040
c = 0; \
4141
} \
42-
LIBC_NAMESPACE::sprintf(buff, "%" FMT, X); \
43-
ASSERT_STREQ(buff, expected); \
42+
written = LIBC_NAMESPACE::sprintf(buff, "%" FMT, X); \
43+
ASSERT_STREQ_LEN(written, buff, expected); \
4444
} while (0)
4545

4646
TEST(LlvmLibcSPrintfTest, Macros) {
4747
char buff[128];
48+
int written;
4849
macro_test(PRIu8, 1, "1");
4950
macro_test(PRIX16, 0xAA, "AA");
5051
macro_test(PRId32, -123, "-123");
5152
macro_test(PRIX32, 0xFFFFFF85, "FFFFFF85");
5253
macro_test(PRIo8, 0xFF, "377");
53-
macro_test(PRIo64, 0123, "123");
54+
macro_test(PRIo64, 0123456712345671234567ll, "123456712345671234567");
5455
}
5556

5657
TEST(LlvmLibcSPrintfTest, SimpleNoConv) {

0 commit comments

Comments
 (0)