]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/chrono/test/time_point/constructor_pass.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / chrono / test / time_point / constructor_pass.cpp
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 #include <boost/chrono/chrono.hpp>
15 #include <boost/detail/lightweight_test.hpp>
16 #include "../rep.h"
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
24 int main()
25 {
26 {
27 typedef boost::chrono::system_clock Clock;
28 typedef boost::chrono::microseconds Duration1;
29 typedef boost::chrono::milliseconds Duration2;
30 boost::chrono::time_point<Clock, Duration2> t2(Duration2(3));
31 boost::chrono::time_point<Clock, Duration1> t1 = t2;
32 BOOST_TEST(t1.time_since_epoch() == Duration1(3000));
33 }
34 {
35 typedef boost::chrono::system_clock Clock;
36 typedef boost::chrono::microseconds Duration1;
37 typedef boost::chrono::milliseconds Duration2;
38 BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration2> t2(Duration2(3));
39 BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration1> t1 = t2;
40 BOOST_CONSTEXPR_ASSERT(t1.time_since_epoch() == Duration1(3000));
41 }
42 {
43 typedef boost::chrono::system_clock Clock;
44 typedef boost::chrono::duration<Rep, boost::milli> Duration;
45 boost::chrono::time_point<Clock, Duration> t;
46 BOOST_TEST(t.time_since_epoch() == Duration::zero());
47 }
48 {
49 typedef boost::chrono::system_clock Clock;
50 typedef boost::chrono::duration<Rep, boost::milli> Duration;
51 BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration> t;
52 BOOST_CONSTEXPR_ASSERT(t.time_since_epoch() == Duration::zero());
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 BOOST_TEST(t.time_since_epoch() == Duration(3));
59 }
60 {
61 typedef boost::chrono::system_clock Clock;
62 typedef boost::chrono::milliseconds Duration;
63 BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration> t(Duration(3));
64 BOOST_CONSTEXPR_ASSERT(t.time_since_epoch() == Duration(3));
65 }
66 {
67 typedef boost::chrono::system_clock Clock;
68 typedef boost::chrono::milliseconds Duration;
69 boost::chrono::time_point<Clock, Duration> t(boost::chrono::seconds(3));
70 BOOST_TEST(t.time_since_epoch() == Duration(3000));
71 }
72 {
73 typedef boost::chrono::system_clock Clock;
74 typedef boost::chrono::milliseconds Duration;
75 BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration> t(boost::chrono::seconds(3));
76 BOOST_CONSTEXPR_ASSERT(t.time_since_epoch() == Duration(3000));
77 }
78
79 return boost::report_errors();
80 }