Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86383 - in trunk: boost/chrono/io libs/chrono/test/io
From: vicente.botet_at_[hidden]
Date: 2013-10-21 17:36:42


Author: viboes
Date: 2013-10-21 17:36:42 EDT (Mon, 21 Oct 2013)
New Revision: 86383
URL: http://svn.boost.org/trac/boost/changeset/86383

Log:
Chrono: set precission to 9 so that there is no lost with the hisgest systemp_clock precission (nanoseconds). todo, adapt the io precission to the system_clock duration period.

Text files modified:
   trunk/boost/chrono/io/time_point_io.hpp | 7 +++++
   trunk/libs/chrono/test/io/time_point_output.cpp | 42 ++++++++++++++++++++--------------------
   2 files changed, 27 insertions(+), 22 deletions(-)

Modified: trunk/boost/chrono/io/time_point_io.hpp
==============================================================================
--- trunk/boost/chrono/io/time_point_io.hpp Mon Oct 21 14:43:32 2013 (r86382)
+++ trunk/boost/chrono/io/time_point_io.hpp 2013-10-21 17:36:42 EDT (Mon, 21 Oct 2013) (r86383)
@@ -46,7 +46,7 @@
 {
   namespace chrono
   {
- typedef double fractional_seconds;
+ typedef double fractional_seconds;
     namespace detail
     {
 
@@ -937,6 +937,7 @@
                 //if (! os.good()) {
                 //throw "exception";
                 //}
+ os.precision(9);
                 os << d.count();
                 //if (! os.good()) {
                 //throw "exception";
@@ -1082,7 +1083,11 @@
             if (err & std::ios_base::failbit) goto exit;
             fractional_seconds sec;
             CharT c = CharT();
+ std::ios::fmtflags flgs = is.flags();
+ is.setf(std::ios::fixed, std::ios::floatfield);
+ is.precision(9);
             is >> sec;
+ is.flags(flgs);
             if (is.fail())
             {
               err |= std::ios_base::failbit;

Modified: trunk/libs/chrono/test/io/time_point_output.cpp
==============================================================================
--- trunk/libs/chrono/test/io/time_point_output.cpp Mon Oct 21 14:43:32 2013 (r86382)
+++ trunk/libs/chrono/test/io/time_point_output.cpp 2013-10-21 17:36:42 EDT (Mon, 21 Oct 2013) (r86383)
@@ -148,28 +148,28 @@
   using namespace boost::chrono;
   using namespace boost;
 
- test_good_system_clock("1970-01-01 02:00:00.000000 +0000", hours(2), duration_style::prefix);
- test_good_system_clock("1970-01-01 02:00:00.000000 +0000", hours(2), duration_style::symbol);
+ test_good_system_clock("1970-01-01 02:00:00.000000000 +0000", hours(2), duration_style::prefix);
+ test_good_system_clock("1970-01-01 02:00:00.000000000 +0000", hours(2), duration_style::symbol);
 
- test_good_prefix_system_clock("1970-01-01 02:00:00.000000 +0000", hours(2));
- test_good_prefix_system_clock("1970-01-01 00:02:00.000000 +0000", minutes(2));
- test_good_prefix_system_clock("1970-01-01 00:00:02.000000 +0000", seconds(2));
- test_good_prefix_system_clock("1970-01-01 00:00:01.000000 +0000", seconds(1));
- test_good_prefix_system_clock("1969-12-31 23:59:59.000000 +0000", seconds(-1));
- test_good_prefix_system_clock("1970-01-01 00:00:00.000000 +0000", seconds(0));
- test_good_prefix_system_clock("1970-01-01 00:00:00.002000 +0000", milliseconds(2));
- test_good_prefix_system_clock("1970-01-01 00:00:00.000002 +0000", microseconds(2));
- test_good_prefix_system_clock("1970-01-01 00:00:00.000000 +0000", nanoseconds(2));
- test_good_prefix_system_clock("1970-01-01 00:00:00.200000 +0000", duration<boost::int_least64_t, deci> (2));
- test_good_prefix_system_clock("1970-01-01 00:00:00.066667 +0000", duration<boost::int_least64_t, ratio<1, 30> > (2));
-
- test_good_symbol_system_clock("1970-01-01 02:00:00.000000 +0000", hours(2));
- test_good_symbol_system_clock("1970-01-01 00:02:00.000000 +0000", minutes(2));
- test_good_symbol_system_clock("1970-01-01 00:00:02.000000 +0000", seconds(2));
- test_good_symbol_system_clock("1970-01-01 00:00:00.002000 +0000", milliseconds(2));
- test_good_symbol_system_clock("1970-01-01 00:00:00.000000 +0000", nanoseconds(2));
- test_good_symbol_system_clock("1970-01-01 00:00:00.200000 +0000", duration<boost::int_least64_t, deci> (2));
- test_good_symbol_system_clock("1970-01-01 00:00:00.066667 +0000", duration<boost::int_least64_t, ratio<1, 30> > (2));
+ test_good_prefix_system_clock("1970-01-01 02:00:00.000000000 +0000", hours(2));
+ test_good_prefix_system_clock("1970-01-01 00:02:00.000000000 +0000", minutes(2));
+ test_good_prefix_system_clock("1970-01-01 00:00:02.000000000 +0000", seconds(2));
+ test_good_prefix_system_clock("1970-01-01 00:00:01.000000000 +0000", seconds(1));
+ test_good_prefix_system_clock("1969-12-31 23:59:59.000000000 +0000", seconds(-1));
+ test_good_prefix_system_clock("1970-01-01 00:00:00.000000000 +0000", seconds(0));
+ test_good_prefix_system_clock("1970-01-01 00:00:00.002000000 +0000", milliseconds(2));
+ test_good_prefix_system_clock("1970-01-01 00:00:00.000002000 +0000", microseconds(2));
+ test_good_prefix_system_clock("1970-01-01 00:00:00.000000002 +0000", nanoseconds(2));
+ test_good_prefix_system_clock("1970-01-01 00:00:00.200000000 +0000", duration<boost::int_least64_t, deci> (2));
+ test_good_prefix_system_clock("1970-01-01 00:00:00.066666667 +0000", duration<boost::int_least64_t, ratio<1, 30> > (2));
+
+ test_good_symbol_system_clock("1970-01-01 02:00:00.000000000 +0000", hours(2));
+ test_good_symbol_system_clock("1970-01-01 00:02:00.000000000 +0000", minutes(2));
+ test_good_symbol_system_clock("1970-01-01 00:00:02.000000000 +0000", seconds(2));
+ test_good_symbol_system_clock("1970-01-01 00:00:00.002000000 +0000", milliseconds(2));
+ test_good_symbol_system_clock("1970-01-01 00:00:00.000000002 +0000", nanoseconds(2));
+ test_good_symbol_system_clock("1970-01-01 00:00:00.200000000 +0000", duration<boost::int_least64_t, deci> (2));
+ test_good_symbol_system_clock("1970-01-01 00:00:00.066666667 +0000", duration<boost::int_least64_t, ratio<1, 30> > (2));
 
   test_good_utc_fmt_system_clock("1970-01-01 02:00:00", "%Y-%m-%d %H:%M:%S", hours(2));
   test_good_utc_fmt_system_clock("1970-01-01 02", "%Y-%m-%d %H", hours(2));


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