[libc-commits] [libc] [libc][math][c23] Add nextup{, f, f128} and nextdown{, f, f128} functions (PR #85431)

via libc-commits libc-commits at lists.llvm.org
Fri Mar 15 12:16:59 PDT 2024


================
@@ -0,0 +1,55 @@
+//===-- Utility class to test different flavors of nextdown -----*- 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_NEXTDOWNTEST_H
+#define LLVM_LIBC_TEST_SRC_MATH_NEXTDOWNTEST_H
+
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+template <typename T>
+class NextDownTestTemplate : public LIBC_NAMESPACE::testing::Test {
+  using FPBits = typename LIBC_NAMESPACE::fputil::FPBits<T>;
+  using Sign = typename LIBC_NAMESPACE::fputil::Sign;
+
+  static constexpr T inf = FPBits::inf().get_val();
+  static constexpr T neg_inf = FPBits::inf(Sign::NEG).get_val();
+  static constexpr T zero = FPBits::zero().get_val();
+  static constexpr T neg_zero = FPBits::zero(Sign::NEG).get_val();
+  static constexpr T nan = FPBits::quiet_nan().get_val();
+
+  static constexpr T min_subnormal = FPBits::min_subnormal().get_val();
+  static constexpr T neg_min_subnormal =
+      FPBits::min_subnormal(Sign::NEG).get_val();
+  static constexpr T max_normal = FPBits::max_normal().get_val();
+  static constexpr T neg_max_normal = FPBits::max_normal(Sign::NEG).get_val();
----------------
lntue wrote:

Technically you can inherit directly from `FPTest` instead of calling `DECLARE_SPECIAL_CONSTANTS`.  But we can leave the clean up task of making all the floating point tests requiring common constants to use `FPTest` all at once to the future.  It's not needed for this PR.

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


More information about the libc-commits mailing list