[libc-commits] [libc] [libc][math][c23] add c23 floating point fmaximum and fminimum functions. (PR #86016)

via libc-commits libc-commits at lists.llvm.org
Sun Mar 24 22:08:04 PDT 2024


================
@@ -0,0 +1,100 @@
+//===-- Utility class to test fminimum_num[f|l] -----------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMNUMTEST_H
+#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMNUMTEST_H
+
+#include "src/__support/FPUtil/FPBits.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+template <typename T>
+class FMinimumNumTest : public LIBC_NAMESPACE::testing::Test {
+
+  DECLARE_SPECIAL_CONSTANTS(T)
+
+public:
+  typedef T (*FMinimumNumFunc)(T, T);
+
+  void testNaN(FMinimumNumFunc func) {
+    EXPECT_FP_EQ(inf, func(FPBits::quiet_nan().get_val(), inf));
+    EXPECT_FP_EQ(inf, func(FPBits::signaling_nan().get_val(), inf));
----------------
lntue wrote:

Ditto.  For all the tests, just use `aNaN` and `sNaN` consistently, and only use `FPBits::quiet_nan( ...  )` when you need to set something special in the payloads.

https://github.com/llvm/llvm-project/pull/86016


More information about the libc-commits mailing list