]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/multi_array/test/assert.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / multi_array / test / assert.cpp
1 // Copyright 2007 The Trustees of Indiana University.
2
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 // Boost.MultiArray Library
8 // Authors: Ronald Garcia
9 // Jeremy Siek
10 // Andrew Lumsdaine
11 // See http://www.boost.org/libs/multi_array for documentation.
12
13 //
14 // Using the BOOST.ASSERT mechanism to replace library assertions
15 // with exceptions
16 //
17
18 #include <boost/core/lightweight_test.hpp>
19
20 #define BOOST_ENABLE_ASSERT_HANDLER
21 #include <boost/multi_array.hpp> // includes assert.hpp
22
23 #include <stdexcept>
24
25 namespace boost {
26
27 void assertion_failed(char const* expr, char const* function,
28 char const* file, long line) {
29 throw std::runtime_error(expr);
30 }
31
32 void assertion_failed_msg(char const * expr, char const * msg,
33 char const * function,
34 char const * file, long line) {
35 throw std::runtime_error(msg);
36 }
37
38 } // namespace boost
39
40 using namespace boost;
41
42 int
43 main() {
44
45 typedef multi_array<int,2> array_t;
46
47 array_t A(extents[2][2]);
48
49 array_t B(extents[3][3]);
50
51 try {
52 A = B;
53 BOOST_ERROR("did not throw an exception");
54 } catch (std::runtime_error&) {
55 //...all good
56 }
57
58 return boost::report_errors();
59 }