1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <regex>
11
12 // template <class BidirectionalIterator, class Allocator, class charT, class traits>
13 // bool
14 // regex_match(BidirectionalIterator first, BidirectionalIterator last,
15 // match_results<BidirectionalIterator, Allocator>& m,
16 // const basic_regex<charT, traits>& e,
17 // regex_constants::match_flag_type flags = regex_constants::match_default);
18
19 #include <regex>
20 #include <cassert>
21
22 #include "test_macros.h"
23 #include "test_iterators.h"
24
main()25 int main()
26 {
27 {
28 std::cmatch m;
29 const char s[] = "tournament";
30 assert(std::regex_match(s, m, std::regex("tour\nto\ntournament",
31 std::regex_constants::grep)));
32 assert(m.size() == 1);
33 assert(!m.prefix().matched);
34 assert(m.prefix().first == s);
35 assert(m.prefix().second == m[0].first);
36 assert(!m.suffix().matched);
37 assert(m.suffix().first == m[0].second);
38 assert(m.suffix().second == s + std::char_traits<char>::length(s));
39 assert(m.length(0) == 10);
40 assert(m.position(0) == 0);
41 assert(m.str(0) == "tournament");
42 }
43 {
44 std::cmatch m;
45 const char s[] = "ment";
46 assert(!std::regex_match(s, m, std::regex("tour\n\ntournament",
47 std::regex_constants::grep)));
48 assert(m.size() == 0);
49 }
50 }
51