41using ::testing::TestCase;
44using ::testing::TestPartResult;
52 void OnTestProgramStart(
const UnitTest& )
override {}
55 void OnTestProgramEnd(
const UnitTest& unit_test)
override {
56 fprintf(stdout,
"TEST %s\n", unit_test.
Passed() ?
"PASSED" :
"FAILED");
61 void OnTestStart(
const TestInfo& test_info)
override {
63 "*** Test %s.%s starting.\n",
70 void OnTestPartResult(
const TestPartResult& test_part_result)
override {
73 test_part_result.failed() ?
"*** Failure" :
"Success",
74 test_part_result.file_name(),
75 test_part_result.line_number(),
76 test_part_result.summary());
81 void OnTestEnd(
const TestInfo& test_info)
override {
83 "*** Test %s.%s ending.\n",
90TEST(CustomOutputTest, PrintsMessage) {
91 printf(
"Printing something from the test body...\n");
94TEST(CustomOutputTest, Succeeds) {
95 SUCCEED() <<
"SUCCEED() has been invoked from here";
98TEST(CustomOutputTest, Fails) {
100 <<
"This test fails in order to demonstrate alternative failure messages";
104int main(
int argc,
char **argv) {
107 bool terse_output =
false;
108 if (argc > 1 && strcmp(argv[1],
"--terse_output") == 0 )
111 printf(
"%s\n",
"Run this program with --terse_output to change the way "
112 "it prints its output.");
131 listeners.
Append(
new TersePrinter);
137 int unexpectedly_failed_tests = 0;
145 strcmp(test_info.
name(),
"Fails") != 0) {
146 unexpectedly_failed_tests++;
152 if (unexpectedly_failed_tests == 0)
static UnitTest * GetInstance()
TestEventListener * Release(TestEventListener *listener)
void Append(TestEventListener *listener)
TestEventListener * default_result_printer() const
const char * name() const
const TestResult * result() const
const char * test_case_name() const
int total_test_count() const
const TestInfo * GetTestInfo(int i) const
const TestSuite * GetTestSuite(int i) const
TestEventListeners & listeners()
int total_test_suite_count() const
#define EXPECT_EQ(val1, val2)
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
#define TEST(test_suite_name, test_name)
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
GTEST_API_ void InitGoogleTest(int *argc, char **argv)