1//===-- Unittests for log10 -----------------------------------------------===//
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/math_macros.h"
10#include "src/__support/FPUtil/FPBits.h"
11#include "src/errno/libc_errno.h"
12#include "src/math/log10.h"
13#include "test/UnitTest/FPMatcher.h"
14#include "test/UnitTest/Test.h"
15
16#include <errno.h>
17#include <stdint.h>
18
19using LlvmLibcLog10Test = LIBC_NAMESPACE::testing::FPTest<double>;
20
21TEST_F(LlvmLibcLog10Test, SpecialNumbers) {
22 EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::log10(aNaN));
23 EXPECT_FP_EQ(inf, LIBC_NAMESPACE::log10(inf));
24 EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log10(neg_inf), FE_INVALID);
25 EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log10(0.0),
26 FE_DIVBYZERO);
27 EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log10(-0.0),
28 FE_DIVBYZERO);
29 EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log10(-1.0), FE_INVALID);
30 EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::log10(1.0));
31
32 double x = 1.0;
33 for (int i = 0; i < 11; ++i, x *= 10.0) {
34 EXPECT_FP_EQ_ALL_ROUNDING(static_cast<double>(i), LIBC_NAMESPACE::log10(x));
35 }
36}
37

source code of libc/test/src/math/smoke/log10_test.cpp