diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/container/test/throw_exception_test.cpp | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/container/test/throw_exception_test.cpp')
-rw-r--r-- | src/boost/libs/container/test/throw_exception_test.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/boost/libs/container/test/throw_exception_test.cpp b/src/boost/libs/container/test/throw_exception_test.cpp new file mode 100644 index 00000000..2cbabefc --- /dev/null +++ b/src/boost/libs/container/test/throw_exception_test.cpp @@ -0,0 +1,62 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2012-2013. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#define BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS + +#include <boost/container/detail/config_begin.hpp> + +#include <boost/container/throw_exception.hpp> +#include <boost/core/lightweight_test.hpp> + +using namespace boost::container; + +static bool bad_alloc_called = false; +static bool out_of_range_called = false; +static bool length_error_called = false; +static bool logic_error_called = false; +static bool runtime_error_called = false; + +//User defined throw implementations +namespace boost { +namespace container { + + void throw_bad_alloc() + { bad_alloc_called = true; } + + void throw_out_of_range(const char* str) + { (void)str; out_of_range_called = true; } + + void throw_length_error(const char* str) + { (void)str; length_error_called = true; } + + void throw_logic_error(const char* str) + { (void)str; logic_error_called = true; } + + void throw_runtime_error(const char* str) + { (void)str; runtime_error_called = true; } + +}} //boost::container + +int main() +{ + //Check user-defined throw callbacks are called + throw_bad_alloc(); + BOOST_TEST(bad_alloc_called == true); + throw_out_of_range("dummy"); + BOOST_TEST(out_of_range_called == true); + throw_length_error("dummy"); + BOOST_TEST(length_error_called == true); + throw_logic_error("dummy"); + BOOST_TEST(logic_error_called == true); + throw_runtime_error("dummy"); + BOOST_TEST(runtime_error_called == true); + return ::boost::report_errors(); +} + +#include <boost/container/detail/config_end.hpp> |