brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 2f9f636 Raw
71 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++0310 11// <regex>12 13// class regex_token_iterator<BidirectionalIterator, charT, traits>14 15// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,16//                      const regex_type& re,17//                      initializer_list<int> submatches,18//                      regex_constants::match_flag_type m =19//                                              regex_constants::match_default);20 21// XFAIL: FROZEN-CXX03-HEADERS-FIXME22 23#include <regex>24#include <cassert>25#include <iterator>26 27#include "test_macros.h"28 29int main(int, char**)30{31    {32        std::regex phone_numbers("\\d{3}-(\\d{4})");33        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";34        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,35                                     phone_numbers, {-1, 0, 1});36        assert(i != std::cregex_token_iterator());37        assert(i->str() == "start ");38        ++i;39        assert(i != std::cregex_token_iterator());40        assert(i->str() == "555-1234");41        ++i;42        assert(i != std::cregex_token_iterator());43        assert(i->str() == "1234");44        ++i;45        assert(i != std::cregex_token_iterator());46        assert(i->str() == ", ");47        ++i;48        assert(i != std::cregex_token_iterator());49        assert(i->str() == "555-2345");50        ++i;51        assert(i != std::cregex_token_iterator());52        assert(i->str() == "2345");53        ++i;54        assert(i != std::cregex_token_iterator());55        assert(i->str() == ", ");56        ++i;57        assert(i != std::cregex_token_iterator());58        assert(i->str() == "555-3456");59        ++i;60        assert(i != std::cregex_token_iterator());61        assert(i->str() == "3456");62        ++i;63        assert(i != std::cregex_token_iterator());64        assert(i->str() == " end");65        ++i;66        assert(i == std::cregex_token_iterator());67    }68 69  return 0;70}71