]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/core/test/lightweight_test_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / core / test / lightweight_test_test.cpp
1 //
2 // Test for lightweight_test.hpp
3 //
4 // Copyright (c) 2014 Peter Dimov
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt
9 //
10
11 #include <boost/detail/lightweight_test.hpp>
12
13 struct X
14 {
15 };
16
17 #if !defined( BOOST_NO_EXCEPTIONS )
18 # define LWT_THROW( x ) throw x
19 #else
20 # define LWT_THROW( x ) ((void)(x))
21 #endif
22
23 void f( bool x )
24 {
25 if( x )
26 {
27 LWT_THROW( X() );
28 }
29 else
30 {
31 LWT_THROW( 5 );
32 }
33 }
34
35 int main()
36 {
37 int x = 0;
38
39 // BOOST_TEST
40
41 BOOST_TEST( x == 0 );
42 BOOST_TEST( ++x == 1 );
43 BOOST_TEST( x++ == 1 );
44 BOOST_TEST( x == 2? true: false );
45 BOOST_TEST( x == 2? &x: 0 );
46
47 // BOOST_TEST_NOT
48
49 BOOST_TEST_NOT( x == 1 );
50 BOOST_TEST_NOT( ++x == 2 );
51 BOOST_TEST_NOT( x++ == 2 );
52 BOOST_TEST_NOT( --x == 2 );
53 BOOST_TEST_NOT( x-- == 2 );
54 BOOST_TEST_NOT( x == 2? false: true );
55 BOOST_TEST_NOT( x == 2? 0: &x );
56
57 // BOOST_TEST_EQ
58
59 BOOST_TEST_EQ( x, 2 );
60 BOOST_TEST_EQ( ++x, 3 );
61 BOOST_TEST_EQ( x++, 3 );
62
63 int y = 4;
64
65 BOOST_TEST_EQ( ++x, ++y );
66 BOOST_TEST_EQ( x++, y++ );
67
68 // BOOST_TEST_NE
69
70 BOOST_TEST_NE( ++x, y );
71 BOOST_TEST_NE( &x, &y );
72
73 // BOOST_TEST_THROWS
74
75 BOOST_TEST_THROWS( throw X(), X );
76 BOOST_TEST_THROWS( throw 1, int );
77
78 BOOST_TEST_THROWS( f(true), X );
79 BOOST_TEST_THROWS( f(false), int );
80
81 return boost::report_errors();
82 }