92 changes: 77 additions & 15 deletions libc/test/src/math/smoke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2541,8 +2541,10 @@ add_fp_unittest(
HDRS
NextAfterTest.h
DEPENDS
libc.hdr.fenv_macros
libc.src.math.nextafter
libc.src.__support.FPUtil.basic_operations
libc.src.__support.CPP.bit
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2555,8 +2557,10 @@ add_fp_unittest(
HDRS
NextAfterTest.h
DEPENDS
libc.hdr.fenv_macros
libc.src.math.nextafterf
libc.src.__support.FPUtil.basic_operations
libc.src.__support.CPP.bit
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2569,8 +2573,26 @@ add_fp_unittest(
HDRS
NextAfterTest.h
DEPENDS
libc.hdr.fenv_macros
libc.src.math.nextafterl
libc.src.__support.FPUtil.basic_operations
libc.src.__support.CPP.bit
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
nextafterf16_test
SUITE
libc-math-smoke-tests
SRCS
nextafterf16_test.cpp
HDRS
NextAfterTest.h
DEPENDS
libc.hdr.fenv_macros
libc.src.math.nextafterf16
libc.src.__support.CPP.bit
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2583,8 +2605,10 @@ add_fp_unittest(
HDRS
NextAfterTest.h
DEPENDS
libc.hdr.fenv_macros
libc.src.math.nextafterf128
libc.src.__support.FPUtil.basic_operations
libc.src.__support.CPP.bit
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2599,8 +2623,10 @@ if(NOT LIBC_TARGET_OS_IS_GPU)
HDRS
NextTowardTest.h
DEPENDS
libc.hdr.fenv_macros
libc.src.math.nexttoward
libc.src.__support.FPUtil.basic_operations
libc.src.__support.CPP.bit
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2613,8 +2639,10 @@ if(NOT LIBC_TARGET_OS_IS_GPU)
HDRS
NextTowardTest.h
DEPENDS
libc.hdr.fenv_macros
libc.src.math.nexttowardf
libc.src.__support.FPUtil.basic_operations
libc.src.__support.CPP.bit
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
endif()
Expand All @@ -2628,8 +2656,26 @@ add_fp_unittest(
HDRS
NextTowardTest.h
DEPENDS
libc.hdr.fenv_macros
libc.src.math.nexttowardl
libc.src.__support.FPUtil.basic_operations
libc.src.__support.CPP.bit
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
nexttowardf16_test
SUITE
libc-math-smoke-tests
SRCS
nexttowardf16_test.cpp
HDRS
NextTowardTest.h
DEPENDS
libc.hdr.fenv_macros
libc.src.math.nexttowardf16
libc.src.__support.CPP.bit
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2643,7 +2689,6 @@ add_fp_unittest(
NextDownTest.h
DEPENDS
libc.src.math.nextdown
libc.src.__support.FPUtil.manipulation_functions
)

add_fp_unittest(
Expand All @@ -2656,7 +2701,6 @@ add_fp_unittest(
NextDownTest.h
DEPENDS
libc.src.math.nextdownf
libc.src.__support.FPUtil.manipulation_functions
)

add_fp_unittest(
Expand All @@ -2669,7 +2713,18 @@ add_fp_unittest(
NextDownTest.h
DEPENDS
libc.src.math.nextdownl
libc.src.__support.FPUtil.manipulation_functions
)

add_fp_unittest(
nextdownf16_test
SUITE
libc-math-smoke-tests
SRCS
nextdownf16_test.cpp
HDRS
NextDownTest.h
DEPENDS
libc.src.math.nextdownf16
)

add_fp_unittest(
Expand All @@ -2682,7 +2737,6 @@ add_fp_unittest(
NextDownTest.h
DEPENDS
libc.src.math.nextdownf128
libc.src.__support.FPUtil.manipulation_functions
)

add_fp_unittest(
Expand All @@ -2695,7 +2749,6 @@ add_fp_unittest(
NextUpTest.h
DEPENDS
libc.src.math.nextup
libc.src.__support.FPUtil.manipulation_functions
)

add_fp_unittest(
Expand All @@ -2708,7 +2761,6 @@ add_fp_unittest(
NextUpTest.h
DEPENDS
libc.src.math.nextupf
libc.src.__support.FPUtil.manipulation_functions
)

add_fp_unittest(
Expand All @@ -2721,7 +2773,18 @@ add_fp_unittest(
NextUpTest.h
DEPENDS
libc.src.math.nextupl
libc.src.__support.FPUtil.manipulation_functions
)

add_fp_unittest(
nextupf16_test
SUITE
libc-math-smoke-tests
SRCS
nextupf16_test.cpp
HDRS
NextUpTest.h
DEPENDS
libc.src.math.nextupf16
)

add_fp_unittest(
Expand All @@ -2734,7 +2797,6 @@ add_fp_unittest(
NextUpTest.h
DEPENDS
libc.src.math.nextupf128
libc.src.__support.FPUtil.manipulation_functions
)

# TODO(lntue): The current implementation of fputil::general::fma<float> is only
Expand Down
10 changes: 5 additions & 5 deletions libc/test/src/math/smoke/NextAfterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTAFTERTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_NEXTAFTERTEST_H

#include "hdr/math_macros.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include "hdr/fenv_macros.h"

// TODO: Strengthen errno,exception checks and remove these assert macros
// after new matchers/test fixtures are added
#define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception) \
Expand Down Expand Up @@ -181,7 +181,7 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
result_bits = FPBits(result);
ASSERT_EQ(result_bits.get_biased_exponent(), x_bits.get_biased_exponent());
ASSERT_EQ(result_bits.get_mantissa(),
x_bits.get_mantissa() + StorageType(1));
static_cast<StorageType>(x_bits.get_mantissa() + StorageType(1)));

x = -x;

Expand All @@ -195,7 +195,7 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
result_bits = FPBits(result);
ASSERT_EQ(result_bits.get_biased_exponent(), x_bits.get_biased_exponent());
ASSERT_EQ(result_bits.get_mantissa(),
x_bits.get_mantissa() + StorageType(1));
static_cast<StorageType>(x_bits.get_mantissa() + StorageType(1)));
}
};

Expand Down
11 changes: 5 additions & 6 deletions libc/test/src/math/smoke/NextTowardTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTTOWARDTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_NEXTTOWARDTEST_H

#include "hdr/fenv_macros.h"
#include "hdr/math_macros.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include "hdr/fenv_macros.h"

// TODO: Strengthen errno,exception checks and remove these assert macros
// after new matchers/test fixtures are added
#define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception) \
Expand Down Expand Up @@ -194,7 +193,7 @@ class NextTowardTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
result_bits = FPBits(result);
ASSERT_EQ(result_bits.get_biased_exponent(), x_bits.get_biased_exponent());
ASSERT_EQ(result_bits.get_mantissa(),
x_bits.get_mantissa() + StorageType(1));
static_cast<StorageType>(x_bits.get_mantissa() + StorageType(1)));

x = -x;

Expand All @@ -208,7 +207,7 @@ class NextTowardTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
result_bits = FPBits(result);
ASSERT_EQ(result_bits.get_biased_exponent(), x_bits.get_biased_exponent());
ASSERT_EQ(result_bits.get_mantissa(),
x_bits.get_mantissa() + StorageType(1));
static_cast<StorageType>(x_bits.get_mantissa() + StorageType(1)));
}
};

Expand Down
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/nextafterf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for nextafterf16 ----------------------------------------===//
//
// 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 "NextAfterTest.h"

#include "src/math/nextafterf16.h"

LIST_NEXTAFTER_TESTS(float16, LIBC_NAMESPACE::nextafterf16)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/nextdownf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for nextdownf16 -----------------------------------------===//
//
// 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 "NextDownTest.h"

#include "src/math/nextdownf16.h"

LIST_NEXTDOWN_TESTS(float16, LIBC_NAMESPACE::nextdownf16)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/nexttowardf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for nexttowardf16 ---------------------------------------===//
//
// 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 "NextTowardTest.h"

#include "src/math/nexttowardf16.h"

LIST_NEXTTOWARD_TESTS(float16, LIBC_NAMESPACE::nexttowardf16)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/nextupf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for nextupf16 -------------------------------------------===//
//
// 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 "NextUpTest.h"

#include "src/math/nextupf16.h"

LIST_NEXTUP_TESTS(float16, LIBC_NAMESPACE::nextupf16)