8fd0dea683aafa3dcc7d70f854618572fe46b77f
[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         boost::posix_time::ptime now
19             = boost::posix_time::microsec_clock::local_time();
20         //std::cout << now << std::endl;
21         
22         sleep(1);
23         
24         boost::posix_time::ptime then
25             = boost::posix_time::microsec_clock::local_time();
26         //std::cout << then << std::endl;
27         
28         boost::posix_time::time_period period(now, then);
29         //std::cout << period << std::endl;
30         
31         boost::posix_time::time_duration duration = then - now;
32         //std::cout << duration << std::endl;
33         
34         BOOST_CHECK (duration.total_seconds() == 1);
35         
36     }
37     catch (std::exception &e) {
38         std::cout << e.what() << "\n";
39         BOOST_CHECK (false);
40     }
41     catch (...) {
42         BOOST_CHECK (false);
43     }
44 }
45
46 /*
47  * Local variables:
48  * c-basic-offset: 4
49  * indent-tabs-mode: nil
50  * End:
51  * vim: shiftwidth=4 tabstop=8 expandtab
52  */