From 787cd1101e4bc1446206f6e345d023ca18ded09a Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sun, 22 Dec 2013 09:57:01 +0000 Subject: [PATCH] Update tests to exercise move-construct/copy better. Fix exposed bug in tommath backend. See also https://svn.boost.org/trac/boost/ticket/9497. --- include/boost/multiprecision/tommath.hpp | 2 +- test/test_arithmetic.hpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/boost/multiprecision/tommath.hpp b/include/boost/multiprecision/tommath.hpp index 17094434..85a7551e 100644 --- a/include/boost/multiprecision/tommath.hpp +++ b/include/boost/multiprecision/tommath.hpp @@ -58,7 +58,7 @@ struct tommath_int } tommath_int& operator = (tommath_int&& o) { - mp_exch(&m_data, &o.data()); + mp_exch(&m_data, &o.m_data); return *this; } #endif diff --git a/test/test_arithmetic.hpp b/test/test_arithmetic.hpp index a34d6247..3b6703ff 100644 --- a/test/test_arithmetic.hpp +++ b/test/test_arithmetic.hpp @@ -1777,5 +1777,24 @@ void test() test_conditional(a, (a + 0)); test_signed_ops(boost::mpl::bool_::is_signed>()); + // + // Test move: + // +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + Real m(static_cast(a)); + BOOST_CHECK_EQUAL(m, 20); + // Move from already moved from object: + Real m2(static_cast(a)); + // assign from moved from object + // (may result in "a" being left in valid state as implementation artifact): + c = static_cast(a); + // assignment to moved-from objects: + c = static_cast(m); + BOOST_CHECK_EQUAL(c, 20); + m2 = c; + BOOST_CHECK_EQUAL(c, 20); + // Destructor of "a" checks destruction of moved-from-object... + Real m3(static_cast(a)); +#endif }