]>
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/detail/lightweight_test.hpp>
14 #include <boost/assert.hpp>
25 BOOST_ASSERT_MSG(1, "msg");
26 BOOST_ASSERT_MSG(x
, "msg");
27 BOOST_ASSERT_MSG(x
== 1, "msg");
28 BOOST_ASSERT_MSG(&x
, "msg");
31 #define BOOST_DISABLE_ASSERTS
32 #include <boost/assert.hpp>
43 BOOST_ASSERT_MSG(1, "msg");
44 BOOST_ASSERT_MSG(x
, "msg");
45 BOOST_ASSERT_MSG(x
== 1, "msg");
46 BOOST_ASSERT_MSG(&x
, "msg");
52 BOOST_ASSERT_MSG(0, "msg");
53 BOOST_ASSERT_MSG(!x
, "msg");
54 BOOST_ASSERT_MSG(x
== 0, "msg");
59 BOOST_ASSERT_MSG(p
, "msg");
66 #undef BOOST_DISABLE_ASSERTS
68 #define BOOST_ENABLE_ASSERT_HANDLER
69 #include <boost/assert.hpp>
70 #include <boost/config.hpp>
73 int handler_invoked
= 0;
74 int msg_handler_invoked
= 0;
76 void boost::assertion_failed(char const * expr
, char const * function
, char const * file
, long line
)
78 #if !defined(BOOST_NO_STDC_NAMESPACE)
82 printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr
, function
, file
, line
);
86 void boost::assertion_failed_msg(char const * expr
, char const * msg
, char const * function
,
87 char const * file
, long line
)
89 #if !defined(BOOST_NO_STDC_NAMESPACE)
93 printf("Expression: %s Message: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n",
94 expr
, msg
, function
, file
, line
);
95 ++msg_handler_invoked
;
103 BOOST_ASSERT_MSG(0, "msg f()");
113 BOOST_ASSERT(x
== 1);
116 BOOST_ASSERT_MSG(1, "msg2");
117 BOOST_ASSERT_MSG(x
, "msg3");
118 BOOST_ASSERT_MSG(x
== 1, "msg4");
119 BOOST_ASSERT_MSG(&x
, "msg5");
123 BOOST_ASSERT(x
== 0);
125 BOOST_ASSERT_MSG(0,"msg 0");
126 BOOST_ASSERT_MSG(!x
, "msg !x");
127 BOOST_ASSERT_MSG(x
== 0, "msg x == 0");
132 BOOST_ASSERT_MSG(p
, "msg p");
136 BOOST_ASSERT(handler_invoked
== 5);
137 BOOST_TEST(handler_invoked
== 5);
139 BOOST_ASSERT_MSG(msg_handler_invoked
== 5, "msg_handler_invoked count is wrong");
140 BOOST_TEST(msg_handler_invoked
== 5);
143 #undef BOOST_ENABLE_ASSERT_HANDLER
144 #undef BOOST_ENABLE_ASSERT_MSG_HANDLER
152 return boost::report_errors();