// or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifdef _MSC_VER
-# define _SCL_SECURE_NO_WARNINGS
+#define _SCL_SECURE_NO_WARNINGS
#endif
#if !defined(TEST_MPZ) && !defined(TEST_TOMMATH) && !defined(TEST_CPP_INT)
-# define TEST_TOMMATH
-# define TEST_MPZ
-# define TEST_CPP_INT
+#define TEST_TOMMATH
+#define TEST_MPZ
+#define TEST_CPP_INT
#ifdef _MSC_VER
#pragma message("CAUTION!!: No backend type specified so testing everything.... this will take some time!!")
#include <iomanip>
#ifdef BOOST_MSVC
-#pragma warning(disable:4127)
+#pragma warning(disable : 4127)
#endif
template <class T>
-struct unchecked_type{ typedef T type; };
+struct unchecked_type
+{
+ typedef T type;
+};
#ifdef TEST_CPP_INT
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
static const unsigned limbs = std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::is_bounded ? std::numeric_limits<T>::digits / std::numeric_limits<unsigned>::digits + 3 : 20;
static boost::random::uniform_int_distribution<unsigned> ui(0, limbs);
- static boost::random::mt19937 gen;
- unchecked_T val = gen();
- unsigned lim = ui(gen);
- for(unsigned i = 0; i < lim; ++i)
+ static boost::random::mt19937 gen;
+ unchecked_T val = gen();
+ unsigned lim = ui(gen);
+ for (unsigned i = 0; i < lim; ++i)
{
val *= (gen.max)();
val += gen();
void do_round_trip(const T& val)
{
do_round_trip(val, std::ios_base::fmtflags(0));
- if(val >= 0)
+ if (val >= 0)
{
- do_round_trip(val, std::ios_base::fmtflags(std::ios_base::showbase|std::ios_base::hex));
- do_round_trip(val, std::ios_base::fmtflags(std::ios_base::showbase|std::ios_base::oct));
+ do_round_trip(val, std::ios_base::fmtflags(std::ios_base::showbase | std::ios_base::hex));
+ do_round_trip(val, std::ios_base::fmtflags(std::ios_base::showbase | std::ios_base::oct));
}
}
void negative_spots(const boost::mpl::true_&)
{
BOOST_CHECK_EQUAL(T(-1002).str(), "-1002");
- if(!std::numeric_limits<T>::is_modulo)
+ if (!std::numeric_limits<T>::is_modulo)
{
#ifndef BOOST_NO_EXCEPTIONS
BOOST_CHECK_THROW(T(-2).str(0, std::ios_base::oct), std::runtime_error);
template <class T>
void test_round_trip()
{
- for(unsigned i = 0; i < 1000; ++i)
+ for (unsigned i = 0; i < 1000; ++i)
{
T val = generate_random<T>();
do_round_trip(val);
BOOST_CHECK_EQUAL(T(1002).str(), "1002");
BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::showpos), "+1002");
BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::oct), "1752");
- BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::oct|std::ios_base::showbase), "01752");
+ BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::oct | std::ios_base::showbase), "01752");
BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::hex), "3ea");
- BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::hex|std::ios_base::showbase), "0x3ea");
- BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::hex|std::ios_base::uppercase), "3EA");
- BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::hex|std::ios_base::showbase|std::ios_base::uppercase), "0X3EA");
+ BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::hex | std::ios_base::showbase), "0x3ea");
+ BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::hex | std::ios_base::uppercase), "3EA");
+ BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::hex | std::ios_base::showbase | std::ios_base::uppercase), "0X3EA");
BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::dec), "1002");
- BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::dec|std::ios_base::showbase), "1002");
+ BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::dec | std::ios_base::showbase), "1002");
negative_spots<T>(boost::mpl::bool_<std::numeric_limits<T>::is_signed>());
}
#ifdef TEST_CPP_INT
test_round_trip<boost::multiprecision::cpp_int>();
test_round_trip<boost::multiprecision::checked_int1024_t>();
- test_round_trip<boost::multiprecision::checked_uint512_t >();
+ test_round_trip<boost::multiprecision::checked_uint512_t>();
test_round_trip<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<32, 32, boost::multiprecision::signed_magnitude, boost::multiprecision::checked, void> > >();
test_round_trip<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<32, 32, boost::multiprecision::unsigned_magnitude, boost::multiprecision::checked, void> > >();
#endif
return boost::report_errors();
}
-