]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/multiprecision/test/test_convert_from_mpfi_float.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / multiprecision / test / test_convert_from_mpfi_float.cpp
index e2e664db2cbabf4d88bab5e766fa0160741cfa6a..b7a24585b975b3fdb916697cd59e9529a3ac301a 100644 (file)
@@ -1,10 +1,10 @@
 ///////////////////////////////////////////////////////////////
 //  Copyright 2012 John Maddock. Distributed under the Boost
 //  Software License, Version 1.0. (See accompanying file
-//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
+//  LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
 
 #ifdef _MSC_VER
-#  define _SCL_SECURE_NO_WARNINGS
+#define _SCL_SECURE_NO_WARNINGS
 #endif
 
 #if defined(HAS_MPFI)
 #include <boost/multiprecision/cpp_bin_float.hpp>
 #include <boost/multiprecision/cpp_dec_float.hpp>
 
-
 using namespace boost::multiprecision;
 
 #ifdef BOOST_MSVC
-#pragma warning(disable:4127)
+#pragma warning(disable : 4127)
 #endif
 
-
 template <class T>
 T generate_random()
 {
-   typedef int e_type;
+   typedef int                   e_type;
    static boost::random::mt19937 gen;
-   T val = gen();
-   T prev_val = -1;
-   int digits_so_far = 0;
-   while(digits_so_far < std::numeric_limits<T>::digits)
+   T                             val           = gen();
+   T                             prev_val      = -1;
+   int                           digits_so_far = 0;
+   while (digits_so_far < std::numeric_limits<T>::digits)
    {
       val *= (gen.max)();
       prev_val = val;
@@ -79,14 +77,14 @@ void test_convert_neg_int(From const&, const boost::mpl::false_&)
 template <class From, class To>
 void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_integer> const&)
 {
-   for(unsigned i = 0; i < 100; ++i)
+   for (unsigned i = 0; i < 100; ++i)
    {
       From from = generate_random<From>();
-      To t1(from);
-      To t2 = from.template convert_to<To>();
+      To   t1(from);
+      To   t2 = from.template convert_to<To>();
       BOOST_CHECK_EQUAL(From(trunc(from)), From(t1));
       BOOST_CHECK_EQUAL(From(trunc(from)), From(t2));
-      test_convert_neg_int<From, To>(from, boost::mpl::bool_<std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed>());
+      test_convert_neg_int<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
    }
 }
 
@@ -107,14 +105,14 @@ void test_convert_rat_int(From const&, const boost::mpl::false_&)
 template <class From, class To>
 void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_rational> const&)
 {
-   for(unsigned i = 0; i < 100; ++i)
+   for (unsigned i = 0; i < 100; ++i)
    {
       From from = generate_random<From>();
-      To t1(from);
-      To t2 = from.template convert_to<To>();
+      To   t1(from);
+      To   t2 = from.template convert_to<To>();
       BOOST_CHECK_EQUAL(From(t1), median(from));
       BOOST_CHECK_EQUAL(From(t2), median(from));
-      test_convert_neg_rat<From, To>(from, boost::mpl::bool_<std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed>());
+      test_convert_neg_rat<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
    }
 }
 
@@ -137,16 +135,16 @@ void test_convert_neg_float(From const&, const boost::mpl::false_&)
 template <class From, class To>
 void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_floating_point> const&)
 {
-   for(unsigned i = 0; i < 100; ++i)
+   for (unsigned i = 0; i < 100; ++i)
    {
       From from = generate_random<From>();
-      To t1(from);
-      To t2 = from.template convert_to<To>();
-      To answer(median(from).str());
-      To tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2;
+      To   t1(from);
+      To   t2 = from.template convert_to<To>();
+      To   answer(median(from).str());
+      To   tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2;
       BOOST_CHECK_CLOSE_FRACTION(t1, answer, tol);
       BOOST_CHECK_CLOSE_FRACTION(t2, answer, tol);
-      test_convert_neg_float<From, To>(from, boost::mpl::bool_<std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed>());
+      test_convert_neg_float<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
    }
 }
 
@@ -156,15 +154,14 @@ void test_convert()
    test_convert_imp<From, To>(typename number_category<From>::type(), typename number_category<To>::type());
 }
 
-
 int main()
 {
-   try {
+   try
+   {
       test_convert<mpfi_float_50, cpp_int>();
       test_convert<mpfi_float_50, int128_t>();
       test_convert<mpfi_float_50, uint128_t>();
 
-
       test_convert<mpfi_float_50, cpp_rational>();
 
       test_convert<mpfi_float_50, cpp_dec_float_50>();
@@ -185,7 +182,7 @@ int main()
       test_convert<mpfi_float_50, float128>();
 #endif
    }
-   catch(...)
+   catch (...)
    {
       return 1;
    }