Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
gtest_environment_test.cc File Reference
#include <stdlib.h>
#include <stdio.h>
#include "gtest/gtest.h"
#include "src/gtest-internal-inl.h"
Include dependency graph for gtest_environment_test.cc:

Go to the source code of this file.

Namespaces

namespace  testing
 

Functions

 testing::GTEST_DECLARE_string_ (filter)
 
int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 134 of file gtest_environment_test.cc.

134 {
136
137 // Registers a global test environment, and verifies that the
138 // registration function returns its argument.
139 MyEnvironment* const env = new MyEnvironment;
140 Check(testing::AddGlobalTestEnvironment(env) == env,
141 "AddGlobalTestEnvironment() should return its argument.");
142
143 // Verifies that RUN_ALL_TESTS() runs the tests when the global
144 // set-up is successful.
145 Check(RunAllTests(env, NO_FAILURE) != 0,
146 "RUN_ALL_TESTS() should return non-zero, as the global tear-down "
147 "should generate a failure.");
148 Check(test_was_run,
149 "The tests should run, as the global set-up should generate no "
150 "failure");
151 Check(env->tear_down_was_run(),
152 "The global tear-down should run, as the global set-up was run.");
153
154 // Verifies that RUN_ALL_TESTS() runs the tests when the global
155 // set-up generates no fatal failure.
156 Check(RunAllTests(env, NON_FATAL_FAILURE) != 0,
157 "RUN_ALL_TESTS() should return non-zero, as both the global set-up "
158 "and the global tear-down should generate a non-fatal failure.");
159 Check(test_was_run,
160 "The tests should run, as the global set-up should generate no "
161 "fatal failure.");
162 Check(env->tear_down_was_run(),
163 "The global tear-down should run, as the global set-up was run.");
164
165 // Verifies that RUN_ALL_TESTS() runs no test when the global set-up
166 // generates a fatal failure.
167 Check(RunAllTests(env, FATAL_FAILURE) != 0,
168 "RUN_ALL_TESTS() should return non-zero, as the global set-up "
169 "should generate a fatal failure.");
170 Check(!test_was_run,
171 "The tests should not run, as the global set-up should generate "
172 "a fatal failure.");
173 Check(env->tear_down_was_run(),
174 "The global tear-down should run, as the global set-up was run.");
175
176 // Verifies that RUN_ALL_TESTS() doesn't do global set-up or
177 // tear-down when there is no test to run.
178 testing::GTEST_FLAG(filter) = "-*";
179 Check(RunAllTests(env, NO_FAILURE) == 0,
180 "RUN_ALL_TESTS() should return zero, as there is no test to run.");
181 Check(!env->set_up_was_run(),
182 "The global set-up should not run, as there is no test to run.");
183 Check(!env->tear_down_was_run(),
184 "The global tear-down should not run, "
185 "as the global set-up was not run.");
186
187 printf("PASS\n");
188 return 0;
189}
int RunAllTests()
char ** argv
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
Environment * AddGlobalTestEnvironment(Environment *env)
Definition gtest.h:1391
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition gtest.cc:5787
Here is the call graph for this function: