]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/assert/test/assert_test.cpp
2 // assert_test.cpp - a test for boost/assert.hpp
4 // Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
5 // Copyright (2) Beman Dawes 2011
7 // Distributed under the Boost Software License, Version 1.0. (See
8 // accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
12 #include <boost/core/lightweight_test.hpp>
15 # pragma GCC diagnostic ignored "-Waddress"
18 #include <boost/assert.hpp>
29 BOOST_ASSERT_MSG(1, "msg");
30 BOOST_ASSERT_MSG(x
, "msg");
31 BOOST_ASSERT_MSG(x
== 1, "msg");
32 BOOST_ASSERT_MSG(&x
, "msg");
35 #define BOOST_DISABLE_ASSERTS
36 #include <boost/assert.hpp>
47 BOOST_ASSERT_MSG(1, "msg");
48 BOOST_ASSERT_MSG(x
, "msg");
49 BOOST_ASSERT_MSG(x
== 1, "msg");
50 BOOST_ASSERT_MSG(&x
, "msg");
56 BOOST_ASSERT_MSG(0, "msg");
57 BOOST_ASSERT_MSG(!x
, "msg");
58 BOOST_ASSERT_MSG(x
== 0, "msg");
63 BOOST_ASSERT_MSG(p
, "msg");
70 #undef BOOST_DISABLE_ASSERTS
72 #define BOOST_ENABLE_ASSERT_HANDLER
73 #include <boost/assert.hpp>
74 #include <boost/config.hpp>
77 int handler_invoked
= 0;
78 int msg_handler_invoked
= 0;
80 void boost::assertion_failed(char const * expr
, char const * function
, char const * file
, long line
)
82 #if !defined(BOOST_NO_STDC_NAMESPACE)
86 printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr
, function
, file
, line
);
90 void boost::assertion_failed_msg(char const * expr
, char const * msg
, char const * function
,
91 char const * file
, long line
)
93 #if !defined(BOOST_NO_STDC_NAMESPACE)
97 printf("Expression: %s Message: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n",
98 expr
, msg
, function
, file
, line
);
99 ++msg_handler_invoked
;
107 BOOST_ASSERT_MSG(0, "msg f()");
117 BOOST_ASSERT(x
== 1);
120 BOOST_ASSERT_MSG(1, "msg2");
121 BOOST_ASSERT_MSG(x
, "msg3");
122 BOOST_ASSERT_MSG(x
== 1, "msg4");
123 BOOST_ASSERT_MSG(&x
, "msg5");
127 BOOST_ASSERT(x
== 0);
129 BOOST_ASSERT_MSG(0,"msg 0");
130 BOOST_ASSERT_MSG(!x
, "msg !x");
131 BOOST_ASSERT_MSG(x
== 0, "msg x == 0");
136 BOOST_ASSERT_MSG(p
, "msg p");
140 BOOST_ASSERT(handler_invoked
== 5);
141 BOOST_TEST(handler_invoked
== 5);
143 BOOST_ASSERT_MSG(msg_handler_invoked
== 5, "msg_handler_invoked count is wrong");
144 BOOST_TEST(msg_handler_invoked
== 5);
147 #undef BOOST_ENABLE_ASSERT_HANDLER
148 #undef BOOST_ENABLE_ASSERT_MSG_HANDLER
156 return boost::report_errors();