brintos

brintos / llvm-project-archived public Read only

0
0
Text · 949 B · fce49d8 Raw
41 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// REQUIRES: c++03 || c++11 || c++1410 11// test set_unexpected12 13#include <exception>14#include <cassert>15#include <cstdlib>16 17#include "test_macros.h"18 19void f1() {}20void f2() {}21 22void f3()23{24    std::exit(0);25}26 27int main(int, char**)28{29    std::unexpected_handler old = std::set_unexpected(f1);30    // verify there is a previous unexpected handler31    assert(old);32    // verify f1 was replace with f233    assert(std::set_unexpected(f2) == f1);34    // verify calling original unexpected handler calls terminate35    std::set_terminate(f3);36    (*old)();37    assert(0);38 39  return 0;40}41