Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / multiprecision / test / test_unchecked_cpp_int.cpp
index 0e21ac9..addc0ea 100644 (file)
@@ -8,7 +8,7 @@
 //
 
 #ifdef _MSC_VER
-#  define _SCL_SECURE_NO_WARNINGS
+#define _SCL_SECURE_NO_WARNINGS
 #endif
 
 #include <boost/multiprecision/cpp_int.hpp>
 template <class T>
 T generate_random(unsigned bits_wanted)
 {
-   static boost::random::mt19937 gen;
+   static boost::random::mt19937               gen;
    typedef boost::random::mt19937::result_type random_type;
 
-   T max_val;
+   T        max_val;
    unsigned digits;
-   if(std::numeric_limits<T>::is_bounded && (bits_wanted == (unsigned)std::numeric_limits<T>::digits))
+   if (std::numeric_limits<T>::is_bounded && (bits_wanted == (unsigned)std::numeric_limits<T>::digits))
    {
       max_val = (std::numeric_limits<T>::max)();
-      digits = std::numeric_limits<T>::digits;
+      digits  = std::numeric_limits<T>::digits;
    }
    else
    {
       max_val = T(1) << bits_wanted;
-      digits = bits_wanted;
+      digits  = bits_wanted;
    }
 
    unsigned bits_per_r_val = std::numeric_limits<random_type>::digits - 1;
-   while((random_type(1) << bits_per_r_val) > (gen.max)()) --bits_per_r_val;
+   while ((random_type(1) << bits_per_r_val) > (gen.max)())
+      --bits_per_r_val;
 
    unsigned terms_needed = digits / bits_per_r_val + 1;
 
    T val = 0;
-   for(unsigned i = 0; i < terms_needed; ++i)
+   for (unsigned i = 0; i < terms_needed; ++i)
    {
       val *= (gen.max)();
       val += gen();
@@ -50,19 +51,17 @@ T generate_random(unsigned bits_wanted)
    return val;
 }
 
-
 template <class Number>
 void test()
 {
    using namespace boost::multiprecision;
    typedef Number test_type;
 
-
-   for(unsigned i = 30; i < std::numeric_limits<test_type>::digits; ++i)
+   for (unsigned i = 30; i < std::numeric_limits<test_type>::digits; ++i)
    {
-      for(unsigned j = std::numeric_limits<test_type>::digits - i - 1; j < std::numeric_limits<test_type>::digits; ++j)
+      for (unsigned j = std::numeric_limits<test_type>::digits - i - 1; j < std::numeric_limits<test_type>::digits; ++j)
       {
-         for(unsigned k = 0; k < 10; ++k)
+         for (unsigned k = 0; k < 10; ++k)
          {
             test_type a = static_cast<test_type>(generate_random<cpp_int>(i));
             test_type b = static_cast<test_type>(generate_random<cpp_int>(j));
@@ -70,9 +69,9 @@ void test()
             test_type d = a * b;
             BOOST_CHECK_EQUAL(c, d);
 
-            if((k == 0) && (j == 0))
+            if ((k == 0) && (j == 0))
             {
-               for(unsigned s = 1; s < std::numeric_limits<test_type>::digits; ++s)
+               for (unsigned s = 1; s < std::numeric_limits<test_type>::digits; ++s)
                   BOOST_CHECK_EQUAL(a << s, test_type(cpp_int(a) << s));
             }
          }
@@ -96,6 +95,3 @@ int main()
    test<number<cpp_int_backend<48, 48, unsigned_magnitude, unchecked, void> > >();
    return boost::report_errors();
 }
-
-
-