xref: /llvm-project/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size.pass.cpp (revision 2df59c50688c122bbcae7467d3eaf862c3ea3088)
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 charT, class traits = regex_traits<charT>> class basic_regex;
12 
13 // basic_regex(const charT* p, size_t len);
14 
15 #include <regex>
16 #include <cassert>
17 
18 template <class CharT>
19 void
20 test(const CharT* p, std::size_t len, unsigned mc)
21 {
22     std::basic_regex<CharT> r(p, len);
23     assert(r.flags() == std::regex_constants::ECMAScript);
24     assert(r.mark_count() == mc);
25 }
26 
27 int main(int, char**)
28 {
29     test("\\(a\\)", 5, 0);
30     test("\\(a[bc]\\)", 9, 0);
31     test("\\(a\\([bc]\\)\\)", 13, 0);
32     test("(a([bc]))", 9, 2);
33 
34     test("(\0)(b)(c)(d)", 12, 4);
35     test("(\0)(b)(c)(d)", 9, 3);
36     test("(\0)(b)(c)(d)", 3, 1);
37     test("(\0)(b)(c)(d)", 0, 0);
38 
39   return 0;
40 }
41