tesseract v5.3.3.20231005
testing::ParseFlagsTest Class Reference
Inheritance diagram for testing::ParseFlagsTest:
testing::Test

Protected Member Functions

void SetUp () override
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
virtual void SetUp ()
 
virtual void TearDown ()
 

Static Protected Member Functions

template<typename CharType >
static void AssertStringArrayEq (int size1, CharType **array1, int size2, CharType **array2)
 
static void CheckFlags (const Flags &expected)
 
template<typename CharType >
static void TestParsingFlags (int argc1, const CharType **argv1, int argc2, const CharType **argv2, const Flags &expected, bool should_print_help)
 

Additional Inherited Members

- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
- Static Public Member Functions inherited from testing::Test
static void SetUpTestSuite ()
 
static void TearDownTestSuite ()
 
static void TearDownTestCase ()
 
static void SetUpTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool IsSkipped ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 

Detailed Description

Definition at line 5738 of file gtest_unittest.cc.

Member Function Documentation

◆ AssertStringArrayEq()

template<typename CharType >
static void testing::ParseFlagsTest::AssertStringArrayEq ( int  size1,
CharType **  array1,
int  size2,
CharType **  array2 
)
inlinestaticprotected

Definition at line 5762 of file gtest_unittest.cc.

5763 {
5764 ASSERT_EQ(size1, size2) << " Array sizes different.";
5765
5766 for (int i = 0; i != size1; i++) {
5767 ASSERT_STREQ(array1[i], array2[i]) << " where i == " << i;
5768 }
5769 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:2073
#define ASSERT_STREQ(s1, s2)
Definition: gtest.h:2121

◆ CheckFlags()

static void testing::ParseFlagsTest::CheckFlags ( const Flags expected)
inlinestaticprotected

Definition at line 5772 of file gtest_unittest.cc.

5772 {
5773 EXPECT_EQ(expected.also_run_disabled_tests,
5774 GTEST_FLAG(also_run_disabled_tests));
5775 EXPECT_EQ(expected.break_on_failure, GTEST_FLAG(break_on_failure));
5776 EXPECT_EQ(expected.catch_exceptions, GTEST_FLAG(catch_exceptions));
5777 EXPECT_EQ(expected.death_test_use_fork, GTEST_FLAG(death_test_use_fork));
5778 EXPECT_EQ(expected.fail_fast, GTEST_FLAG(fail_fast));
5779 EXPECT_STREQ(expected.filter, GTEST_FLAG(filter).c_str());
5780 EXPECT_EQ(expected.list_tests, GTEST_FLAG(list_tests));
5781 EXPECT_STREQ(expected.output, GTEST_FLAG(output).c_str());
5782 EXPECT_EQ(expected.brief, GTEST_FLAG(brief));
5783 EXPECT_EQ(expected.print_time, GTEST_FLAG(print_time));
5784 EXPECT_EQ(expected.random_seed, GTEST_FLAG(random_seed));
5785 EXPECT_EQ(expected.repeat, GTEST_FLAG(repeat));
5786 EXPECT_EQ(expected.shuffle, GTEST_FLAG(shuffle));
5787 EXPECT_EQ(expected.stack_trace_depth, GTEST_FLAG(stack_trace_depth));
5788 EXPECT_STREQ(expected.stream_result_to,
5789 GTEST_FLAG(stream_result_to).c_str());
5790 EXPECT_EQ(expected.throw_on_failure, GTEST_FLAG(throw_on_failure));
5791 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:2043
#define EXPECT_STREQ(s1, s2)
Definition: gtest.h:2112
#define GTEST_FLAG(name)
Definition: gtest-port.h:2205

◆ SetUp()

void testing::ParseFlagsTest::SetUp ( )
inlineoverrideprotectedvirtual

Reimplemented from testing::Test.

Definition at line 5741 of file gtest_unittest.cc.

5741 {
5742 GTEST_FLAG(also_run_disabled_tests) = false;
5743 GTEST_FLAG(break_on_failure) = false;
5744 GTEST_FLAG(catch_exceptions) = false;
5745 GTEST_FLAG(death_test_use_fork) = false;
5746 GTEST_FLAG(fail_fast) = false;
5747 GTEST_FLAG(filter) = "";
5748 GTEST_FLAG(list_tests) = false;
5749 GTEST_FLAG(output) = "";
5750 GTEST_FLAG(brief) = false;
5751 GTEST_FLAG(print_time) = true;
5752 GTEST_FLAG(random_seed) = 0;
5753 GTEST_FLAG(repeat) = 1;
5754 GTEST_FLAG(shuffle) = false;
5755 GTEST_FLAG(stack_trace_depth) = kMaxStackTraceDepth;
5756 GTEST_FLAG(stream_result_to) = "";
5757 GTEST_FLAG(throw_on_failure) = false;
5758 }

◆ TestParsingFlags()

template<typename CharType >
static void testing::ParseFlagsTest::TestParsingFlags ( int  argc1,
const CharType **  argv1,
int  argc2,
const CharType **  argv2,
const Flags expected,
bool  should_print_help 
)
inlinestaticprotected

Definition at line 5797 of file gtest_unittest.cc.

5799 {
5800 const bool saved_help_flag = ::testing::internal::g_help_flag;
5802
5803# if GTEST_HAS_STREAM_REDIRECTION
5804 CaptureStdout();
5805# endif
5806
5807 // Parses the command line.
5808 internal::ParseGoogleTestFlagsOnly(&argc1, const_cast<CharType**>(argv1));
5809
5810# if GTEST_HAS_STREAM_REDIRECTION
5811 const std::string captured_stdout = GetCapturedStdout();
5812# endif
5813
5814 // Verifies the flag values.
5815 CheckFlags(expected);
5816
5817 // Verifies that the recognized flags are removed from the command
5818 // line.
5819 AssertStringArrayEq(argc1 + 1, argv1, argc2 + 1, argv2);
5820
5821 // ParseGoogleTestFlagsOnly should neither set g_help_flag nor print the
5822 // help message for the flags it recognizes.
5823 EXPECT_EQ(should_print_help, ::testing::internal::g_help_flag);
5824
5825# if GTEST_HAS_STREAM_REDIRECTION
5826 const char* const expected_help_fragment =
5827 "This program contains tests written using";
5828 if (should_print_help) {
5829 EXPECT_PRED_FORMAT2(IsSubstring, expected_help_fragment, captured_stdout);
5830 } else {
5832 expected_help_fragment, captured_stdout);
5833 }
5834# endif // GTEST_HAS_STREAM_REDIRECTION
5835
5836 ::testing::internal::g_help_flag = saved_help_flag;
5837 }
#define EXPECT_PRED_FORMAT2(pred_format, v1, v2)
GTEST_API_ AssertionResult IsNotSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)
Definition: gtest.cc:1789
GTEST_API_ AssertionResult IsSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)
Definition: gtest.cc:1777
void ParseGoogleTestFlagsOnly(int *argc, char **argv)
Definition: gtest.cc:6607
bool g_help_flag
Definition: gtest.cc:178
GTEST_API_ void CaptureStdout()
GTEST_API_ std::string GetCapturedStdout()
static void CheckFlags(const Flags &expected)
static void AssertStringArrayEq(int size1, CharType **array1, int size2, CharType **array2)

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