2010-05-11 21:42:16 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-05-11 23:36:01 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
2010-11-16 23:09:02 +01:00
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2010-08-22 02:31:12 +02:00
|
|
|
|
2010-05-11 21:42:16 +02:00
|
|
|
// test set_unexpected
|
|
|
|
|
|
|
|
#include <exception>
|
|
|
|
#include <cassert>
|
2010-05-14 22:17:42 +02:00
|
|
|
#include <cstdlib>
|
2010-05-11 21:42:16 +02:00
|
|
|
|
|
|
|
void f1() {}
|
|
|
|
void f2() {}
|
|
|
|
|
2010-05-14 22:17:42 +02:00
|
|
|
void f3()
|
|
|
|
{
|
|
|
|
std::exit(0);
|
|
|
|
}
|
|
|
|
|
2010-05-11 21:42:16 +02:00
|
|
|
int main()
|
|
|
|
{
|
2010-08-22 15:53:14 +02:00
|
|
|
std::unexpected_handler old = std::set_unexpected(f1);
|
2010-05-14 22:17:42 +02:00
|
|
|
// verify there is a previous unexpected handler
|
2010-08-22 15:53:14 +02:00
|
|
|
assert(old);
|
|
|
|
// verify f1 was replace with f2
|
2010-08-22 02:31:12 +02:00
|
|
|
assert(std::set_unexpected(f2) == f1);
|
2010-08-22 15:53:14 +02:00
|
|
|
// verify calling original unexpected handler calls terminate
|
|
|
|
std::set_terminate(f3);
|
|
|
|
(*old)();
|
|
|
|
assert(0);
|
2010-05-11 21:42:16 +02:00
|
|
|
}
|