From a5ac1fbd4ad1fc07b33dbb8809d9366f1d20f823 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sun, 4 Mar 2018 17:53:38 +0000 Subject: [PATCH] Complex: mpc.hpp now compiles and passes test_arithmetic.hpp. Disabled relational operators for complex types. --- .../multiprecision/detail/number_compare.hpp | 52 +-- include/boost/multiprecision/mpc.hpp | 10 +- test/test_arithmetic.hpp | 335 ++++++++++++------ 3 files changed, 251 insertions(+), 146 deletions(-) diff --git a/include/boost/multiprecision/detail/number_compare.hpp b/include/boost/multiprecision/detail/number_compare.hpp index adf03426..0c961848 100644 --- a/include/boost/multiprecision/detail/number_compare.hpp +++ b/include/boost/multiprecision/detail/number_compare.hpp @@ -258,14 +258,15 @@ inline typename enable_if -inline bool operator < (const number& a, const number& b) +inline typename boost::enable_if_c<(number_category::value != number_kind_complex) && (number_category::value != number_kind_complex), bool>::type + operator < (const number& a, const number& b) { using default_ops::eval_lt; if(detail::is_unordered_comparison(a, b)) return false; return eval_lt(a.backend(), b.backend()); } template -inline typename enable_if_c, Arithmetic>::value, bool>::type +inline typename enable_if_c, Arithmetic>::value && (number_category::value != number_kind_complex), bool>::type operator < (const number& a, const Arithmetic& b) { using default_ops::eval_lt; @@ -273,7 +274,7 @@ inline typename enable_if_c::canonical_value(b)); } template -inline typename enable_if_c, Arithmetic>::value, bool>::type +inline typename enable_if_c, Arithmetic>::value && (number_category::value != number_kind_complex), bool>::type operator < (const Arithmetic& a, const number& b) { using default_ops::eval_gt; @@ -281,7 +282,7 @@ inline typename enable_if_c::canonical_value(a)); } template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type +inline typename enable_if_c::result_type, Arithmetic>::value && (number_category::result_type>::value != number_kind_complex), bool>::type operator < (const Arithmetic& a, const detail::expression& b) { typedef typename detail::expression::result_type result_type; @@ -291,7 +292,7 @@ inline typename enable_if_c -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type +inline typename enable_if_c::result_type, Arithmetic>::value && (number_category::result_type>::value != number_kind_complex), bool>::type operator < (const detail::expression& a, const Arithmetic& b) { typedef typename detail::expression::result_type result_type; @@ -301,7 +302,7 @@ inline typename enable_if_c -inline typename enable_if::result_type, typename detail::expression::result_type>, bool>::type +inline typename enable_if_c::result_type, typename detail::expression::result_type>::value && (number_category::result_type>::value != number_kind_complex), bool>::type operator < (const detail::expression& a, const detail::expression& b) { using default_ops::eval_lt; @@ -312,14 +313,15 @@ inline typename enable_if -inline bool operator > (const number& a, const number& b) +inline typename boost::enable_if_c<(number_category::value != number_kind_complex) && (number_category::value != number_kind_complex), bool>::type + operator > (const number& a, const number& b) { using default_ops::eval_gt; if(detail::is_unordered_comparison(a, b)) return false; return eval_gt(a.backend(), b.backend()); } template -inline typename enable_if_c, Arithmetic>::value, bool>::type +inline typename enable_if_c, Arithmetic>::value && (number_category::value != number_kind_complex), bool>::type operator > (const number& a, const Arithmetic& b) { using default_ops::eval_gt; @@ -327,7 +329,7 @@ inline typename enable_if_c::canonical_value(b)); } template -inline typename enable_if_c, Arithmetic>::value, bool>::type +inline typename enable_if_c, Arithmetic>::value && (number_category::value != number_kind_complex), bool>::type operator > (const Arithmetic& a, const number& b) { using default_ops::eval_lt; @@ -335,7 +337,7 @@ inline typename enable_if_c::canonical_value(a)); } template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type +inline typename enable_if_c::result_type, Arithmetic>::value && (number_category::result_type>::value != number_kind_complex), bool>::type operator > (const Arithmetic& a, const detail::expression& b) { typedef typename detail::expression::result_type result_type; @@ -345,7 +347,7 @@ inline typename enable_if_c t; } template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type +inline typename enable_if_c::result_type, Arithmetic>::value && (number_category::result_type>::value != number_kind_complex), bool>::type operator > (const detail::expression& a, const Arithmetic& b) { typedef typename detail::expression::result_type result_type; @@ -355,7 +357,7 @@ inline typename enable_if_c b; } template -inline typename enable_if::result_type, typename detail::expression::result_type>, bool>::type +inline typename enable_if_c::result_type, typename detail::expression::result_type>::value && (number_category::result_type>::value != number_kind_complex), bool>::type operator > (const detail::expression& a, const detail::expression& b) { using default_ops::eval_gt; @@ -366,14 +368,15 @@ inline typename enable_if -inline bool operator <= (const number& a, const number& b) +inline typename boost::enable_if_c<(number_category::value != number_kind_complex) && (number_category::value != number_kind_complex), bool>::type + operator <= (const number& a, const number& b) { using default_ops::eval_gt; if(detail::is_unordered_comparison(a, b)) return false; return !eval_gt(a.backend(), b.backend()); } template -inline typename enable_if_c, Arithmetic>::value, bool>::type +inline typename enable_if_c, Arithmetic>::value && (number_category::value != number_kind_complex), bool>::type operator <= (const number& a, const Arithmetic& b) { using default_ops::eval_gt; @@ -381,7 +384,7 @@ inline typename enable_if_c::canonical_value(b)); } template -inline typename enable_if_c, Arithmetic>::value, bool>::type +inline typename enable_if_c, Arithmetic>::value && (number_category::value != number_kind_complex), bool>::type operator <= (const Arithmetic& a, const number& b) { using default_ops::eval_lt; @@ -389,7 +392,7 @@ inline typename enable_if_c::canonical_value(a)); } template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type +inline typename enable_if_c::result_type, Arithmetic>::value && (number_category::result_type>::value != number_kind_complex), bool>::type operator <= (const Arithmetic& a, const detail::expression& b) { typedef typename detail::expression::result_type result_type; @@ -401,7 +404,7 @@ inline typename enable_if_c -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type +inline typename enable_if_c::result_type, Arithmetic>::value && (number_category::result_type>::value != number_kind_complex), bool>::type operator <= (const detail::expression& a, const Arithmetic& b) { typedef typename detail::expression::result_type result_type; @@ -411,7 +414,7 @@ inline typename enable_if_c -inline typename enable_if::result_type, typename detail::expression::result_type>, bool>::type +inline typename enable_if_c::result_type, typename detail::expression::result_type>::value && (number_category::result_type>::value != number_kind_complex), bool>::type operator <= (const detail::expression& a, const detail::expression& b) { using default_ops::eval_gt; @@ -422,14 +425,15 @@ inline typename enable_if -inline bool operator >= (const number& a, const number& b) +inline typename boost::enable_if_c<(number_category::value != number_kind_complex) && (number_category::value != number_kind_complex), bool>::type + operator >= (const number& a, const number& b) { using default_ops::eval_lt; if(detail::is_unordered_comparison(a, b)) return false; return !eval_lt(a.backend(), b.backend()); } template -inline typename enable_if_c, Arithmetic>::value, bool>::type +inline typename enable_if_c, Arithmetic>::value && (number_category::value != number_kind_complex), bool>::type operator >= (const number& a, const Arithmetic& b) { using default_ops::eval_lt; @@ -437,7 +441,7 @@ inline typename enable_if_c::canonical_value(b)); } template -inline typename enable_if_c, Arithmetic>::value, bool>::type +inline typename enable_if_c, Arithmetic>::value && (number_category::value != number_kind_complex), bool>::type operator >= (const Arithmetic& a, const number& b) { using default_ops::eval_gt; @@ -445,7 +449,7 @@ inline typename enable_if_c::canonical_value(a)); } template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type +inline typename enable_if_c::result_type, Arithmetic>::value && (number_category::result_type>::value != number_kind_complex), bool>::type operator >= (const Arithmetic& a, const detail::expression& b) { typedef typename detail::expression::result_type result_type; @@ -455,7 +459,7 @@ inline typename enable_if_c -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type +inline typename enable_if_c::result_type, Arithmetic>::value && (number_category::result_type>::value != number_kind_complex), bool>::type operator >= (const detail::expression& a, const Arithmetic& b) { typedef typename detail::expression::result_type result_type; @@ -465,7 +469,7 @@ inline typename enable_if_c -inline typename enable_if::result_type, typename detail::expression::result_type>, bool>::type +inline typename enable_if_c::result_type, typename detail::expression::result_type>::value && (number_category::result_type>::value != number_kind_complex), bool>::type operator >= (const detail::expression& a, const detail::expression& b) { using default_ops::eval_lt; diff --git a/include/boost/multiprecision/mpc.hpp b/include/boost/multiprecision/mpc.hpp index 2c17013a..99e45d68 100644 --- a/include/boost/multiprecision/mpc.hpp +++ b/include/boost/multiprecision/mpc.hpp @@ -177,12 +177,12 @@ struct mpc_float_imp if(m_data[0].re[0]._mpfr_d == 0) mpc_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision())); - if(s && (*s == '{')) + if(s && (*s == '(')) { mpfr_float_backend a, b; std::string part; const char* p = ++s; - while(*p && (*p != ',') && (*p != '}')) + while(*p && (*p != ',') && (*p != ')')) ++p; part.assign(s + 1, p); a = part.c_str(); @@ -190,7 +190,7 @@ struct mpc_float_imp if(*p && (*p != '}')) { ++p; - while(*p && (*p != ',') && (*p != '}')) + while(*p && (*p != ',') && (*p != ')')) ++p; part.assign(s + 1, p); } @@ -230,10 +230,10 @@ struct mpc_float_imp mpc_real(a.data(), m_data, GMP_RNDD); mpc_imag(b.data(), m_data, GMP_RNDD); - if(a.compare(b) == 0) + if(eval_is_zero(b)) return a.str(digits, f); - return "{" + a.str(digits, f) + "," + b.str(digits, f) + "}"; + return "(" + a.str(digits, f) + "," + b.str(digits, f) + ")"; } ~mpc_float_imp() BOOST_NOEXCEPT { diff --git a/test/test_arithmetic.hpp b/test/test_arithmetic.hpp index 28afc4ab..f4832b5e 100644 --- a/test/test_arithmetic.hpp +++ b/test/test_arithmetic.hpp @@ -77,7 +77,8 @@ int normalize_compare_result(int r) } template -void test_comparisons(Val a, Val b, const boost::mpl::true_) +typename boost::disable_if_c::value == boost::multiprecision::number_kind_complex>::type + test_comparisons(Val a, Val b, const boost::mpl::true_) { Real r1(a); Real r2(b); @@ -147,6 +148,56 @@ void test_comparisons(Val a, Val b, const boost::mpl::true_) BOOST_CHECK_EQUAL(normalize_compare_result(r2.compare(a)), -cr); } +template +typename boost::enable_if_c::value == boost::multiprecision::number_kind_complex>::type + test_comparisons(Val a, Val b, const boost::mpl::true_) +{ + Real r1(a); + Real r2(b); + Real z(1); + + int cr = a < b ? -1 : a > b ? 1 : 0; + + BOOST_CHECK_EQUAL(r1 == r2, a == b); + BOOST_CHECK_EQUAL(r1 != r2, a != b); + + BOOST_CHECK_EQUAL(r1 == b, a == b); + BOOST_CHECK_EQUAL(r1 != b, a != b); + + BOOST_CHECK_EQUAL(a == r2, a == b); + BOOST_CHECK_EQUAL(a != r2, a != b); + + BOOST_CHECK_EQUAL(r1*z == r2, a == b); + BOOST_CHECK_EQUAL(r1*z != r2, a != b); + + BOOST_CHECK_EQUAL(r1 == r2 * z, a == b); + BOOST_CHECK_EQUAL(r1 != r2 * z, a != b); + + BOOST_CHECK_EQUAL(r1*z == r2 * z, a == b); + BOOST_CHECK_EQUAL(r1*z != r2 * z, a != b); + + BOOST_CHECK_EQUAL(r1*z == b, a == b); + BOOST_CHECK_EQUAL(r1*z != b, a != b); + + BOOST_CHECK_EQUAL(a == r2 * z, a == b); + BOOST_CHECK_EQUAL(a != r2 * z, a != b); + + if (r1 == r2) + { + BOOST_CHECK_EQUAL(normalize_compare_result(r1.compare(r2)), 0); + BOOST_CHECK_EQUAL(normalize_compare_result(r2.compare(r1)), 0); + BOOST_CHECK_EQUAL(normalize_compare_result(r1.compare(b)), 0); + BOOST_CHECK_EQUAL(normalize_compare_result(r2.compare(a)), 0); + } + else + { + BOOST_CHECK_NE(normalize_compare_result(r1.compare(r2)), 0); + BOOST_CHECK_NE(normalize_compare_result(r2.compare(r1)), 0); + BOOST_CHECK_NE(normalize_compare_result(r1.compare(b)), 0); + BOOST_CHECK_NE(normalize_compare_result(r2.compare(a)), 0); + } +} + template void test_conditional(Real v, Exp e) { @@ -1648,6 +1699,29 @@ inline Real negate_value(const Real& val, const boost::mpl::false_&) return val; } +template +void test_mixed_numeric_limits(const boost::mpl::true_&) +{ + if (std::numeric_limits::has_infinity && std::numeric_limits::has_infinity) + { + d = static_cast(std::numeric_limits::infinity()); + BOOST_CHECK_GT(d, (std::numeric_limits::max)()); + d = static_cast(negate_value(std::numeric_limits::infinity(), boost::mpl::bool_::is_signed>())); + BOOST_CHECK_LT(d, negate_value((std::numeric_limits::max)(), boost::mpl::bool_::is_signed>())); + } + if (std::numeric_limits::has_quiet_NaN && std::numeric_limits::has_quiet_NaN) + { + d = static_cast(std::numeric_limits::quiet_NaN()); + BOOST_CHECK(check_is_nan(d, boost::mpl::bool_::has_quiet_NaN>())); + d = static_cast(negate_value(std::numeric_limits::quiet_NaN(), boost::mpl::bool_::is_signed>())); + BOOST_CHECK(check_is_nan(d, boost::mpl::bool_::has_quiet_NaN>())); + } +} +template +void test_mixed_numeric_limits(const boost::mpl::false_&) +{ +} + template void test_mixed(const boost::mpl::true_&) { @@ -1850,20 +1924,7 @@ void test_mixed(const boost::mpl::true_&) d = b * static_cast(n3) - static_cast(n1); BOOST_CHECK_EQUAL(d , 3 * 4 - 2); - if(std::numeric_limits::has_infinity && std::numeric_limits::has_infinity) - { - d = static_cast(std::numeric_limits::infinity()); - BOOST_CHECK_GT(d, (std::numeric_limits::max)()); - d = static_cast(negate_value(std::numeric_limits::infinity(), boost::mpl::bool_::is_signed>())); - BOOST_CHECK_LT(d, negate_value((std::numeric_limits::max)(), boost::mpl::bool_::is_signed>())); - } - if(std::numeric_limits::has_quiet_NaN && std::numeric_limits::has_quiet_NaN) - { - d = static_cast(std::numeric_limits::quiet_NaN()); - BOOST_CHECK(check_is_nan(d, boost::mpl::bool_::has_quiet_NaN>())); - d = static_cast(negate_value(std::numeric_limits::quiet_NaN(), boost::mpl::bool_::is_signed>())); - BOOST_CHECK(check_is_nan(d, boost::mpl::bool_::has_quiet_NaN>())); - } + test_mixed_numeric_limits(boost::mpl::bool_::is_specialized>()); } template @@ -2007,6 +2068,147 @@ void test_basic_conditionals(Real a, Real b) } } +template +typename boost::enable_if_c::value == boost::multiprecision::number_kind_complex>::type + test_relationals(T a, T b) +{ + BOOST_CHECK_EQUAL((a == b), false); + BOOST_CHECK_EQUAL((a != b), true); + + BOOST_CHECK_EQUAL((a + b == b), false); + BOOST_CHECK_EQUAL((a + b != b), true); + + BOOST_CHECK_EQUAL((a == b + a), false); + BOOST_CHECK_EQUAL((a != b + a), true); + + BOOST_CHECK_EQUAL((a + b == b + a), true); + BOOST_CHECK_EQUAL((a + b != b + a), false); + + BOOST_CHECK_EQUAL((8 == b + a), false); + BOOST_CHECK_EQUAL((8 != b + a), true); + BOOST_CHECK_EQUAL((800 == b + a), false); + BOOST_CHECK_EQUAL((800 != b + a), true); + BOOST_CHECK_EQUAL((72 == b + a), true); + BOOST_CHECK_EQUAL((72 != b + a), false); + + BOOST_CHECK_EQUAL((b + a == 8), false); + BOOST_CHECK_EQUAL((b + a != 8), true); + BOOST_CHECK_EQUAL((b + a == 800), false); + BOOST_CHECK_EQUAL((b + a != 800), true); + BOOST_CHECK_EQUAL((b + a == 72), true); + BOOST_CHECK_EQUAL((b + a != 72), false); +} + +template +typename boost::disable_if_c::value == boost::multiprecision::number_kind_complex>::type +test_relationals(T a, T b) +{ + BOOST_CHECK_EQUAL((a == b), false); + BOOST_CHECK_EQUAL((a != b), true); + BOOST_CHECK_EQUAL((a <= b), true); + BOOST_CHECK_EQUAL((a < b), true); + BOOST_CHECK_EQUAL((a >= b), false); + BOOST_CHECK_EQUAL((a > b), false); + + BOOST_CHECK_EQUAL((a + b == b), false); + BOOST_CHECK_EQUAL((a + b != b), true); + BOOST_CHECK_EQUAL((a + b >= b), true); + BOOST_CHECK_EQUAL((a + b > b), true); + BOOST_CHECK_EQUAL((a + b <= b), false); + BOOST_CHECK_EQUAL((a + b < b), false); + + BOOST_CHECK_EQUAL((a == b + a), false); + BOOST_CHECK_EQUAL((a != b + a), true); + BOOST_CHECK_EQUAL((a <= b + a), true); + BOOST_CHECK_EQUAL((a < b + a), true); + BOOST_CHECK_EQUAL((a >= b + a), false); + BOOST_CHECK_EQUAL((a > b + a), false); + + BOOST_CHECK_EQUAL((a + b == b + a), true); + BOOST_CHECK_EQUAL((a + b != b + a), false); + BOOST_CHECK_EQUAL((a + b <= b + a), true); + BOOST_CHECK_EQUAL((a + b < b + a), false); + BOOST_CHECK_EQUAL((a + b >= b + a), true); + BOOST_CHECK_EQUAL((a + b > b + a), false); + + BOOST_CHECK_EQUAL((8 == b + a), false); + BOOST_CHECK_EQUAL((8 != b + a), true); + BOOST_CHECK_EQUAL((8 <= b + a), true); + BOOST_CHECK_EQUAL((8 < b + a), true); + BOOST_CHECK_EQUAL((8 >= b + a), false); + BOOST_CHECK_EQUAL((8 > b + a), false); + BOOST_CHECK_EQUAL((800 == b + a), false); + BOOST_CHECK_EQUAL((800 != b + a), true); + BOOST_CHECK_EQUAL((800 >= b + a), true); + BOOST_CHECK_EQUAL((800 > b + a), true); + BOOST_CHECK_EQUAL((800 <= b + a), false); + BOOST_CHECK_EQUAL((800 < b + a), false); + BOOST_CHECK_EQUAL((72 == b + a), true); + BOOST_CHECK_EQUAL((72 != b + a), false); + BOOST_CHECK_EQUAL((72 <= b + a), true); + BOOST_CHECK_EQUAL((72 < b + a), false); + BOOST_CHECK_EQUAL((72 >= b + a), true); + BOOST_CHECK_EQUAL((72 > b + a), false); + + BOOST_CHECK_EQUAL((b + a == 8), false); + BOOST_CHECK_EQUAL((b + a != 8), true); + BOOST_CHECK_EQUAL((b + a >= 8), true); + BOOST_CHECK_EQUAL((b + a > 8), true); + BOOST_CHECK_EQUAL((b + a <= 8), false); + BOOST_CHECK_EQUAL((b + a < 8), false); + BOOST_CHECK_EQUAL((b + a == 800), false); + BOOST_CHECK_EQUAL((b + a != 800), true); + BOOST_CHECK_EQUAL((b + a <= 800), true); + BOOST_CHECK_EQUAL((b + a < 800), true); + BOOST_CHECK_EQUAL((b + a >= 800), false); + BOOST_CHECK_EQUAL((b + a > 800), false); + BOOST_CHECK_EQUAL((b + a == 72), true); + BOOST_CHECK_EQUAL((b + a != 72), false); + BOOST_CHECK_EQUAL((b + a >= 72), true); + BOOST_CHECK_EQUAL((b + a > 72), false); + BOOST_CHECK_EQUAL((b + a <= 72), true); + BOOST_CHECK_EQUAL((b + a < 72), false); + + T c; + // + // min and max overloads: + // +#if !defined(min) && !defined(max) + using std::max; + using std::min; + a = 2; + b = 5; + c = 6; + BOOST_CHECK_EQUAL(min(a, b), a); + BOOST_CHECK_EQUAL(min(b, a), a); + BOOST_CHECK_EQUAL(max(a, b), b); + BOOST_CHECK_EQUAL(max(b, a), b); + BOOST_CHECK_EQUAL(min(a, b + c), a); + BOOST_CHECK_EQUAL(min(b + c, a), a); + BOOST_CHECK_EQUAL(min(a, c - b), 1); + BOOST_CHECK_EQUAL(min(c - b, a), 1); + BOOST_CHECK_EQUAL(max(a, b + c), 11); + BOOST_CHECK_EQUAL(max(b + c, a), 11); + BOOST_CHECK_EQUAL(max(a, c - b), a); + BOOST_CHECK_EQUAL(max(c - b, a), a); + BOOST_CHECK_EQUAL(min(a + b, b + c), 7); + BOOST_CHECK_EQUAL(min(b + c, a + b), 7); + BOOST_CHECK_EQUAL(max(a + b, b + c), 11); + BOOST_CHECK_EQUAL(max(b + c, a + b), 11); + BOOST_CHECK_EQUAL(min(a + b, c - a), 4); + BOOST_CHECK_EQUAL(min(c - a, a + b), 4); + BOOST_CHECK_EQUAL(max(a + b, c - a), 7); + BOOST_CHECK_EQUAL(max(c - a, a + b), 7); + + long l1(2), l2(3), l3; + l3 = min(l1, l2) + max(l1, l2) + max(l1, l2) + min(l1, l2); + BOOST_CHECK_EQUAL(l3, 10); + +#endif + + +} + template void test() { @@ -2192,73 +2394,7 @@ void test() // // Comparisons: // - BOOST_CHECK_EQUAL((a == b) , false); - BOOST_CHECK_EQUAL((a != b) , true); - BOOST_CHECK_EQUAL((a <= b) , true); - BOOST_CHECK_EQUAL((a < b) , true); - BOOST_CHECK_EQUAL((a >= b) , false); - BOOST_CHECK_EQUAL((a > b) , false); - - BOOST_CHECK_EQUAL((a+b == b) , false); - BOOST_CHECK_EQUAL((a+b != b) , true); - BOOST_CHECK_EQUAL((a+b >= b) , true); - BOOST_CHECK_EQUAL((a+b > b) , true); - BOOST_CHECK_EQUAL((a+b <= b) , false); - BOOST_CHECK_EQUAL((a+b < b) , false); - - BOOST_CHECK_EQUAL((a == b+a) , false); - BOOST_CHECK_EQUAL((a != b+a) , true); - BOOST_CHECK_EQUAL((a <= b+a) , true); - BOOST_CHECK_EQUAL((a < b+a) , true); - BOOST_CHECK_EQUAL((a >= b+a) , false); - BOOST_CHECK_EQUAL((a > b+a) , false); - - BOOST_CHECK_EQUAL((a+b == b+a) , true); - BOOST_CHECK_EQUAL((a+b != b+a) , false); - BOOST_CHECK_EQUAL((a+b <= b+a) , true); - BOOST_CHECK_EQUAL((a+b < b+a) , false); - BOOST_CHECK_EQUAL((a+b >= b+a) , true); - BOOST_CHECK_EQUAL((a+b > b+a) , false); - - BOOST_CHECK_EQUAL((8 == b+a) , false); - BOOST_CHECK_EQUAL((8 != b+a) , true); - BOOST_CHECK_EQUAL((8 <= b+a) , true); - BOOST_CHECK_EQUAL((8 < b+a) , true); - BOOST_CHECK_EQUAL((8 >= b+a) , false); - BOOST_CHECK_EQUAL((8 > b+a) , false); - BOOST_CHECK_EQUAL((800 == b+a) , false); - BOOST_CHECK_EQUAL((800 != b+a) , true); - BOOST_CHECK_EQUAL((800 >= b+a) , true); - BOOST_CHECK_EQUAL((800 > b+a) , true); - BOOST_CHECK_EQUAL((800 <= b+a) , false); - BOOST_CHECK_EQUAL((800 < b+a) , false); - BOOST_CHECK_EQUAL((72 == b+a) , true); - BOOST_CHECK_EQUAL((72 != b+a) , false); - BOOST_CHECK_EQUAL((72 <= b+a) , true); - BOOST_CHECK_EQUAL((72 < b+a) , false); - BOOST_CHECK_EQUAL((72 >= b+a) , true); - BOOST_CHECK_EQUAL((72 > b+a) , false); - - BOOST_CHECK_EQUAL((b + a == 8), false); - BOOST_CHECK_EQUAL((b + a != 8), true); - BOOST_CHECK_EQUAL((b + a >= 8), true); - BOOST_CHECK_EQUAL((b + a > 8), true); - BOOST_CHECK_EQUAL((b + a <= 8), false); - BOOST_CHECK_EQUAL((b + a < 8), false); - BOOST_CHECK_EQUAL((b + a == 800), false); - BOOST_CHECK_EQUAL((b + a != 800), true); - BOOST_CHECK_EQUAL((b + a <= 800), true); - BOOST_CHECK_EQUAL((b + a < 800), true); - BOOST_CHECK_EQUAL((b + a >= 800), false); - BOOST_CHECK_EQUAL((b + a > 800), false); - BOOST_CHECK_EQUAL((b + a == 72), true); - BOOST_CHECK_EQUAL((b + a != 72), false); - BOOST_CHECK_EQUAL((b + a >= 72), true); - BOOST_CHECK_EQUAL((b + a > 72), false); - BOOST_CHECK_EQUAL((b + a <= 72), true); - BOOST_CHECK_EQUAL((b + a < 72), false); - - + test_relationals(a, b); test_members(a); // // Use in Boolean context: @@ -2359,41 +2495,6 @@ void test() BOOST_CHECK_EQUAL(c, 20); // Destructor of "a" checks destruction of moved-from-object... Real m3(static_cast(a)); -#endif - // - // min and max overloads: - // -#if !defined(min) && !defined(max) - using std::max; - using std::min; - a = 2; - b = 5; - c = 6; - BOOST_CHECK_EQUAL(min(a, b), a); - BOOST_CHECK_EQUAL(min(b, a), a); - BOOST_CHECK_EQUAL(max(a, b), b); - BOOST_CHECK_EQUAL(max(b, a), b); - BOOST_CHECK_EQUAL(min(a, b + c), a); - BOOST_CHECK_EQUAL(min(b + c, a), a); - BOOST_CHECK_EQUAL(min(a, c - b), 1); - BOOST_CHECK_EQUAL(min(c - b, a), 1); - BOOST_CHECK_EQUAL(max(a, b + c), 11); - BOOST_CHECK_EQUAL(max(b + c, a), 11); - BOOST_CHECK_EQUAL(max(a, c - b), a); - BOOST_CHECK_EQUAL(max(c - b, a), a); - BOOST_CHECK_EQUAL(min(a + b, b + c), 7); - BOOST_CHECK_EQUAL(min(b + c, a + b), 7); - BOOST_CHECK_EQUAL(max(a + b, b + c), 11); - BOOST_CHECK_EQUAL(max(b + c, a + b), 11); - BOOST_CHECK_EQUAL(min(a + b, c - a), 4); - BOOST_CHECK_EQUAL(min(c - a, a + b), 4); - BOOST_CHECK_EQUAL(max(a + b, c - a), 7); - BOOST_CHECK_EQUAL(max(c - a, a + b), 7); - - long l1(2), l2(3), l3; - l3 = min(l1, l2) + max(l1, l2) + max(l1, l2) + min(l1, l2); - BOOST_CHECK_EQUAL(l3, 10); - #endif // // Bug cases, self assignment first: