#include "gtest/gtest.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdexcept>
Go to the source code of this file.
◆ Fail()
| void Fail |
( |
const char * | msg | ) |
|
◆ main()
| int main |
( |
int | argc, |
|
|
char ** | argv ) |
Definition at line 81 of file gtest_throw_on_failure_ex_test.cc.
81 {
83
84
85
86
87
88
89
91 return 0;
92}
void TestFailureThrowsRuntimeError()
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
◆ 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
57 try {
59 } catch(...) {
60 Fail(
"A successful assertion wrongfully threw.");
61 }
62
63
64 try {
66 } catch(const std::runtime_error& e) {
67 if (strstr(e.what(), "Expected failure") != NULL)
68 return;
69
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");
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)
void Fail(const char *msg)