Include config.hpp in all .cpp files
[metaproxy-moved-to-github.git] / src / test_boost_time.cpp
1 #include <iostream>
2
3 #include "config.hpp"
4 #include "boost/date_time/posix_time/posix_time.hpp"
5
6 #define BOOST_AUTO_TEST_MAIN
7 #include <boost/test/auto_unit_test.hpp>
8
9 using namespace boost::unit_test;
10
11
12
13 BOOST_AUTO_TEST_CASE( testboosttime1 ) 
14 {
15
16     // test session 
17     try {
18
19         boost::posix_time::ptime now
20             = boost::posix_time::microsec_clock::local_time();
21         //std::cout << now << std::endl;
22         
23         sleep(1);
24         
25         boost::posix_time::ptime then
26             = boost::posix_time::microsec_clock::local_time();
27         //std::cout << then << std::endl;
28         
29         boost::posix_time::time_period period(now, then);
30         //std::cout << period << std::endl;
31         
32         boost::posix_time::time_duration duration = then - now;
33         //std::cout << duration << std::endl;
34         
35         BOOST_CHECK (duration.total_seconds() == 1);
36         
37     }
38     catch (std::exception &e) {
39         std::cout << e.what() << "\n";
40         BOOST_CHECK (false);
41     }
42     catch (...) {
43         BOOST_CHECK (false);
44     }
45 }
46
47 /*
48  * Local variables:
49  * c-basic-offset: 4
50  * indent-tabs-mode: nil
51  * End:
52  * vim: shiftwidth=4 tabstop=8 expandtab
53  */