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

Go to the source code of this file.

Classes

class  ThrowListener
 

Functions

void Fail (const char *msg)
 
 TEST (Test, Test)
 
 TEST (Test, Test2)
 
int main (int argc, char **argv)
 

Variables

int kTestForContinuingTest = 0
 

Function Documentation

◆ Fail()

void Fail ( const char * msg)

Definition at line 53 of file gtest_assert_by_exception_test.cc.

53 {
54 printf("FAILURE: %s\n", msg);
55 fflush(stdout);
56 exit(1);
57}
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 105 of file gtest_assert_by_exception_test.cc.

105 {
108
109 int result = RUN_ALL_TESTS();
110 if (result == 0) {
111 printf("RUN_ALL_TESTS returned %d\n", result);
112 Fail("Expected failure instead.");
113 }
114
115 if (kTestForContinuingTest == 0) {
116 Fail("Should have continued with other tests, but did not.");
117 }
118 return 0;
119}
void Append(TestEventListener *listener)
Definition gtest.cc:4304
static UnitTest * GetInstance()
Definition gtest.cc:4374
TestEventListeners & listeners()
Definition gtest.cc:4483
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition gtest.h:2328
void Fail(const char *msg)
char ** argv
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition gtest.cc:5787
Here is the call graph for this function:

◆ TEST() [1/2]

TEST ( Test ,
Test  )

Definition at line 65 of file gtest_assert_by_exception_test.cc.

65 {
66 // A successful assertion shouldn't throw.
67 try {
68 EXPECT_EQ(3, 3);
69 } catch(...) {
70 Fail("A successful assertion wrongfully threw.");
71 }
72
73 // A successful assertion shouldn't throw.
74 try {
75 EXPECT_EQ(3, 4);
76 } catch(...) {
77 Fail("A failed non-fatal assertion wrongfully threw.");
78 }
79
80 // A failed assertion should throw.
81 try {
82 AssertFalse();
83 } catch(const testing::AssertionException& e) {
84 if (strstr(e.what(), "Expected failure") != NULL)
85 throw;
86
87 printf("%s",
88 "A failed assertion did throw an exception of the right type, "
89 "but the message is incorrect. Instead of containing \"Expected "
90 "failure\", it is:\n");
91 Fail(e.what());
92 } catch(...) {
93 Fail("A failed assertion threw the wrong type of exception.");
94 }
95 Fail("A failed assertion should've thrown but didn't.");
96}
#define EXPECT_EQ(val1, val2)
Definition gtest.h:1954
Here is the call graph for this function:

◆ TEST() [2/2]

TEST ( Test ,
Test2  )

Definition at line 100 of file gtest_assert_by_exception_test.cc.

100 {
101 // FIXME(sokolov): how to force Test2 to be after Test?
103}

Variable Documentation

◆ kTestForContinuingTest

int kTestForContinuingTest = 0

Definition at line 98 of file gtest_assert_by_exception_test.cc.