134 {
136
137
138
139 MyEnvironment* const env = new MyEnvironment;
141 "AddGlobalTestEnvironment() should return its argument.");
142
143
144
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
155
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
166
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
177
178 testing::GTEST_FLAG(filter) = "-*";
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
188 return 0;
189}
LOGGING_API void printf(Category category, const char *format,...)
Environment * AddGlobalTestEnvironment(Environment *env)
GTEST_API_ void InitGoogleTest(int *argc, char **argv)