| the Compartmented Robust Posix C++ Unit Test system | hosted by | 
|---|
A test modifier which states that the normal way to finish the test is via a signal instead of returning from the function.
Used in: The modifier list of a test.
        See TEST(name, ...)
The parameter to
      EXPECT_SIGNAL_DEATH(num)
      is the signal number, or
      ANY_CODE
      if any signal is accepted.
    
If the test finishes through any other means, it fails.
![]()  | Tip | 
|---|---|
EXPECT_SIGNAL_DEATH(SIGABRT)
      is useful together with
      NO_CORE_FILE to verify
      that assert(expr) traps.
     | 
![]()  | Note | 
|---|---|
EXPECT_SIGNAL_DEATH(signo) cannot be used together
      with either of EXPECT_EXIT(num) or
      EXPECT_EXCEPTION(type).
     | 
Example: The test program
     #include <crpcut.hpp>
     
     extern "C"
     {
     #include <signal.h>
     }
     
     TEST(fail_no_signal, EXPECT_SIGNAL_DEATH(ANY_CODE))
     {
     }
     
     TEST(pass_sigabort, EXPECT_SIGNAL_DEATH(SIGABRT), NO_CORE_FILE)
     {
       abort();
     }
     
     TEST(fail_wrong_signal, EXPECT_SIGNAL_DEATH(SIGABRT), NO_CORE_FILE)
     {
       int *p = 0;
       *p = 1;
     }
     
     TEST(fail_by_exception, EXPECT_SIGNAL_DEATH(ANY_CODE))
     {
       throw std::bad_alloc();
     }
     
     int main(int argc, char *argv[])
     {
       return crpcut::run(argc, argv);
     }
reports three failed tests:
     FAILED: fail_no_signal
     phase="running"  --------------------------------------------------------------
     Unexpectedly survived
     Expected any signal
     -------------------------------------------------------------------------------
     ===============================================================================
     FAILED: fail_wrong_signal
     phase="post_mortem"  ----------------------------------------------------------
     Died on signal 11
     Expected signal 6
     -------------------------------------------------------------------------------
     ===============================================================================
     FAILED: fail_by_exception
     phase="running"  --------------------------------------------------------------
     Unexpectedly caught std::exception
       what()=std::bad_alloc
     -------------------------------------------------------------------------------
     ===============================================================================
     Total 4 test cases selected
     UNTESTED : 0
     PASSED   : 1
     FAILED   : 3