• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10 
11 // <regex>
12 
13 // match_not_eol:
14 //     The last character in the sequence [first,last) shall be treated as
15 //     though it is not at the end of a line, so the character "$" in
16 //     the regular expression shall not match [last,last).
17 
18 #include <regex>
19 #include <cassert>
20 #include "test_macros.h"
21 
main()22 int main()
23 {
24     {
25     std::string target = "foo";
26     std::regex re("foo$");
27     assert( std::regex_match(target, re));
28     assert(!std::regex_match(target, re, std::regex_constants::match_not_eol));
29     }
30 
31     {
32     std::string target = "foo";
33     std::regex re("foo");
34     assert( std::regex_match(target, re));
35     assert( std::regex_match(target, re, std::regex_constants::match_not_eol));
36     }
37 
38     {
39     std::string target = "refoo";
40     std::regex re("foo$");
41     assert( std::regex_search(target, re));
42     assert(!std::regex_search(target, re, std::regex_constants::match_not_eol));
43     }
44 
45     {
46     std::string target = "refoo";
47     std::regex re("foo");
48     assert( std::regex_search(target, re));
49     assert( std::regex_search(target, re, std::regex_constants::match_not_eol));
50     }
51 }
52