test for boost time added. missing configure test for headers yet ...
[metaproxy-moved-to-github.git] / src / test_boost_time.cpp
1 #include <iostream>
2
3 #include "boost/date_time/posix_time/posix_time.hpp"
4
5 #define BOOST_AUTO_TEST_MAIN
6 #include <boost/test/auto_unit_test.hpp>
7
8 using namespace boost::unit_test;
9
10
11
12 BOOST_AUTO_TEST_CASE( testboosttime1 ) 
13 {
14
15     // test session 
16     try {
17
18         //using namespace boost::posix_time;
19   //using namespace boost::gregorian;
20
21   //get the current time from the clock -- one second resolution
22   //boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
23   boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
24   //std::cout << to_iso_extended_string(now) << std::endl;
25   //std::cout << now << std::endl;
26
27   sleep(1);
28   
29   boost::posix_time::ptime then = boost::posix_time::microsec_clock::local_time();
30
31   //std::cout << then << std::endl;
32
33   boost::posix_time::time_period period(now, then);
34   
35   //std::cout << period << std::endl;
36
37
38   //Get the date part out of the time
39   //date today = now.date();
40   //date tommorrow = today + days(1);
41   //ptime tommorrow_start(tommorrow); //midnight 
42
43   //iterator adds by one hour
44   //time_iterator titr(now,hours(1)); 
45   //for (; titr < tommorrow_start; ++titr) {
46   //  std::cout << to_simple_string(*titr) << std::endl;
47   //}
48   
49   //time_duration remaining = tommorrow_start - now;
50   //std::cout << "Time left till midnight: " 
51   //          << to_simple_string(remaining) << std::endl;
52
53         BOOST_CHECK (1 == 1);
54         
55     }
56     catch (std::exception &e) {
57         std::cout << e.what() << "\n";
58         BOOST_CHECK (false);
59     }
60     catch (...) {
61         BOOST_CHECK (false);
62     }
63 }
64
65 /*
66  * Local variables:
67  * c-basic-offset: 4
68  * indent-tabs-mode: nil
69  * End:
70  * vim: shiftwidth=4 tabstop=8 expandtab
71  */