Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
gtest_throw_on_failure_ex_test.cc File Reference
#include "gtest/gtest.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdexcept>
Include dependency graph for gtest_throw_on_failure_ex_test.cc:

Go to the source code of this file.

Functions

void Fail (const char *msg)
 
void TestFailureThrowsRuntimeError ()
 
int main (int argc, char **argv)
 

Function Documentation

◆ Fail()

void Fail ( const char * msg)

Definition at line 45 of file gtest_throw_on_failure_ex_test.cc.

45 {
46 printf("FAILURE: %s\n", msg);
47 fflush(stdout);
48 exit(1);
49}
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
Here is the caller graph for this function:

◆ main()

int main ( int argc,
char ** argv )

Definition at line 81 of file gtest_throw_on_failure_ex_test.cc.

81 {
83
84 // We want to ensure that people can use Google Test assertions in
85 // other testing frameworks, as long as they initialize Google Test
86 // properly and set the thrown-on-failure mode. Therefore, we don't
87 // use Google Test's constructs for defining and running tests
88 // (e.g. TEST and RUN_ALL_TESTS) here.
89
91 return 0;
92}
void TestFailureThrowsRuntimeError()
char ** argv
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition gtest.cc:5787
Here is the call graph for this function:

◆ TestFailureThrowsRuntimeError()

void TestFailureThrowsRuntimeError ( )

Definition at line 53 of file gtest_throw_on_failure_ex_test.cc.

53 {
54 testing::GTEST_FLAG(throw_on_failure) = true;
55
56 // A successful assertion shouldn't throw.
57 try {
58 EXPECT_EQ(3, 3);
59 } catch(...) {
60 Fail("A successful assertion wrongfully threw.");
61 }
62
63 // A failed assertion should throw a subclass of std::runtime_error.
64 try {
65 EXPECT_EQ(2, 3) << "Expected failure";
66 } catch(const std::runtime_error& e) {
67 if (strstr(e.what(), "Expected failure") != NULL)
68 return;
69
70 printf("%s",
71 "A failed assertion did throw an exception of the right type, "
72 "but the message is incorrect. Instead of containing \"Expected "
73 "failure\", it is:\n");
74 Fail(e.what());
75 } catch(...) {
76 Fail("A failed assertion threw the wrong type of exception.");
77 }
78 Fail("A failed assertion should've thrown but didn't.");
79}
#define EXPECT_EQ(val1, val2)
Definition gtest.h:1954
void Fail(const char *msg)
Here is the call graph for this function:
Here is the caller graph for this function: