]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/core/assert.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / test / core / assert.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2015 Oracle and/or its affiliates.
5
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7
8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
11
12
13 #include <geometry_test_common.hpp>
14
15 #define BOOST_GEOMETRY_ENABLE_ASSERT_HANDLER
16 #include <boost/geometry/core/assert.hpp>
17
18 struct assert_failure_exception
19 : std::exception
20 {
21 const char * what() const throw()
22 {
23 return "assertion failure";
24 }
25 };
26
27 namespace boost { namespace geometry {
28
29 inline void assertion_failed(char const * expr, char const * function, char const * file, long line)
30 {
31 throw assert_failure_exception();
32 }
33
34 inline void assertion_failed_msg(char const * expr, char const * msg, char const * function, char const * file, long line)
35 {
36 throw assert_failure_exception();
37 }
38
39 }}
40
41 void fun1(bool condition)
42 {
43 BOOST_GEOMETRY_ASSERT(condition);
44 }
45
46 void fun2(bool condition, const char* msg = "")
47 {
48 BOOST_GEOMETRY_ASSERT_MSG(condition, msg);
49 }
50
51 bool is_ok(assert_failure_exception const& ) { return true; }
52
53 int test_main(int, char* [])
54 {
55 int a = 1;
56
57 fun1(a == 1);
58 BOOST_CHECK_EXCEPTION(fun1(a == 2), assert_failure_exception, is_ok);
59 fun2(a == 1);
60 BOOST_CHECK_EXCEPTION(fun2(a == 2), assert_failure_exception, is_ok);
61
62 return 0;
63 }