tesseract v5.3.3.20231005
testing::internal::PrettyUnitTestResultPrinter Class Reference
Inheritance diagram for testing::internal::PrettyUnitTestResultPrinter:
testing::TestEventListener

Public Member Functions

 PrettyUnitTestResultPrinter ()
 
void OnTestProgramStart (const UnitTest &) override
 
void OnTestIterationStart (const UnitTest &unit_test, int iteration) override
 
void OnEnvironmentsSetUpStart (const UnitTest &unit_test) override
 
void OnEnvironmentsSetUpEnd (const UnitTest &) override
 
void OnTestCaseStart (const TestCase &test_case) override
 
void OnTestStart (const TestInfo &test_info) override
 
void OnTestPartResult (const TestPartResult &result) override
 
void OnTestEnd (const TestInfo &test_info) override
 
void OnTestCaseEnd (const TestCase &test_case) override
 
void OnEnvironmentsTearDownStart (const UnitTest &unit_test) override
 
void OnEnvironmentsTearDownEnd (const UnitTest &) override
 
void OnTestIterationEnd (const UnitTest &unit_test, int iteration) override
 
void OnTestProgramEnd (const UnitTest &) override
 
- Public Member Functions inherited from testing::TestEventListener
virtual ~TestEventListener ()
 
virtual void OnTestProgramStart (const UnitTest &unit_test)=0
 
virtual void OnTestIterationStart (const UnitTest &unit_test, int iteration)=0
 
virtual void OnEnvironmentsSetUpStart (const UnitTest &unit_test)=0
 
virtual void OnEnvironmentsSetUpEnd (const UnitTest &unit_test)=0
 
virtual void OnTestSuiteStart (const TestSuite &)
 
virtual void OnTestCaseStart (const TestCase &)
 
virtual void OnTestStart (const TestInfo &test_info)=0
 
virtual void OnTestPartResult (const TestPartResult &test_part_result)=0
 
virtual void OnTestEnd (const TestInfo &test_info)=0
 
virtual void OnTestSuiteEnd (const TestSuite &)
 
virtual void OnTestCaseEnd (const TestCase &)
 
virtual void OnEnvironmentsTearDownStart (const UnitTest &unit_test)=0
 
virtual void OnEnvironmentsTearDownEnd (const UnitTest &unit_test)=0
 
virtual void OnTestIterationEnd (const UnitTest &unit_test, int iteration)=0
 
virtual void OnTestProgramEnd (const UnitTest &unit_test)=0
 

Static Public Member Functions

static void PrintTestName (const char *test_suite, const char *test)
 

Detailed Description

Definition at line 3348 of file gtest.cc.

Constructor & Destructor Documentation

◆ PrettyUnitTestResultPrinter()

testing::internal::PrettyUnitTestResultPrinter::PrettyUnitTestResultPrinter ( )
inline

Definition at line 3350 of file gtest.cc.

3350{}

Member Function Documentation

◆ OnEnvironmentsSetUpEnd()

void testing::internal::PrettyUnitTestResultPrinter::OnEnvironmentsSetUpEnd ( const UnitTest )
inlineoverridevirtual

Implements testing::TestEventListener.

Definition at line 3359 of file gtest.cc.

3359{}

◆ OnEnvironmentsSetUpStart()

void testing::internal::PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart ( const UnitTest unit_test)
overridevirtual

Implements testing::TestEventListener.

Definition at line 3422 of file gtest.cc.

3423 {
3424 ColoredPrintf(GTestColor::kGreen, "[----------] ");
3425 printf("Global test environment set-up.\n");
3426 fflush(stdout);
3427}

◆ OnEnvironmentsTearDownEnd()

void testing::internal::PrettyUnitTestResultPrinter::OnEnvironmentsTearDownEnd ( const UnitTest )
inlineoverridevirtual

Implements testing::TestEventListener.

Definition at line 3377 of file gtest.cc.

3377{}

◆ OnEnvironmentsTearDownStart()

void testing::internal::PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart ( const UnitTest unit_test)
overridevirtual

Implements testing::TestEventListener.

Definition at line 3525 of file gtest.cc.

3526 {
3527 ColoredPrintf(GTestColor::kGreen, "[----------] ");
3528 printf("Global test environment tear-down\n");
3529 fflush(stdout);
3530}

◆ OnTestCaseEnd()

void testing::internal::PrettyUnitTestResultPrinter::OnTestCaseEnd ( const TestCase &  test_case)
overridevirtual

Reimplemented from testing::TestEventListener.

Definition at line 3502 of file gtest.cc.

3502 {
3503 if (!GTEST_FLAG(print_time)) return;
3504
3505 const std::string counts =
3506 FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
3507 ColoredPrintf(GTestColor::kGreen, "[----------] ");
3508 printf("%s from %s (%s ms total)\n\n", counts.c_str(), test_case.name(),
3509 internal::StreamableToString(test_case.elapsed_time()).c_str());
3510 fflush(stdout);
3511}
#define GTEST_FLAG(name)
Definition: gtest-port.h:2205
std::string StreamableToString(const T &streamable)

◆ OnTestCaseStart()

void testing::internal::PrettyUnitTestResultPrinter::OnTestCaseStart ( const TestCase &  test_case)
overridevirtual

Reimplemented from testing::TestEventListener.

Definition at line 3430 of file gtest.cc.

3430 {
3431 const std::string counts =
3432 FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
3433 ColoredPrintf(GTestColor::kGreen, "[----------] ");
3434 printf("%s from %s", counts.c_str(), test_case.name());
3435 if (test_case.type_param() == nullptr) {
3436 printf("\n");
3437 } else {
3438 printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param());
3439 }
3440 fflush(stdout);
3441}

◆ OnTestEnd()

void testing::internal::PrettyUnitTestResultPrinter::OnTestEnd ( const TestInfo test_info)
overridevirtual

Implements testing::TestEventListener.

Definition at line 3480 of file gtest.cc.

3480 {
3481 if (test_info.result()->Passed()) {
3482 ColoredPrintf(GTestColor::kGreen, "[ OK ] ");
3483 } else if (test_info.result()->Skipped()) {
3484 ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
3485 } else {
3486 ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
3487 }
3488 PrintTestName(test_info.test_suite_name(), test_info.name());
3489 if (test_info.result()->Failed())
3490 PrintFullTestCommentIfPresent(test_info);
3491
3492 if (GTEST_FLAG(print_time)) {
3493 printf(" (%s ms)\n", internal::StreamableToString(
3494 test_info.result()->elapsed_time()).c_str());
3495 } else {
3496 printf("\n");
3497 }
3498 fflush(stdout);
3499}
static void PrintTestName(const char *test_suite, const char *test)
Definition: gtest.cc:3351

◆ OnTestIterationEnd()

void testing::internal::PrettyUnitTestResultPrinter::OnTestIterationEnd ( const UnitTest unit_test,
int  iteration 
)
overridevirtual

Implements testing::TestEventListener.

Definition at line 3604 of file gtest.cc.

3605 {
3606 ColoredPrintf(GTestColor::kGreen, "[==========] ");
3607 printf("%s from %s ran.",
3608 FormatTestCount(unit_test.test_to_run_count()).c_str(),
3609 FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());
3610 if (GTEST_FLAG(print_time)) {
3611 printf(" (%s ms total)",
3612 internal::StreamableToString(unit_test.elapsed_time()).c_str());
3613 }
3614 printf("\n");
3615 ColoredPrintf(GTestColor::kGreen, "[ PASSED ] ");
3616 printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str());
3617
3618 const int skipped_test_count = unit_test.skipped_test_count();
3619 if (skipped_test_count > 0) {
3620 ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
3621 printf("%s, listed below:\n", FormatTestCount(skipped_test_count).c_str());
3622 PrintSkippedTests(unit_test);
3623 }
3624
3625 if (!unit_test.Passed()) {
3626 PrintFailedTests(unit_test);
3627 PrintFailedTestSuites(unit_test);
3628 }
3629
3630 int num_disabled = unit_test.reportable_disabled_test_count();
3631 if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
3632 if (unit_test.Passed()) {
3633 printf("\n"); // Add a spacer if no FAILURE banner is displayed.
3634 }
3635 ColoredPrintf(GTestColor::kYellow, " YOU HAVE %d DISABLED %s\n\n",
3636 num_disabled, num_disabled == 1 ? "TEST" : "TESTS");
3637 }
3638 // Ensure that Google Test output is printed before, e.g., heapchecker output.
3639 fflush(stdout);
3640}

◆ OnTestIterationStart()

void testing::internal::PrettyUnitTestResultPrinter::OnTestIterationStart ( const UnitTest unit_test,
int  iteration 
)
overridevirtual

Implements testing::TestEventListener.

Definition at line 3388 of file gtest.cc.

3389 {
3390 if (GTEST_FLAG(repeat) != 1)
3391 printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1);
3392
3393 const char* const filter = GTEST_FLAG(filter).c_str();
3394
3395 // Prints the filter if it's not *. This reminds the user that some
3396 // tests may be skipped.
3397 if (!String::CStringEquals(filter, kUniversalFilter)) {
3398 ColoredPrintf(GTestColor::kYellow, "Note: %s filter = %s\n", GTEST_NAME_,
3399 filter);
3400 }
3401
3402 if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {
3403 const int32_t shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
3404 ColoredPrintf(GTestColor::kYellow, "Note: This is test shard %d of %s.\n",
3405 static_cast<int>(shard_index) + 1,
3406 internal::posix::GetEnv(kTestTotalShards));
3407 }
3408
3409 if (GTEST_FLAG(shuffle)) {
3410 ColoredPrintf(GTestColor::kYellow,
3411 "Note: Randomizing tests' orders with a seed of %d .\n",
3412 unit_test.random_seed());
3413 }
3414
3415 ColoredPrintf(GTestColor::kGreen, "[==========] ");
3416 printf("Running %s from %s.\n",
3417 FormatTestCount(unit_test.test_to_run_count()).c_str(),
3418 FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());
3419 fflush(stdout);
3420}
#define GTEST_NAME_
Definition: gtest-port.h:295
int32_t Int32FromEnvOrDie(const char *var, int32_t default_val)
Definition: gtest.cc:5995
bool ShouldShard(const char *total_shards_env, const char *shard_index_env, bool in_subprocess_for_death_test)
Definition: gtest.cc:5950
const char * GetEnv(const char *name)
Definition: gtest-port.h:2103
static bool CStringEquals(const char *lhs, const char *rhs)
Definition: gtest.cc:1104

◆ OnTestPartResult()

void testing::internal::PrettyUnitTestResultPrinter::OnTestPartResult ( const TestPartResult &  result)
overridevirtual

Implements testing::TestEventListener.

Definition at line 3466 of file gtest.cc.

3467 {
3468 switch (result.type()) {
3469 // If the test part succeeded, we don't need to do anything.
3470 case TestPartResult::kSuccess:
3471 return;
3472 default:
3473 // Print failure message from the assertion
3474 // (e.g. expected this and got that).
3475 PrintTestPartResult(result);
3476 fflush(stdout);
3477 }
3478}

◆ OnTestProgramEnd()

void testing::internal::PrettyUnitTestResultPrinter::OnTestProgramEnd ( const UnitTest )
inlineoverridevirtual

Implements testing::TestEventListener.

Definition at line 3379 of file gtest.cc.

3379{}

◆ OnTestProgramStart()

void testing::internal::PrettyUnitTestResultPrinter::OnTestProgramStart ( const UnitTest )
inlineoverridevirtual

Implements testing::TestEventListener.

Definition at line 3356 of file gtest.cc.

3356{}

◆ OnTestStart()

void testing::internal::PrettyUnitTestResultPrinter::OnTestStart ( const TestInfo test_info)
overridevirtual

Implements testing::TestEventListener.

Definition at line 3458 of file gtest.cc.

3458 {
3459 ColoredPrintf(GTestColor::kGreen, "[ RUN ] ");
3460 PrintTestName(test_info.test_suite_name(), test_info.name());
3461 printf("\n");
3462 fflush(stdout);
3463}

◆ PrintTestName()

static void testing::internal::PrettyUnitTestResultPrinter::PrintTestName ( const char *  test_suite,
const char *  test 
)
inlinestatic

Definition at line 3351 of file gtest.cc.

3351 {
3352 printf("%s.%s", test_suite, test);
3353 }

The documentation for this class was generated from the following file: