@@ -474,27 +474,33 @@ TEST_CASE(simple_period_end_benchmark)
474
474
475
475
TEST_CASE (ECMA262_parse)
476
476
{
477
- constexpr const char * patterns[] {
478
- " ^hello.$" ,
479
- " ^(hello.)$" ,
480
- " ^h{0,1}ello.$" ,
481
- " ^hello\\ W$" ,
482
- " ^hell\\ w.$" ,
483
- " ^hell\\ x6f1$" , // ^hello1$
484
- " ^hel(?:l\\ w).$" ,
485
- " ^hel(?<LO>l\\ w).$" ,
486
- " ^[-a-zA-Z\\ w\\ s]+$" ,
487
- " \\ bhello\\ B" ,
488
- " ^[\\ w+/_-]+[=]{0,2}$" , // #4189
489
- " ^(?:[^<]*(<[\\ w\\ W]+>)[^>]*$|#([\\ w\\ -]*)$)" , // #4189
490
- " \\ /" , // #4189
491
- " ,/=-:" , // #4243
492
- " \\ x" , // Even invalid escapes are allowed if ~unicode.
477
+ struct _test {
478
+ const char * pattern;
479
+ regex::Error expected_error { regex::Error::NoError };
493
480
};
494
481
495
- for (auto & pattern : patterns) {
496
- Regex<ECMA262> re (pattern);
497
- EXPECT_EQ (re.parser_result .error , Error::NoError);
482
+ constexpr _test tests[] {
483
+ { " ^hello.$" },
484
+ { " ^(hello.)$" },
485
+ { " ^h{0,1}ello.$" },
486
+ { " ^hello\\ W$" },
487
+ { " ^hell\\ w.$" },
488
+ { " ^hell\\ x6f1$" }, // ^hello1$
489
+ { " ^hel(?:l\\ w).$" },
490
+ { " ^hel(?<LO>l\\ w).$" },
491
+ { " ^[-a-zA-Z\\ w\\ s]+$" },
492
+ { " \\ bhello\\ B" },
493
+ { " ^[\\ w+/_-]+[=]{0,2}$" }, // #4189
494
+ { " ^(?:[^<]*(<[\\ w\\ W]+>)[^>]*$|#([\\ w\\ -]*)$)" }, // #4189
495
+ { " \\ /" }, // #4189
496
+ { " ,/=-:" }, // #4243
497
+ { " \\ x" }, // Even invalid escapes are allowed if ~unicode.
498
+ { " \\ " , regex::Error::InvalidTrailingEscape },
499
+ };
500
+
501
+ for (auto & test : tests) {
502
+ Regex<ECMA262> re (test.pattern );
503
+ EXPECT_EQ (re.parser_result .error , test.expected_error );
498
504
#ifdef REGEX_DEBUG
499
505
dbg () << " \n " ;
500
506
RegexDebug regex_dbg (stderr);
0 commit comments