]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/ccmath_fdim_test.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / test / ccmath_fdim_test.cpp
1 // (C) Copyright Matt Borland 2022.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #include <cmath>
7 #include <cfloat>
8 #include <cstdint>
9 #include <limits>
10 #include <type_traits>
11 #include <boost/math/ccmath/fdim.hpp>
12 #include <boost/math/ccmath/isnan.hpp>
13 #include <boost/math/ccmath/isinf.hpp>
14
15 #ifdef BOOST_HAS_FLOAT128
16 #include <boost/multiprecision/float128.hpp>
17 #endif
18
19 template <typename T>
20 constexpr void test()
21 {
22 static_assert(boost::math::ccmath::isnan(boost::math::ccmath::fdim(std::numeric_limits<T>::quiet_NaN(), T(1))), "If x is NaN, NaN is returned");
23 static_assert(boost::math::ccmath::isnan(boost::math::ccmath::fdim(T(1), std::numeric_limits<T>::quiet_NaN())), "If y is NaN, NaN is returned");
24
25 static_assert(boost::math::ccmath::fdim(T(4), T(1)) == T(3));
26 static_assert(boost::math::ccmath::fdim(T(1), T(4)) == T(0));
27 static_assert(boost::math::ccmath::fdim(T(4), T(-1)) == T(5));
28 static_assert(boost::math::ccmath::fdim(T(1), T(-4)) == T(5));
29
30 static_assert(boost::math::ccmath::isinf(boost::math::ccmath::fdim(std::numeric_limits<T>::infinity(), T(-1))));
31 }
32
33 #if !defined(BOOST_MATH_NO_CONSTEXPR_DETECTION) && !defined(BOOST_MATH_USING_BUILTIN_CONSTANT_P)
34 int main()
35 {
36 test<float>();
37 test<double>();
38
39 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
40 test<long double>();
41 #endif
42
43 #ifdef BOOST_HAS_FLOAT128
44 test<boost::multiprecision::float128>();
45 #endif
46
47 return 0;
48 }
49 #else
50 int main()
51 {
52 return 0;
53 }
54 #endif