Commit be4edfec authored by Karandeep Bhatia's avatar Karandeep Bhatia Committed by Commit Bot

Fix ErrorUtils.FormatErrorMessage_Death in official builds.

ErrorUtils.FormatErrorMessage_Death fails on official builds because
failure messages aren't passed to CHECK in official builds. Modify the death
regex for the test in official builds and fix the test.

BUG=934831

Change-Id: I4b301410ce990e3ced014c5fa82c42d1fea98cce
Reviewed-on: https://chromium-review.googlesource.com/c/1483938
Auto-Submit: Karan Bhatia <karandeepb@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634845}
parent 058e3d26
...@@ -50,15 +50,24 @@ TEST(ErrorUtils, FormatErrorMessage_Death) { ...@@ -50,15 +50,24 @@ TEST(ErrorUtils, FormatErrorMessage_Death) {
} cases[] = {{"Hello * Bye * *", "arg1", "arg2", "More placeholders"}, } cases[] = {{"Hello * Bye * *", "arg1", "arg2", "More placeholders"},
{"Hello * Bye", "arg1", "arg2", "Fewer placeholders"}}; {"Hello * Bye", "arg1", "arg2", "Fewer placeholders"}};
auto get_death_regex = [](const char* death_message_regex) {
// String arguments aren't passed to CHECK() in official builds.
#if defined(OFFICIAL_BUILD) && defined(NDEBUG)
return "";
#else
return death_message_regex;
#endif
};
for (const auto& test_case : cases) { for (const auto& test_case : cases) {
SCOPED_TRACE(test_case.format); SCOPED_TRACE(test_case.format);
EXPECT_DEATH(ErrorUtils::FormatErrorMessage(test_case.format, test_case.s1, EXPECT_DEATH(ErrorUtils::FormatErrorMessage(test_case.format, test_case.s1,
test_case.s2), test_case.s2),
test_case.death_message_regex); get_death_regex(test_case.death_message_regex));
EXPECT_DEATH(ErrorUtils::FormatErrorMessageUTF16( EXPECT_DEATH(ErrorUtils::FormatErrorMessageUTF16(
test_case.format, test_case.s1, test_case.s2), test_case.format, test_case.s1, test_case.s2),
test_case.death_message_regex); get_death_regex(test_case.death_message_regex));
} }
} }
#endif // defined(GTEST_HAS_DEATH_TEST) #endif // defined(GTEST_HAS_DEATH_TEST)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment