]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/libcxx/debug/debug_throw.pass.cpp
Vendor import of libc++ trunk r302418:
[FreeBSD/FreeBSD.git] / test / libcxx / debug / debug_throw.pass.cpp
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 // UNSUPPORTED: libcpp-no-exceptions
12 // MODULES_DEFINES: _LIBCPP_DEBUG=0
13
14 // Can't test the system lib because this test enables debug mode
15 // UNSUPPORTED: with_system_cxx_lib
16
17 // Test that the default debug handler can be overridden and test the
18 // throwing debug handler.
19
20 #define _LIBCPP_DEBUG 0
21
22 #include <cstdlib>
23 #include <exception>
24 #include <type_traits>
25 #include <__debug>
26
27 int main()
28 {
29   {
30     std::__libcpp_debug_function = std::__libcpp_throw_debug_function;
31     try {
32       _LIBCPP_ASSERT(false, "foo");
33     } catch (std::__libcpp_debug_exception const&) {}
34   }
35   {
36     // test that the libc++ exception type derives from std::exception
37     static_assert((std::is_base_of<std::exception,
38                                   std::__libcpp_debug_exception
39                   >::value), "must be an exception");
40   }
41 }