aboutsummaryrefslogtreecommitdiff
path: root/libc/test
diff options
context:
space:
mode:
authorOverMighty <its.overmighty@gmail.com>2024-06-05 16:37:55 +0200
committerGitHub <noreply@github.com>2024-06-05 10:37:55 -0400
commitc537f3564684662748f76cccc325287cb0f54cbd (patch)
tree9078594616df8f568b3c94b89b7f9b640ede1af8 /libc/test
parent07b8990d38ebaf42b0ed1c60d49b484a6e2497e8 (diff)
downloadllvm-c537f3564684662748f76cccc325287cb0f54cbd.zip
llvm-c537f3564684662748f76cccc325287cb0f54cbd.tar.gz
llvm-c537f3564684662748f76cccc325287cb0f54cbd.tar.bz2
[libc][math][c23] Add fdimf16 C23 math function (#94354)
#93566
Diffstat (limited to 'libc/test')
-rw-r--r--libc/test/src/math/smoke/CMakeLists.txt22
-rw-r--r--libc/test/src/math/smoke/FDimTest.h11
-rw-r--r--libc/test/src/math/smoke/fdimf16_test.cpp13
3 files changed, 37 insertions, 9 deletions
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 6b70d89..09e54349 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -1635,7 +1635,7 @@ add_fp_unittest(
FDimTest.h
DEPENDS
libc.src.math.fdimf
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)
@@ -1649,7 +1649,7 @@ add_fp_unittest(
FDimTest.h
DEPENDS
libc.src.math.fdim
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)
@@ -1663,7 +1663,21 @@ add_fp_unittest(
FDimTest.h
DEPENDS
libc.src.math.fdiml
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fp_bits
+)
+
+add_fp_unittest(
+ fdimf16_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ fdimf16_test.cpp
+ HDRS
+ FDimTest.h
+ DEPENDS
+ libc.src.math.fdimf16
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)
@@ -1677,7 +1691,7 @@ add_fp_unittest(
FDimTest.h
DEPENDS
libc.src.math.fdimf128
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)
diff --git a/libc/test/src/math/smoke/FDimTest.h b/libc/test/src/math/smoke/FDimTest.h
index cff88f2..cc0ce3b 100644
--- a/libc/test/src/math/smoke/FDimTest.h
+++ b/libc/test/src/math/smoke/FDimTest.h
@@ -6,7 +6,7 @@
//
//===---------------------------------------------------------------------===//
-#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/CPP/algorithm.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
@@ -61,10 +61,11 @@ public:
void test_in_range(FuncPtr func) {
constexpr StorageType STORAGE_MAX =
LIBC_NAMESPACE::cpp::numeric_limits<StorageType>::max();
- constexpr StorageType COUNT = 100'001;
- constexpr StorageType STEP = STORAGE_MAX / COUNT;
- for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT;
- ++i, v += STEP, w -= STEP) {
+ constexpr int COUNT = 100'001;
+ constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max(
+ static_cast<StorageType>(STORAGE_MAX / COUNT), StorageType(1));
+ StorageType v = 0, w = STORAGE_MAX;
+ for (int i = 0; i <= COUNT; ++i, v += STEP, w -= STEP) {
FPBits xbits(v), ybits(w);
if (xbits.is_inf_or_nan())
continue;
diff --git a/libc/test/src/math/smoke/fdimf16_test.cpp b/libc/test/src/math/smoke/fdimf16_test.cpp
new file mode 100644
index 0000000..f40fab3
--- /dev/null
+++ b/libc/test/src/math/smoke/fdimf16_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for fdimf16 ---------------------------------------------===//
+//
+// 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 "FDimTest.h"
+
+#include "src/math/fdimf16.h"
+
+LIST_FDIM_TESTS(float16, LIBC_NAMESPACE::fdimf16);