• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <regex>
11 
12 // match_not_eol:
13 //     The last character in the sequence [first,last) shall be treated as
14 //     though it is not at the end of a line, so the character "$" in
15 //     the regular expression shall not match [last,last).
16 
17 #include <regex>
18 #include <cassert>
19 #include "test_macros.h"
20 
main(int,char **)21 int main(int, char**)
22 {
23     {
24     std::string target = "foo";
25     std::regex re("foo$");
26     assert( std::regex_match(target, re));
27     assert(!std::regex_match(target, re, std::regex_constants::match_not_eol));
28     }
29 
30     {
31     std::string target = "foo";
32     std::regex re("foo");
33     assert( std::regex_match(target, re));
34     assert( std::regex_match(target, re, std::regex_constants::match_not_eol));
35     }
36 
37     {
38     std::string target = "refoo";
39     std::regex re("foo$");
40     assert( std::regex_search(target, re));
41     assert(!std::regex_search(target, re, std::regex_constants::match_not_eol));
42     }
43 
44     {
45     std::string target = "refoo";
46     std::regex re("foo");
47     assert( std::regex_search(target, re));
48     assert( std::regex_search(target, re, std::regex_constants::match_not_eol));
49     }
50 
51   return 0;
52 }
53