Replace EXPECT_STDOUT and EXPECT_STDERR with a single macro EXPECT_WRITE.

This commit is contained in:
Victor Zverovich
2014-05-05 08:35:59 -07:00
parent 098f8ac343
commit 0aacd0cf6d
3 changed files with 48 additions and 29 deletions
+4 -8
View File
@@ -337,7 +337,7 @@ class OutputRedirect {
std::string RestoreAndRead();
};
#define FMT_TEST_PRINT_(statement, expected_output, file, fail) \
#define FMT_TEST_WRITE_(statement, expected_output, file, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::AssertionResult gtest_ar = ::testing::AssertionSuccess()) { \
std::string gtest_expected_output = expected_output; \
@@ -355,13 +355,9 @@ class OutputRedirect {
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
fail(gtest_ar.failure_message())
// Tests that the statement prints the expected output to stdout.
#define EXPECT_STDOUT(statement, expected_output) \
FMT_TEST_PRINT_(statement, expected_output, stdout, GTEST_NONFATAL_FAILURE_)
// Tests that the statement prints the expected output to stderr.
#define EXPECT_STDERR(statement, expected_output) \
FMT_TEST_PRINT_(statement, expected_output, stderr, GTEST_NONFATAL_FAILURE_)
// Tests that the statement writes the expected output to file.
#define EXPECT_WRITE(file, statement, expected_output) \
FMT_TEST_WRITE_(statement, expected_output, file, GTEST_NONFATAL_FAILURE_)
#endif // FMT_USE_FILE_DESCRIPTORS