[libc-commits] [libc] [libc][math] Add MPFR unit tests for nearbyint{, f, l, f16} (PR #94479)

via libc-commits libc-commits at lists.llvm.org
Thu Jun 27 03:41:34 PDT 2024


================
@@ -0,0 +1,128 @@
+//===-- Utility class to test different flavors of nearbyint ----*- 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_NEARBYINTTEST_H
+#define LLVM_LIBC_TEST_SRC_MATH_NEARBYINTTEST_H
+
+#include "src/__support/CPP/algorithm.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "test/UnitTest/FEnvSafeTest.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+#include "utils/MPFRWrapper/MPFRUtils.h"
+
+#include "hdr/fenv_macros.h"
+
+namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
+
+template <typename T>
+class NearbyIntTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
+
+  DECLARE_SPECIAL_CONSTANTS(T)
+
+  static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD,
----------------
overmighty wrote:

I copied RIntTest.h and did a bit of cleanup but not that much. Will change this.

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


More information about the libc-commits mailing list