1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // Adaptation to Boost of the libcxx 10 // Copyright 2010 Vicente J. Botet Escriba 11 // Distributed under the Boost Software License, Version 1.0. 12 // See http://www.boost.org/LICENSE_1_0.txt 13 14 #define BOOST_CHRONO_EXTENSIONS 15 #include <boost/chrono/chrono.hpp> 16 #include <boost/detail/lightweight_test.hpp> 17 #ifdef BOOST_NO_CXX11_CONSTEXPR 18 #define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C) 19 #else 20 #include <boost/static_assert.hpp> 21 #define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C) 22 #endif 23 main()24int main() 25 { 26 { 27 typedef boost::chrono::system_clock Clock; 28 typedef boost::chrono::milliseconds Duration; 29 boost::chrono::time_point<Clock, Duration> t(Duration(3)); 30 t += 2; 31 BOOST_TEST(t.time_since_epoch() == Duration(5)); 32 } 33 { 34 typedef boost::chrono::system_clock Clock; 35 typedef boost::chrono::milliseconds Duration; 36 boost::chrono::time_point<Clock, Duration> t(Duration(3)); 37 t++; 38 BOOST_TEST(t.time_since_epoch() == Duration(4)); 39 } 40 { 41 typedef boost::chrono::system_clock Clock; 42 typedef boost::chrono::milliseconds Duration; 43 boost::chrono::time_point<Clock, Duration> t(Duration(3)); 44 ++t; 45 BOOST_TEST(t.time_since_epoch() == Duration(4)); 46 } 47 { 48 typedef boost::chrono::system_clock Clock; 49 typedef boost::chrono::milliseconds Duration; 50 boost::chrono::time_point<Clock, Duration> t(Duration(3)); 51 t -= 2; 52 BOOST_TEST(t.time_since_epoch() == Duration(1)); 53 } 54 { 55 typedef boost::chrono::system_clock Clock; 56 typedef boost::chrono::milliseconds Duration; 57 boost::chrono::time_point<Clock, Duration> t(Duration(3)); 58 t--; 59 BOOST_TEST(t.time_since_epoch() == Duration(2)); 60 } 61 { 62 typedef boost::chrono::system_clock Clock; 63 typedef boost::chrono::milliseconds Duration; 64 boost::chrono::time_point<Clock, Duration> t(Duration(3)); 65 --t; 66 BOOST_TEST(t.time_since_epoch() == Duration(2)); 67 } 68 69 return boost::report_errors(); 70 } 71