1 //===-- Exhaustive test for sqrtf16 ---------------------------------------===// 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 "src/math/sqrtf16.h" 10 #include "test/UnitTest/FPMatcher.h" 11 #include "test/UnitTest/Test.h" 12 #include "utils/MPFRWrapper/MPFRUtils.h" 13 14 using LlvmLibcSqrtf16Test = LIBC_NAMESPACE::testing::FPTest<float16>; 15 16 namespace mpfr = LIBC_NAMESPACE::testing::mpfr; 17 18 // Range: [0, Inf]; 19 static constexpr uint16_t POS_START = 0x0000U; 20 static constexpr uint16_t POS_STOP = 0x7c00U; 21 TEST_F(LlvmLibcSqrtf16Test,PositiveRange)22TEST_F(LlvmLibcSqrtf16Test, PositiveRange) { 23 for (uint16_t v = POS_START; v <= POS_STOP; ++v) { 24 float16 x = FPBits(v).get_val(); 25 EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sqrt, x, 26 LIBC_NAMESPACE::sqrtf16(x), 0.5); 27 } 28 } 29