diff options
author | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2010-01-28 21:50:29 (GMT) |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2010-01-28 21:50:29 (GMT) |
commit | 81e1cc73c83265e54b2ec7edc17e77f4d1b89e86 (patch) | |
tree | 29625437b9179b51a87fa77745ec093d50e8f1b7 /test | |
parent | fd6f2a8a4b3fe8beb31f26b774b460727c410b66 (diff) | |
download | googletest-81e1cc73c83265e54b2ec7edc17e77f4d1b89e86.zip googletest-81e1cc73c83265e54b2ec7edc17e77f4d1b89e86.tar.gz googletest-81e1cc73c83265e54b2ec7edc17e77f4d1b89e86.tar.bz2 |
Introduces macro GTEST_HAS_STREAM_REDIRECTION_ (by Vlad Losev); fixes unsynchronized color text output on Windows (by Vlad Losev); fixes the cmake script to work with MSVC 10 (by Manuel Klimek).
Diffstat (limited to 'test')
-rw-r--r-- | test/gtest_unittest.cc | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc index 16de794..a593494 100644 --- a/test/gtest_unittest.cc +++ b/test/gtest_unittest.cc @@ -184,6 +184,11 @@ using testing::internal::kMaxRandomSeed; using testing::internal::kTestTypeIdInGoogleTest; using testing::internal::scoped_ptr; +#if GTEST_HAS_STREAM_REDIRECTION_ +using testing::internal::CaptureStdout; +using testing::internal::GetCapturedStdout; +#endif // GTEST_HAS_STREAM_REDIRECTION_ + class TestingVector : public Vector<int> { }; @@ -5471,9 +5476,17 @@ class InitGoogleTestTest : public Test { const bool saved_help_flag = ::testing::internal::g_help_flag; ::testing::internal::g_help_flag = false; +#if GTEST_HAS_STREAM_REDIRECTION_ + CaptureStdout(); +#endif // GTEST_HAS_STREAM_REDIRECTION_ + // Parses the command line. internal::ParseGoogleTestFlagsOnly(&argc1, const_cast<CharType**>(argv1)); +#if GTEST_HAS_STREAM_REDIRECTION_ + const String captured_stdout = GetCapturedStdout(); +#endif // GTEST_HAS_STREAM_REDIRECTION_ + // Verifies the flag values. CheckFlags(expected); @@ -5485,8 +5498,16 @@ class InitGoogleTestTest : public Test { // help message for the flags it recognizes. EXPECT_EQ(should_print_help, ::testing::internal::g_help_flag); - // TODO(vladl@google.com): Verify that the help output is not printed - // for recognized flags when stdout capturing is implemeted. +#if GTEST_HAS_STREAM_REDIRECTION_ + const char* const expected_help_fragment = + "This program contains tests written using"; + if (should_print_help) { + EXPECT_PRED_FORMAT2(IsSubstring, expected_help_fragment, captured_stdout); + } else { + EXPECT_PRED_FORMAT2(IsNotSubstring, + expected_help_fragment, captured_stdout); + } +#endif // GTEST_HAS_STREAM_REDIRECTION_ ::testing::internal::g_help_flag = saved_help_flag; } |