brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 13d9a33 Raw
48 lines · cpp
1//===-- Unittests for rsqrtf16 --------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.6//7//===----------------------------------------------------------------------===//8 9#include "hdr/errno_macros.h"10#include "hdr/fenv_macros.h"11#include "src/__support/FPUtil/cast.h"12#include "src/__support/macros/properties/architectures.h"13#include "src/math/rsqrtf16.h"14#include "test/UnitTest/FPMatcher.h"15#include "test/UnitTest/Test.h"16 17using LlvmLibcRsqrtf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;18using LIBC_NAMESPACE::fputil::cast;19 20TEST_F(LlvmLibcRsqrtf16Test, SpecialNumbers) {21  EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::rsqrtf16(aNaN));22  EXPECT_MATH_ERRNO(0);23 24  EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::rsqrtf16(sNaN), FE_INVALID);25  EXPECT_MATH_ERRNO(0);26 27  EXPECT_FP_EQ(inf, LIBC_NAMESPACE::rsqrtf16(zero));28  EXPECT_MATH_ERRNO(ERANGE);29 30  EXPECT_FP_EQ(neg_inf, LIBC_NAMESPACE::rsqrtf16(neg_zero));31  EXPECT_MATH_ERRNO(ERANGE);32 33  EXPECT_FP_EQ(34      LIBC_NAMESPACE::fputil::cast<float16>(1.0f),35      LIBC_NAMESPACE::rsqrtf16(LIBC_NAMESPACE::fputil::cast<float16>(1.0f)));36  EXPECT_MATH_ERRNO(0);37 38  EXPECT_FP_EQ(zero, LIBC_NAMESPACE::rsqrtf16(inf));39  EXPECT_MATH_ERRNO(0);40 41  EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::rsqrtf16(neg_inf));42  EXPECT_MATH_ERRNO(EDOM);43 44  EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::rsqrtf16(45                         LIBC_NAMESPACE::fputil::cast<float16>(-2.0f)));46  EXPECT_MATH_ERRNO(EDOM);47}48