]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/ccmath_floor_test.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / test / ccmath_floor_test.cpp
1 // (C) Copyright Matt Borland 2021.
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/floor.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 if constexpr (std::numeric_limits<T>::has_quiet_NaN)
23 {
24 static_assert(boost::math::ccmath::isnan(boost::math::ccmath::floor(std::numeric_limits<T>::quiet_NaN())), "If x is NaN, NaN is returned");
25 }
26
27 static_assert(!boost::math::ccmath::floor(T(0)), "If x is +- 0, it is returned, unmodified");
28 static_assert(!boost::math::ccmath::floor(T(-0)), "If x is +- 0, it is returned, unmodified");
29
30 static_assert(boost::math::ccmath::isinf(boost::math::ccmath::floor(std::numeric_limits<T>::infinity())),
31 "If x is +- inf, it is returned, unmodified");
32 static_assert(boost::math::ccmath::isinf(boost::math::ccmath::floor(-std::numeric_limits<T>::infinity())),
33 "If x is +- inf, it is returned, unmodified");
34
35 static_assert(boost::math::ccmath::floor(T(2)) == T(2));
36 static_assert(boost::math::ccmath::floor(T(2.4)) == T(2));
37 static_assert(boost::math::ccmath::floor(T(2.9)) == T(2));
38 static_assert(boost::math::ccmath::floor(T(-2.7)) == T(-3));
39 static_assert(boost::math::ccmath::floor(T(-2)) == T(-2));
40 }
41
42 #if !defined(BOOST_MATH_NO_CONSTEXPR_DETECTION) && !defined(BOOST_MATH_USING_BUILTIN_CONSTANT_P)
43 int main()
44 {
45 test<float>();
46 test<double>();
47
48 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
49 test<long double>();
50 #endif
51
52 #ifdef BOOST_HAS_FLOAT128
53 test<boost::multiprecision::float128>();
54 #endif
55
56 return 0;
57 }
58 #else
59 int main()
60 {
61 return 0;
62 }
63 #endif