[llvm] [libc] [libc][math] Implement nan(f|l) functions (PR #76690)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 2 05:58:39 PST 2024
================
@@ -0,0 +1,40 @@
+//===-- Unittests for nan -------------------------------------------------===//
+//
+// 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/__support/FPUtil/FPBits.h"
+#include "src/math/nan.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+class LlvmLibcNanTest : public LIBC_NAMESPACE::testing::Test {
+public:
+ using StorageType = LIBC_NAMESPACE::fputil::FPBits<double>::StorageType;
+
+ void run_test(const char *input_str, StorageType bits) {
+ double result = LIBC_NAMESPACE::nan(input_str);
+ auto actual_fp = LIBC_NAMESPACE::fputil::FPBits<double>(result);
+ auto expected_fp = LIBC_NAMESPACE::fputil::FPBits<double>(bits);
+ EXPECT_EQ(actual_fp.bits, expected_fp.bits);
+ };
+};
+
+TEST_F(LlvmLibcNanTest, NCharSeq) {
+ run_test("", 0x7ff8000000000000);
----------------
lntue wrote:
What will happen if we call `nan(nullptr)` ?
https://github.com/llvm/llvm-project/pull/76690
More information about the llvm-commits
mailing list