proxygen
gtest_throw_on_failure_test_.cc File Reference
#include "gtest/gtest.h"
#include <stdio.h>
#include <stdlib.h>
#include <exception>

Go to the source code of this file.

Functions

void TerminateHandler ()
 
int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 53 of file gtest_throw_on_failure_test_.cc.

References EXPECT_EQ, testing::InitGoogleTest(), and TerminateHandler().

53  {
54 #if GTEST_HAS_EXCEPTIONS
55  std::set_terminate(&TerminateHandler);
56 #endif
58 
59  // We want to ensure that people can use Google Test assertions in
60  // other testing frameworks, as long as they initialize Google Test
61  // properly and set the throw-on-failure mode. Therefore, we don't
62  // use Google Test's constructs for defining and running tests
63  // (e.g. TEST and RUN_ALL_TESTS) here.
64 
65  // In the throw-on-failure mode with exceptions disabled, this
66  // assertion will cause the program to exit with a non-zero code.
67  EXPECT_EQ(2, 3);
68 
69  // When not in the throw-on-failure mode, the control will reach
70  // here.
71  return 0;
72 }
void TerminateHandler()
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
char ** argv
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: gtest.cc:5370
void TerminateHandler ( )

Definition at line 47 of file gtest_throw_on_failure_test_.cc.

Referenced by main().

47  {
48  fprintf(stderr, "%s\n", "Unhandled C++ exception terminating the program.");
49  fflush(NULL);
50  exit(1);
51 }