[libc-commits] [libc] [libc]: Implement strfrom* functions and utils (PR #85438)
Vinayak Dev via libc-commits
libc-commits at lists.llvm.org
Tue Mar 19 02:04:34 PDT 2024
================
@@ -0,0 +1,91 @@
+//===-- Unittests for strfromf --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/stdlib/strfromf.h"
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibcStrfromfTest, DecimalFloatFormat) {
+ char buff[100];
+ int written;
+
+ written = LIBC_NAMESPACE::strfromf(buff, 16, "%f", 1.0);
+ EXPECT_EQ(written, 8);
+ ASSERT_STREQ(buff, "1.000000");
+
+ written = LIBC_NAMESPACE::strfromf(buff, 20, "%f", 1234567890);
+ EXPECT_EQ(written, 17);
+ ASSERT_STREQ(buff, "1234567936.000000");
+
+ written = LIBC_NAMESPACE::strfromf(buff, 5, "%f", "1234567890.0");
----------------
vinayakdsci wrote:
I am really sorry, I don't know how I didn't notice this. Thanks for catching this!
https://github.com/llvm/llvm-project/pull/85438
More information about the libc-commits
mailing list