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