Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 54 additions & 59 deletions libc/test/src/math/smoke/CMakeLists.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libc/test/src/math/smoke/FModTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_FMODTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_FMODTEST_H

#include "hdr/errno_macros.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/libc_errno.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
Expand Down
1 change: 1 addition & 0 deletions libc/test/src/math/smoke/RoundToIntegerTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "src/__support/CPP/algorithm.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/libc_errno.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
Expand Down
3 changes: 0 additions & 3 deletions libc/test/src/math/smoke/atan2f_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@

#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/libc_errno.h"
#include "src/math/atan2f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

using LlvmLibcAtan2fTest = LIBC_NAMESPACE::testing::FPTest<float>;

TEST_F(LlvmLibcAtan2fTest, SpecialNumbers) {
libc_errno = 0;

EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::atan2f(sNaN, sNaN),
FE_INVALID);
EXPECT_MATH_ERRNO(0);
Expand Down
2 changes: 0 additions & 2 deletions libc/test/src/math/smoke/atanf16_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
//
//===----------------------------------------------------------------------===//

#include "src/__support/libc_errno.h"
#include "src/math/atanf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

using LlvmLibcAtanf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;

TEST_F(LlvmLibcAtanf16Test, SpecialNumbers) {
libc_errno = 0;
EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::atanf16(aNaN));
EXPECT_MATH_ERRNO(0);

Expand Down
2 changes: 0 additions & 2 deletions libc/test/src/math/smoke/atanf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/libc_errno.h"
#include "src/math/atanf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
Expand All @@ -18,7 +17,6 @@
using LlvmLibcAtanfTest = LIBC_NAMESPACE::testing::FPTest<float>;

TEST_F(LlvmLibcAtanfTest, SpecialNumbers) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::atanf(sNaN), FE_INVALID);
EXPECT_MATH_ERRNO(0);

Expand Down
3 changes: 1 addition & 2 deletions libc/test/src/math/smoke/atanhf16_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
//
//===----------------------------------------------------------------------===//

#include "hdr/errno_macros.h"
#include "src/__support/FPUtil/cast.h"
#include "src/__support/libc_errno.h"
#include "src/math/atanhf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

using LlvmLibcAtanhf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;

TEST_F(LlvmLibcAtanhf16Test, SpecialNumbers) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanhf16(sNaN),
FE_INVALID);
EXPECT_MATH_ERRNO(0);
Expand Down
3 changes: 1 addition & 2 deletions libc/test/src/math/smoke/atanhf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//

#include "hdr/errno_macros.h"
#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/libc_errno.h"
#include "src/math/atanhf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
Expand All @@ -20,7 +20,6 @@ using LIBC_NAMESPACE::Sign;
using LlvmLibcAtanhfTest = LIBC_NAMESPACE::testing::FPTest<float>;

TEST_F(LlvmLibcAtanhfTest, SpecialNumbers) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::atanhf(sNaN), FE_INVALID);
EXPECT_MATH_ERRNO(0);
// TODO: Strengthen errno,exception checks and remove these assert macros
Expand Down
1 change: 0 additions & 1 deletion libc/test/src/math/smoke/atanpif16_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

#include "src/__support/libc_errno.h"
#include "src/math/atanpif16.h"
#include "test/UnitTest/FPMatcher.h"

Expand Down
4 changes: 1 addition & 3 deletions libc/test/src/math/smoke/cosf16_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
//
//===----------------------------------------------------------------------===//

#include "src/__support/libc_errno.h"
#include "hdr/errno_macros.h"
#include "src/math/cosf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

using LlvmLibcCosf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;

TEST_F(LlvmLibcCosf16Test, SpecialNumbers) {
libc_errno = 0;

EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::cosf16(sNaN), FE_INVALID);
EXPECT_MATH_ERRNO(0);

Expand Down
4 changes: 1 addition & 3 deletions libc/test/src/math/smoke/cosf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@
//
//===----------------------------------------------------------------------===//

#include "hdr/errno_macros.h"
#include "hdr/math_macros.h"
#include "hdr/stdint_proxy.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/libc_errno.h"
#include "src/math/cosf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

using LlvmLibcCosfTest = LIBC_NAMESPACE::testing::FPTest<float>;

TEST_F(LlvmLibcCosfTest, SpecialNumbers) {
libc_errno = 0;

EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::cosf(sNaN), FE_INVALID);
EXPECT_MATH_ERRNO(0);

Expand Down
6 changes: 1 addition & 5 deletions libc/test/src/math/smoke/coshf16_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
//
//===----------------------------------------------------------------------===//

#include "hdr/errno_macros.h"
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
#include "src/__support/libc_errno.h"
#include "src/math/coshf16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

using LlvmLibcCoshf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;

TEST_F(LlvmLibcCoshf16Test, SpecialNumbers) {
libc_errno = 0;

EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::coshf16(aNaN));
EXPECT_MATH_ERRNO(0);

Expand All @@ -40,8 +38,6 @@ TEST_F(LlvmLibcCoshf16Test, SpecialNumbers) {
}

TEST_F(LlvmLibcCoshf16Test, Overflow) {
libc_errno = 0;

EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::coshf16(max_normal),
FE_OVERFLOW | FE_INEXACT);
EXPECT_MATH_ERRNO(ERANGE);
Expand Down
5 changes: 1 addition & 4 deletions libc/test/src/math/smoke/coshf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@
//
//===----------------------------------------------------------------------===//

#include "hdr/errno_macros.h"
#include "hdr/math_macros.h"
#include "hdr/stdint_proxy.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/libc_errno.h"
#include "src/math/coshf.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

using LlvmLibcCoshfTest = LIBC_NAMESPACE::testing::FPTest<float>;

TEST_F(LlvmLibcCoshfTest, SpecialNumbers) {
libc_errno = 0;

EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::coshf(sNaN), FE_INVALID);
EXPECT_MATH_ERRNO(0);

Expand All @@ -40,7 +38,6 @@ TEST_F(LlvmLibcCoshfTest, SpecialNumbers) {
}

TEST_F(LlvmLibcCoshfTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::coshf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
Expand Down
4 changes: 1 addition & 3 deletions libc/test/src/math/smoke/cospif16_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
//
//===----------------------------------------------------------------------===//

#include "hdr/errno_macros.h"
#include "src/__support/FPUtil/cast.h"
#include "src/__support/libc_errno.h"
#include "src/math/cospif16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

using LlvmLibcCospif16Test = LIBC_NAMESPACE::testing::FPTest<float16>;

TEST_F(LlvmLibcCospif16Test, SpecialNumbers) {
libc_errno = 0;

EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::cospif16(sNaN), FE_INVALID);
EXPECT_MATH_ERRNO(0);

Expand Down
4 changes: 1 addition & 3 deletions libc/test/src/math/smoke/cospif_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
//
//===----------------------------------------------------------------------===//

#include "hdr/errno_macros.h"
#include "hdr/stdint_proxy.h"
#include "src/__support/libc_errno.h"
#include "src/math/cospif.h"
#include "test/UnitTest/FPMatcher.h"

using LlvmLibcCospifTest = LIBC_NAMESPACE::testing::FPTest<float>;

TEST_F(LlvmLibcCospifTest, SpecialNumbers) {
libc_errno = 0;

EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::cospif(sNaN), FE_INVALID);
EXPECT_MATH_ERRNO(0);

Expand Down
9 changes: 8 additions & 1 deletion libc/test/src/math/smoke/exp10_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//

#include "hdr/errno_macros.h"
#include "hdr/math_macros.h"
#include "hdr/stdint_proxy.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/libc_errno.h"
#include "src/math/exp10.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
Expand All @@ -21,12 +21,19 @@ TEST_F(LlvmLibcExp10Test, SpecialNumbers) {
EXPECT_MATH_ERRNO(0);

EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::exp10(aNaN));
EXPECT_MATH_ERRNO(0);
EXPECT_FP_EQ(inf, LIBC_NAMESPACE::exp10(inf));
EXPECT_MATH_ERRNO(0);
EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::exp10(neg_inf));
EXPECT_MATH_ERRNO(0);

EXPECT_FP_EQ_WITH_EXCEPTION(zero, LIBC_NAMESPACE::exp10(-0x1.0p20),
FE_UNDERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::exp10(0x1.0p20),
FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);

EXPECT_FP_EQ_ALL_ROUNDING(1.0, LIBC_NAMESPACE::exp10(0.0));
EXPECT_FP_EQ_ALL_ROUNDING(1.0, LIBC_NAMESPACE::exp10(-0.0));

Expand Down
8 changes: 1 addition & 7 deletions libc/test/src/math/smoke/exp10f16_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
//
//===----------------------------------------------------------------------===//

#include "hdr/errno_macros.h"
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
#include "src/__support/libc_errno.h"
#include "src/math/exp10f16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

using LlvmLibcExp10f16Test = LIBC_NAMESPACE::testing::FPTest<float16>;

TEST_F(LlvmLibcExp10f16Test, SpecialNumbers) {
libc_errno = 0;

EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::exp10f16(aNaN));
EXPECT_MATH_ERRNO(0);

Expand All @@ -40,8 +38,6 @@ TEST_F(LlvmLibcExp10f16Test, SpecialNumbers) {
}

TEST_F(LlvmLibcExp10f16Test, Overflow) {
libc_errno = 0;

EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::exp10f16(max_normal),
FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
Expand All @@ -53,8 +49,6 @@ TEST_F(LlvmLibcExp10f16Test, Overflow) {
}

TEST_F(LlvmLibcExp10f16Test, Underflow) {
libc_errno = 0;

EXPECT_FP_EQ_WITH_EXCEPTION(zero, LIBC_NAMESPACE::exp10f16(neg_max_normal),
FE_UNDERFLOW | FE_INEXACT);
EXPECT_MATH_ERRNO(ERANGE);
Expand Down
5 changes: 1 addition & 4 deletions libc/test/src/math/smoke/exp10f_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@
//
//===----------------------------------------------------------------------===//

#include "hdr/errno_macros.h"
#include "hdr/math_macros.h"
#include "hdr/stdint_proxy.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/libc_errno.h"
#include "src/math/exp10f.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

using LlvmLibcExp10fTest = LIBC_NAMESPACE::testing::FPTest<float>;

TEST_F(LlvmLibcExp10fTest, SpecialNumbers) {
libc_errno = 0;

EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::exp10f(sNaN), FE_INVALID);
EXPECT_MATH_ERRNO(0);

Expand All @@ -43,7 +41,6 @@ TEST_F(LlvmLibcExp10fTest, SpecialNumbers) {
}

TEST_F(LlvmLibcExp10fTest, Overflow) {
libc_errno = 0;
EXPECT_FP_EQ_WITH_EXCEPTION(
inf, LIBC_NAMESPACE::exp10f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW);
EXPECT_MATH_ERRNO(ERANGE);
Expand Down
8 changes: 1 addition & 7 deletions libc/test/src/math/smoke/exp10m1f16_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
//
//===----------------------------------------------------------------------===//

#include "hdr/errno_macros.h"
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/cast.h"
#include "src/__support/libc_errno.h"
#include "src/math/exp10m1f16.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

using LlvmLibcExp10m1f16Test = LIBC_NAMESPACE::testing::FPTest<float16>;

TEST_F(LlvmLibcExp10m1f16Test, SpecialNumbers) {
libc_errno = 0;

EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::exp10m1f16(aNaN));
EXPECT_MATH_ERRNO(0);

Expand All @@ -40,8 +38,6 @@ TEST_F(LlvmLibcExp10m1f16Test, SpecialNumbers) {
}

TEST_F(LlvmLibcExp10m1f16Test, Overflow) {
libc_errno = 0;

EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::exp10m1f16(max_normal),
FE_OVERFLOW | FE_INEXACT);
EXPECT_MATH_ERRNO(ERANGE);
Expand All @@ -67,8 +63,6 @@ TEST_F(LlvmLibcExp10m1f16Test, Overflow) {
}

TEST_F(LlvmLibcExp10m1f16Test, ResultNearNegOne) {
libc_errno = 0;

EXPECT_FP_EQ_WITH_EXCEPTION(LIBC_NAMESPACE::fputil::cast<float16>(-1.0),
LIBC_NAMESPACE::exp10m1f16(neg_max_normal),
FE_INEXACT);
Expand Down
Loading
Loading