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 // template <class ST, class SA>
145a83710eSEric Fiselier // basic_regex(const basic_string<charT, ST, SA>& s,
155a83710eSEric Fiselier // flag_type f = regex_constants::ECMAScript);
165a83710eSEric Fiselier
175a83710eSEric Fiselier #include <regex>
185a83710eSEric Fiselier #include <cassert>
19fd5ceb22SMarshall Clow #include "test_macros.h"
205a83710eSEric Fiselier
215a83710eSEric Fiselier template <class String>
225a83710eSEric Fiselier void
test(const String & p,std::regex_constants::syntax_option_type f,unsigned mc)235a83710eSEric Fiselier test(const String& p, std::regex_constants::syntax_option_type f, unsigned mc)
245a83710eSEric Fiselier {
255a83710eSEric Fiselier std::basic_regex<typename String::value_type> r(p, f);
265a83710eSEric Fiselier assert(r.flags() == f);
275a83710eSEric Fiselier assert(r.mark_count() == mc);
285a83710eSEric Fiselier }
295a83710eSEric Fiselier
main(int,char **)30*2df59c50SJF Bastien int main(int, char**)
315a83710eSEric Fiselier {
325a83710eSEric Fiselier test(std::string("\\(a\\)"), std::regex_constants::basic, 1);
335a83710eSEric Fiselier test(std::string("\\(a[bc]\\)"), std::regex_constants::basic, 1);
345a83710eSEric Fiselier test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::basic, 2);
355a83710eSEric Fiselier test(std::string("(a([bc]))"), std::regex_constants::basic, 0);
365a83710eSEric Fiselier
375a83710eSEric Fiselier test(std::string("\\(a\\)"), std::regex_constants::extended, 0);
385a83710eSEric Fiselier test(std::string("\\(a[bc]\\)"), std::regex_constants::extended, 0);
395a83710eSEric Fiselier test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::extended, 0);
405a83710eSEric Fiselier test(std::string("(a([bc]))"), std::regex_constants::extended, 2);
415a83710eSEric Fiselier
425a83710eSEric Fiselier test(std::string("\\(a\\)"), std::regex_constants::ECMAScript, 0);
435a83710eSEric Fiselier test(std::string("\\(a[bc]\\)"), std::regex_constants::ECMAScript, 0);
445a83710eSEric Fiselier test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::ECMAScript, 0);
455a83710eSEric Fiselier test(std::string("(a([bc]))"), std::regex_constants::ECMAScript, 2);
465a83710eSEric Fiselier
475a83710eSEric Fiselier test(std::string("\\(a\\)"), std::regex_constants::awk, 0);
485a83710eSEric Fiselier test(std::string("\\(a[bc]\\)"), std::regex_constants::awk, 0);
495a83710eSEric Fiselier test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::awk, 0);
505a83710eSEric Fiselier test(std::string("(a([bc]))"), std::regex_constants::awk, 2);
515a83710eSEric Fiselier
525a83710eSEric Fiselier test(std::string("\\(a\\)"), std::regex_constants::grep, 1);
535a83710eSEric Fiselier test(std::string("\\(a[bc]\\)"), std::regex_constants::grep, 1);
545a83710eSEric Fiselier test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::grep, 2);
555a83710eSEric Fiselier test(std::string("(a([bc]))"), std::regex_constants::grep, 0);
565a83710eSEric Fiselier
575a83710eSEric Fiselier test(std::string("\\(a\\)"), std::regex_constants::egrep, 0);
585a83710eSEric Fiselier test(std::string("\\(a[bc]\\)"), std::regex_constants::egrep, 0);
595a83710eSEric Fiselier test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::egrep, 0);
605a83710eSEric Fiselier test(std::string("(a([bc]))"), std::regex_constants::egrep, 2);
61*2df59c50SJF Bastien
62*2df59c50SJF Bastien return 0;
635a83710eSEric Fiselier }
64