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