From 0112f6ac71517de7767296eda1db26cc4bdb14ee Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Thu, 10 Jun 2021 11:23:53 -0500 Subject: [PATCH] [Flang][Runtime][tests] Escape regex special character. The second argument of `ASSERT_DEATH` describes a regular expression, in which parentheses have special meaning. Matches of literal parentheses need to be escaped. Fixes failure of InvalidFormatFailure.ParenMismatch and InvalidFormatFailure.ParenMismatch when gtest is compiled with MSVC's regex implementation. Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D104011 --- flang/unittests/RuntimeGTest/Format.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flang/unittests/RuntimeGTest/Format.cpp b/flang/unittests/RuntimeGTest/Format.cpp index 63a1801071b4..e45bc81739b1 100644 --- a/flang/unittests/RuntimeGTest/Format.cpp +++ b/flang/unittests/RuntimeGTest/Format.cpp @@ -153,7 +153,7 @@ TEST(InvalidFormatFailure, ParenMismatch) { ASSERT_DEATH( context.Report(/*edit=*/control.GetNextDataEdit(context, repeat)), - "FORMAT missing at least one ')'"); + R"(FORMAT missing at least one '\)')"); } TEST(InvalidFormatFailure, MissingPrecision) { @@ -166,7 +166,7 @@ TEST(InvalidFormatFailure, MissingPrecision) { ASSERT_DEATH( context.Report(/*edit=*/control.GetNextDataEdit(context, repeat)), - "Invalid FORMAT: integer expected at ')'"); + R"(Invalid FORMAT: integer expected at '\)')"); } TEST(InvalidFormatFailure, MissingFormatWidth) {