[flang-commits] [flang] 0112f6a - [Flang][Runtime][tests] Escape regex special character.

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Thu Jun 10 09:30:29 PDT 2021


Author: Michael Kruse
Date: 2021-06-10T11:30:23-05:00
New Revision: 0112f6ac71517de7767296eda1db26cc4bdb14ee

URL: https://github.com/llvm/llvm-project/commit/0112f6ac71517de7767296eda1db26cc4bdb14ee
DIFF: https://github.com/llvm/llvm-project/commit/0112f6ac71517de7767296eda1db26cc4bdb14ee.diff

LOG: [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

Added: 
    

Modified: 
    flang/unittests/RuntimeGTest/Format.cpp

Removed: 
    


################################################################################
diff  --git a/flang/unittests/RuntimeGTest/Format.cpp b/flang/unittests/RuntimeGTest/Format.cpp
index 63a1801071b4d..e45bc81739b16 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) {


        


More information about the flang-commits mailing list