$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r67339 - sandbox/icl/libs/icl/test/test_casual_
From: afojgo_at_[hidden]
Date: 2010-12-19 10:29:06
Author: jofaber
Date: 2010-12-19 10:28:36 EST (Sun, 19 Dec 2010)
New Revision: 67339
URL: http://svn.boost.org/trac/boost/changeset/67339
Log:
Added some tests on date_time, date_time durations and icl::intervals.
Text files modified: 
   sandbox/icl/libs/icl/test/test_casual_/test_casual.cpp |    54 +++++++++++++++++++++++++++++++++++---- 
   1 files changed, 48 insertions(+), 6 deletions(-)
Modified: sandbox/icl/libs/icl/test/test_casual_/test_casual.cpp
==============================================================================
--- sandbox/icl/libs/icl/test/test_casual_/test_casual.cpp	(original)
+++ sandbox/icl/libs/icl/test/test_casual_/test_casual.cpp	2010-12-19 10:28:36 EST (Sun, 19 Dec 2010)
@@ -17,21 +17,63 @@
 #include "../test_type_lists.hpp"
 #include "../test_value_maker.hpp"
 
-#include <boost/icl/interval_map.hpp>
+#include <boost/icl/gregorian.hpp>
+#include <boost/icl/ptime.hpp>
+//#include <boost/icl/interval_map.hpp>
+#include <boost/icl/interval.hpp>
+
 
 using namespace std;
 using namespace boost;
 using namespace unit_test;
 using namespace boost::icl;
+using namespace boost::posix_time;
+using namespace boost::gregorian;
+
+void time_test()
+{
+    ptime t_a = time_from_string("2010-12-24 19:30");
+    ptime t_b = time_from_string("2010-12-24 20:30");
+    time_duration a_2_b = t_b - t_a;
+    cout << "Duration of [" << t_a << "," << t_b << ") = " 
+         << a_2_b << endl;  
+
+    interval<ptime>::type a_b 
+        = interval<ptime>::right_open(t_a, t_b);
+    cout << "Duration of " << a_b << " = " 
+         << icl::size(a_b) << endl;
+
+	icl::size(a_b);
+
+    time_duration half = a_2_b / 2;
+    ptime t_m = t_a + half;
 
+    cout << a_b << (icl::contains(a_b, t_m) ? 
+                    " contains " : "does not contain ") 
+         << t_m << endl;
+
+	ptime day_begin = time_from_string("2010-12-24 00:00");
+	time_duration d_a = t_a - day_begin;
+	time_duration d_b = t_b - day_begin;
+	time_duration d_m = d_b - d_a;
+
+	interval<time_duration>::type rel_a_b 
+        = interval<time_duration>::right_open(d_a, d_b);
+
+
+	icl::size(rel_a_b);
+	cout << rel_a_b << " " << d_m << (icl::size(rel_a_b)) << endl;
+}
 
 BOOST_AUTO_TEST_CASE(casual)
 {
-    typedef int T;
-    typedef int U;
-    typedef interval_map<T,U, total_absorber> IntervalMapT;
-    typedef interval_set<T>                   IntervalSetT;
-    typedef IntervalMapT::interval_type       IntervalT;
+    //typedef int T;
+    //typedef int U;
+    //typedef interval_map<T,U, total_absorber> IntervalMapT;
+    //typedef interval_set<T>                   IntervalSetT;
+    //typedef IntervalMapT::interval_type       IntervalT;
+
+    time_test();
 
     BOOST_CHECK_EQUAL(true, true);
 }