Log filter uses same file as yaz_log system by default.
[metaproxy-moved-to-github.git] / src / test_boost_time.cpp
1 /* $Id: test_boost_time.cpp,v 1.12 2007-11-02 17:47:41 adam Exp $
2    Copyright (c) 2005-2007, Index Data.
3
4 This file is part of Metaproxy.
5
6 Metaproxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Metaproxy; see the file LICENSE.  If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.
20  */
21
22 #include <iostream>
23
24 #include "config.hpp"
25 #include "boost/date_time/posix_time/posix_time.hpp"
26
27 #define BOOST_AUTO_TEST_MAIN
28 #define BOOST_TEST_DYN_LINK
29 #include <boost/test/auto_unit_test.hpp>
30
31 using namespace boost::unit_test;
32
33
34
35 BOOST_AUTO_TEST_CASE( testboosttime1 ) 
36 {
37
38     // test session 
39     try {
40
41         boost::posix_time::ptime now
42             = boost::posix_time::microsec_clock::local_time();
43         //std::cout << now << std::endl;
44         
45         sleep(1);
46         
47         boost::posix_time::ptime then
48             = boost::posix_time::microsec_clock::local_time();
49         //std::cout << then << std::endl;
50         
51         boost::posix_time::time_period period(now, then);
52         //std::cout << period << std::endl;
53         
54         boost::posix_time::time_duration duration = then - now;
55         //std::cout << duration << std::endl;
56         
57         BOOST_CHECK (duration.total_seconds() >= 1);
58         BOOST_CHECK (duration.fractional_seconds() > 0);
59         
60     }
61     catch (std::exception &e) {
62         std::cout << e.what() << "\n";
63         BOOST_CHECK (false);
64     }
65     catch (...) {
66         BOOST_CHECK (false);
67     }
68 }
69
70 /*
71  * Local variables:
72  * c-basic-offset: 4
73  * indent-tabs-mode: nil
74  * c-file-style: "stroustrup"
75  * End:
76  * vim: shiftwidth=4 tabstop=8 expandtab
77  */