133 {
135
136
137
138 MyEnvironment* const env = new MyEnvironment;
140 "AddGlobalTestEnvironment() should return its argument.");
141
142
143
145 "RUN_ALL_TESTS() should return non-zero, as the global tear-down "
146 "should generate a failure.");
147 Check(test_was_run,
148 "The tests should run, as the global set-up should generate no "
149 "failure");
150 Check(env->tear_down_was_run(),
151 "The global tear-down should run, as the global set-up was run.");
152
153
154
156 "RUN_ALL_TESTS() should return non-zero, as both the global set-up "
157 "and the global tear-down should generate a non-fatal failure.");
158 Check(test_was_run,
159 "The tests should run, as the global set-up should generate no "
160 "fatal failure.");
161 Check(env->tear_down_was_run(),
162 "The global tear-down should run, as the global set-up was run.");
163
164
165
167 "RUN_ALL_TESTS() should return non-zero, as the global set-up "
168 "should generate a fatal failure.");
169 Check(!test_was_run,
170 "The tests should not run, as the global set-up should generate "
171 "a fatal failure.");
172 Check(env->tear_down_was_run(),
173 "The global tear-down should run, as the global set-up was run.");
174
175
176
179 "RUN_ALL_TESTS() should return zero, as there is no test to run.");
180 Check(!env->set_up_was_run(),
181 "The global set-up should not run, as there is no test to run.");
182 Check(!env->tear_down_was_run(),
183 "The global tear-down should not run, "
184 "as the global set-up was not run.");
185
186 printf("PASS\n");
187 return 0;
188}
Environment * AddGlobalTestEnvironment(Environment *env)
GTEST_API_ void InitGoogleTest(int *argc, char **argv)