15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier
95a83710eSEric Fiselier // <regex>
105a83710eSEric Fiselier
115a83710eSEric Fiselier // template <class charT, class traits = regex_traits<charT>> class basic_regex;
125a83710eSEric Fiselier
135a83710eSEric Fiselier // basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
145a83710eSEric Fiselier
155a83710eSEric Fiselier #include <regex>
165a83710eSEric Fiselier #include <cassert>
17fd5ceb22SMarshall Clow #include "test_macros.h"
185a83710eSEric Fiselier
195a83710eSEric Fiselier template <class CharT>
205a83710eSEric Fiselier void
test(const CharT * p,std::regex_constants::syntax_option_type f,unsigned mc)215a83710eSEric Fiselier test(const CharT* p, std::regex_constants::syntax_option_type f, unsigned mc)
225a83710eSEric Fiselier {
235a83710eSEric Fiselier std::basic_regex<CharT> r(p, f);
245a83710eSEric Fiselier assert(r.flags() == f);
255a83710eSEric Fiselier assert(r.mark_count() == mc);
265a83710eSEric Fiselier }
275a83710eSEric Fiselier
main(int,char **)28*2df59c50SJF Bastien int main(int, char**)
295a83710eSEric Fiselier {
305a83710eSEric Fiselier test("\\(a\\)", std::regex_constants::basic, 1);
315a83710eSEric Fiselier test("\\(a[bc]\\)", std::regex_constants::basic, 1);
325a83710eSEric Fiselier test("\\(a\\([bc]\\)\\)", std::regex_constants::basic, 2);
335a83710eSEric Fiselier test("(a([bc]))", std::regex_constants::basic, 0);
345a83710eSEric Fiselier
355a83710eSEric Fiselier test("\\(a\\)", std::regex_constants::extended, 0);
365a83710eSEric Fiselier test("\\(a[bc]\\)", std::regex_constants::extended, 0);
375a83710eSEric Fiselier test("\\(a\\([bc]\\)\\)", std::regex_constants::extended, 0);
385a83710eSEric Fiselier test("(a([bc]))", std::regex_constants::extended, 2);
395a83710eSEric Fiselier
405a83710eSEric Fiselier test("\\(a\\)", std::regex_constants::ECMAScript, 0);
415a83710eSEric Fiselier test("\\(a[bc]\\)", std::regex_constants::ECMAScript, 0);
425a83710eSEric Fiselier test("\\(a\\([bc]\\)\\)", std::regex_constants::ECMAScript, 0);
435a83710eSEric Fiselier test("(a([bc]))", std::regex_constants::ECMAScript, 2);
445a83710eSEric Fiselier
455a83710eSEric Fiselier test("\\(a\\)", std::regex_constants::awk, 0);
465a83710eSEric Fiselier test("\\(a[bc]\\)", std::regex_constants::awk, 0);
475a83710eSEric Fiselier test("\\(a\\([bc]\\)\\)", std::regex_constants::awk, 0);
485a83710eSEric Fiselier test("(a([bc]))", std::regex_constants::awk, 2);
495a83710eSEric Fiselier
505a83710eSEric Fiselier test("\\(a\\)", std::regex_constants::grep, 1);
515a83710eSEric Fiselier test("\\(a[bc]\\)", std::regex_constants::grep, 1);
525a83710eSEric Fiselier test("\\(a\\([bc]\\)\\)", std::regex_constants::grep, 2);
535a83710eSEric Fiselier test("(a([bc]))", std::regex_constants::grep, 0);
545a83710eSEric Fiselier
555a83710eSEric Fiselier test("\\(a\\)", std::regex_constants::egrep, 0);
565a83710eSEric Fiselier test("\\(a[bc]\\)", std::regex_constants::egrep, 0);
575a83710eSEric Fiselier test("\\(a\\([bc]\\)\\)", std::regex_constants::egrep, 0);
585a83710eSEric Fiselier test("(a([bc]))", std::regex_constants::egrep, 2);
59*2df59c50SJF Bastien
60*2df59c50SJF Bastien return 0;
615a83710eSEric Fiselier }
62