| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // <regex> |
| 10 | |
| 11 | // template <class BidirectionalIterator, class Allocator, class charT, class traits> |
| 12 | // bool |
| 13 | // regex_search(BidirectionalIterator first, BidirectionalIterator last, |
| 14 | // match_results<BidirectionalIterator, Allocator>& m, |
| 15 | // const basic_regex<charT, traits>& e, |
| 16 | // regex_constants::match_flag_type flags = regex_constants::match_default); |
| 17 | |
| 18 | #include <regex> |
| 19 | #include <cassert> |
| 20 | #include "test_macros.h" |
| 21 | |
| 22 | int main(int, char**) |
| 23 | { |
| 24 | // Iterating over /^a/ should yield one instance at the beginning |
| 25 | // of the text. |
| 26 | |
| 27 | const char *text = "aaa\naa" ; |
| 28 | std::regex re("^a" ); |
| 29 | std::cregex_iterator it(text, text+6, re); |
| 30 | std::cregex_iterator end = std::cregex_iterator(); |
| 31 | |
| 32 | assert(it->str() == "a" ); |
| 33 | assert(it->position(0) == 0); |
| 34 | assert(it->length(0) == 1); |
| 35 | |
| 36 | ++it; |
| 37 | assert(it == end); |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |