[libc-commits] [libc] [libc] Fix sprintf FixedConv test (PR #98204)

Mikhail R. Gadelha via libc-commits libc-commits at lists.llvm.org
Tue Jul 9 12:28:24 PDT 2024


https://github.com/mikhailramalho created https://github.com/llvm/llvm-project/pull/98204

Similar to #98195.

This patch enlarges the number to ensure that a 64-bit number is being read.

>From a2223bd9e844e57689264c427fcd1d30052131db Mon Sep 17 00:00:00 2001
From: "Mikhail R. Gadelha" <mikhail at igalia.com>
Date: Tue, 9 Jul 2024 16:23:41 -0300
Subject: [PATCH] [libc] Fix sprintf FixedConv test

Similar to #98195.

This patch enlarges the number to ensure that a 64-bit number is being
read.
---
 libc/test/src/stdio/sprintf_test.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libc/test/src/stdio/sprintf_test.cpp b/libc/test/src/stdio/sprintf_test.cpp
index 7ccc0a2652e2b..de389e032f895 100644
--- a/libc/test/src/stdio/sprintf_test.cpp
+++ b/libc/test/src/stdio/sprintf_test.cpp
@@ -3351,7 +3351,7 @@ TEST_F(LlvmLibcSPrintfTest, FixedConv) {
       LIBC_NAMESPACE::sprintf(buff, "%hR", 0xff); // unsigned short fract max
   ASSERT_STREQ_LEN(written, buff, "0.996094");
 
-  written = LIBC_NAMESPACE::sprintf(buff, "%lk", 0x0); // 0.0
+  written = LIBC_NAMESPACE::sprintf(buff, "%lk", 0x0ll); // 0.0
   ASSERT_STREQ_LEN(written, buff, "0.000000");
 
   written = LIBC_NAMESPACE::sprintf(buff, "%lk",
@@ -3365,7 +3365,7 @@ TEST_F(LlvmLibcSPrintfTest, FixedConv) {
                                     0xffffffff); //-long fract max
   ASSERT_STREQ_LEN(written, buff, "-1.000000");
 
-  written = LIBC_NAMESPACE::sprintf(buff, "%lK", 0x0); // 0.0
+  written = LIBC_NAMESPACE::sprintf(buff, "%lK", 0x0ll); // 0.0
   ASSERT_STREQ_LEN(written, buff, "0.000000");
 
   written =
@@ -3493,8 +3493,8 @@ TEST_F(LlvmLibcSPrintfTest, FixedConv) {
   ASSERT_STREQ_LEN(written, buff, "       0.100 256.000     ");
 
   written =
-      LIBC_NAMESPACE::sprintf(buff, "%+-#12.3lk % 012.3k", 0x000000001013a92a,
-                              0x02740000); // 0.126, 1256.0
+      LIBC_NAMESPACE::sprintf(buff, "%+-#12.3lk % 012.3k", 0x000000001013a92all,
+                              0x02740000ll); // 0.126, 1256.0
   ASSERT_STREQ_LEN(written, buff, "+0.126        0001256.000");
 }
 #endif // defined(LIBC_COMPILER_HAS_FIXED_POINT) &&



More information about the libc-commits mailing list