1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // class regex_token_iterator<BidirectionalIterator, charT, traits>
13 // regex_token_iterator& operator++(int);
17 #include "test_macros.h"
22 std::regex
phone_numbers("\\d{3}-\\d{4}");
23 const char phone_book
[] = "start 555-1234, 555-2345, 555-3456 end";
24 std::cregex_token_iterator
i(std::begin(phone_book
), std::end(phone_book
)-1,
26 std::cregex_token_iterator i2
= i
;
27 std::cregex_token_iterator i3
;
28 assert(i
!= std::cregex_token_iterator());
29 assert(i2
!= std::cregex_token_iterator());
30 assert(i
->str() == "start ");
31 assert(i2
->str() == "start ");
33 assert(i
!= std::cregex_token_iterator());
34 assert(i2
!= std::cregex_token_iterator());
35 assert(i3
!= std::cregex_token_iterator());
36 assert(i
->str() == ", ");
37 assert(i2
->str() == "start ");
38 assert(i3
->str() == "start ");
40 assert(i
!= std::cregex_token_iterator());
41 assert(i2
!= std::cregex_token_iterator());
42 assert(i3
!= std::cregex_token_iterator());
43 assert(i
->str() == ", ");
44 assert(i2
->str() == "start ");
45 assert(i3
->str() == ", ");
47 assert(i
!= std::cregex_token_iterator());
48 assert(i2
!= std::cregex_token_iterator());
49 assert(i3
!= std::cregex_token_iterator());
50 assert(i
->str() == " end");
51 assert(i2
->str() == "start ");
52 assert(i3
->str() == ", ");
54 assert(i
== std::cregex_token_iterator());
55 assert(i2
!= std::cregex_token_iterator());
56 assert(i3
!= std::cregex_token_iterator());
57 assert(i2
->str() == "start ");
58 assert(i3
->str() == " end");
61 std::regex
phone_numbers("\\d{3}-\\d{4}");
62 const char phone_book
[] = "start 555-1234, 555-2345, 555-3456 end";
63 std::cregex_token_iterator
i(std::begin(phone_book
), std::end(phone_book
)-1,
65 std::cregex_token_iterator i2
= i
;
66 std::cregex_token_iterator i3
;
67 assert(i
!= std::cregex_token_iterator());
68 assert(i2
!= std::cregex_token_iterator());
69 assert(i
->str() == "start ");
70 assert(i2
->str() == "start ");
73 assert(i
!= std::cregex_token_iterator());
74 assert(i2
!= std::cregex_token_iterator());
75 assert(i3
!= std::cregex_token_iterator());
76 assert(i
->str() == ", ");
77 assert(i2
->str() == "start ");
78 assert(i3
->str() == "start ");
81 assert(i
!= std::cregex_token_iterator());
82 assert(i2
!= std::cregex_token_iterator());
83 assert(i3
!= std::cregex_token_iterator());
84 assert(i
->str() == ", ");
85 assert(i2
->str() == "start ");
86 assert(i3
->str() == ", ");
89 assert(i
!= std::cregex_token_iterator());
90 assert(i2
!= std::cregex_token_iterator());
91 assert(i3
!= std::cregex_token_iterator());
92 assert(i
->str() == " end");
93 assert(i2
->str() == "start ");
94 assert(i3
->str() == ", ");
97 assert(i
== std::cregex_token_iterator());
98 assert(i2
!= std::cregex_token_iterator());
99 assert(i3
!= std::cregex_token_iterator());
100 assert(i2
->str() == "start ");
101 assert(i3
->str() == " end");
104 std::regex
phone_numbers("\\d{3}-\\d{4}");
105 const char phone_book
[] = "start 555-1234, 555-2345, 555-3456 end";
106 std::cregex_token_iterator
i(std::begin(phone_book
), std::end(phone_book
)-1,
108 assert(i
!= std::cregex_token_iterator());
109 assert(i
->str() == "555-1234");
111 assert(i
!= std::cregex_token_iterator());
112 assert(i
->str() == "555-2345");
114 assert(i
!= std::cregex_token_iterator());
115 assert(i
->str() == "555-3456");
117 assert(i
== std::cregex_token_iterator());
120 std::regex
phone_numbers("\\d{3}-(\\d{4})");
121 const char phone_book
[] = "start 555-1234, 555-2345, 555-3456 end";
122 std::cregex_token_iterator
i(std::begin(phone_book
), std::end(phone_book
)-1,
124 assert(i
!= std::cregex_token_iterator());
125 assert(i
->str() == "1234");
127 assert(i
!= std::cregex_token_iterator());
128 assert(i
->str() == "2345");
130 assert(i
!= std::cregex_token_iterator());
131 assert(i
->str() == "3456");
133 assert(i
== std::cregex_token_iterator());