|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85650 - trunk/libs/multiprecision/test
From: john_at_[hidden]
Date: 2013-09-11 14:14:33
Author: johnmaddock
Date: 2013-09-11 14:14:32 EDT (Wed, 11 Sep 2013)
New Revision: 85650
URL: http://svn.boost.org/trac/boost/changeset/85650
Log:
TRy and improve error reporting.
Text files modified:
trunk/libs/multiprecision/test/test_float_serial.hpp | 82 ++++++++++++++++++++++++++-------------
1 files changed, 55 insertions(+), 27 deletions(-)
Modified: trunk/libs/multiprecision/test/test_float_serial.hpp
==============================================================================
--- trunk/libs/multiprecision/test/test_float_serial.hpp Wed Sep 11 11:01:36 2013 (r85649)
+++ trunk/libs/multiprecision/test/test_float_serial.hpp 2013-09-11 14:14:32 EDT (Wed, 11 Sep 2013) (r85650)
@@ -49,44 +49,72 @@
while(true)
{
T val = generate_random<T>(boost::math::tools::digits<T>());
+ int test_id = 0;
+ std::string stream_contents;
try{
- std::stringstream ss;
- boost::archive::text_oarchive oa(ss);
- oa << static_cast<const T&>(val);
- boost::archive::text_iarchive ia(ss);
- T val2;
- ia >> val2;
- BOOST_CHECK_EQUAL(val, val2);
- ss.clear();
- boost::archive::binary_oarchive ba(ss);
- ba << static_cast<const T&>(val);
- boost::archive::binary_iarchive ib(ss);
- ib >> val2;
- BOOST_CHECK_EQUAL(val, val2);
-
- val = -val;
- ss.clear();
- boost::archive::text_oarchive oa2(ss);
- oa2 << static_cast<const T&>(val);
- boost::archive::text_iarchive ia2(ss);
- ia2 >> val2;
- BOOST_CHECK_EQUAL(val, val2);
- ss.clear();
- boost::archive::binary_oarchive ba2(ss);
- ba2 << static_cast<const T&>(val);
- boost::archive::binary_iarchive ib2(ss);
- ib2 >> val2;
- BOOST_CHECK_EQUAL(val, val2);
+ test_id = 0;
+ {
+ std::stringstream ss(std::ios_base::in | std::ios_base::out | std::ios_base::binary);
+ boost::archive::text_oarchive oa(ss);
+ oa << static_cast<const T&>(val);
+ stream_contents = ss.str();
+ boost::archive::text_iarchive ia(ss);
+ T val2;
+ ia >> val2;
+ BOOST_CHECK_EQUAL(val, val2);
+ }
+ {
+ std::stringstream ss(std::ios_base::in | std::ios_base::out | std::ios_base::binary);
+ ++test_id;
+ boost::archive::binary_oarchive ba(ss);
+ ba << static_cast<const T&>(val);
+ stream_contents = ss.str();
+ boost::archive::binary_iarchive ib(ss);
+ T val2;
+ ib >> val2;
+ BOOST_CHECK_EQUAL(val, val2);
+ }
+ {
+ std::stringstream ss(std::ios_base::in | std::ios_base::out | std::ios_base::binary);
+ val = -val;
+ ++test_id;
+ boost::archive::text_oarchive oa2(ss);
+ oa2 << static_cast<const T&>(val);
+ stream_contents = ss.str();
+ boost::archive::text_iarchive ia2(ss);
+ T val2;
+ ia2 >> val2;
+ BOOST_CHECK_EQUAL(val, val2);
+ }
+ {
+ std::stringstream ss(std::ios_base::in | std::ios_base::out | std::ios_base::binary);
+ ++test_id;
+ boost::archive::binary_oarchive ba2(ss);
+ ba2 << static_cast<const T&>(val);
+ stream_contents = ss.str();
+ boost::archive::binary_iarchive ib2(ss);
+ T val2;
+ ib2 >> val2;
+ BOOST_CHECK_EQUAL(val, val2);
+ }
}
catch(const boost::exception& e)
{
std::cout << "Caught boost::exception with:\n";
std::cout << diagnostic_information(e);
+ std::cout << "Failed test ID = " << test_id << std::endl;
+ std::cout << "Stream contents were: \n" << stream_contents << std::endl;
+ ++boost::detail::test_errors();
+ break;
}
catch(const std::exception& e)
{
std::cout << "Caught std::exception with:\n";
std::cout << e.what() << std::endl;
+ std::cout << "Failed test ID = " << test_id << std::endl;
+ std::cout << "Stream contents were: \n" << stream_contents << std::endl;
+ ++boost::detail::test_errors();
+ break;
}
//
// Check to see if test is taking too long.
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk