165793Smsmith// { dg-options "-std=gnu++11" }
265793Smsmith
381082Sscottl//
465793Smsmith// 2010-06-21  Stephen M. Webb <stephen.webb@bregmasoft.ca>
581082Sscottl//
665793Smsmith// Copyright (C) 2010-2015 Free Software Foundation, Inc.
765793Smsmith//
865793Smsmith// This file is part of the GNU ISO C++ Library.  This library is free
965793Smsmith// software; you can redistribute it and/or modify it under the
1065793Smsmith// terms of the GNU General Public License as published by the
1165793Smsmith// Free Software Foundation; either version 3, or (at your option)
1265793Smsmith// any later version.
1365793Smsmith//
1465793Smsmith// This library is distributed in the hope that it will be useful,
1565793Smsmith// but WITHOUT ANY WARRANTY; without even the implied warranty of
1665793Smsmith// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1765793Smsmith// GNU General Public License for more details.
1865793Smsmith//
1965793Smsmith// You should have received a copy of the GNU General Public License along
2065793Smsmith// with this library; see the file COPYING3.  If not see
2165793Smsmith// <http://www.gnu.org/licenses/>.
2265793Smsmith
2365793Smsmith// 28.11.2 regex_match
2465793Smsmith// Tests ERE against a C-string target, question-mark match.
2565793Smsmith
2665793Smsmith#include <regex>
2765793Smsmith#include <testsuite_hooks.h>
2865793Smsmith#include <testsuite_regex.h>
2965793Smsmith
30119418Sobrienusing namespace __gnu_test;
31119418Sobrienusing namespace std;
32119418Sobrien
3381151Sscottlvoid
3481151Sscottltest01()
3565793Smsmith{
3665793Smsmith  bool test __attribute__((unused)) = true;
3765793Smsmith
38129879Sphk  std::regex  re("(aa?)", std::regex::extended);
3965793Smsmith  char target[] = "a";
4065793Smsmith  std::cmatch m;
4165793Smsmith
4265793Smsmith  VERIFY( regex_match_debug(target, m, re) );
4365793Smsmith
4482527Sscottl  VERIFY( re.mark_count() == 1 );
4582527Sscottl  VERIFY( m.size()  == re.mark_count()+1 );
4682527Sscottl  VERIFY( m.empty() == false );
4782527Sscottl  VERIFY( m.prefix().first == target );
4865793Smsmith  VERIFY( m.prefix().second == target );
4965793Smsmith  VERIFY( m.prefix().matched == false );
5065793Smsmith  VERIFY( m.suffix().first == target+sizeof(target)-1 );
5165793Smsmith  VERIFY( m.suffix().second == target+sizeof(target)-1 );
52138635Sscottl  VERIFY( m.suffix().matched == false );
5365793Smsmith  VERIFY( m[0].first == target );
5465793Smsmith  VERIFY( m[0].second == target+sizeof(target)-1 );
5565793Smsmith  VERIFY( m[0].matched == true );
5665793Smsmith  VERIFY( m[1].first == target );
5765793Smsmith  VERIFY( m[1].second == target+sizeof(target)-1 );
5865793Smsmith  VERIFY( m[1].matched == true );
5965793Smsmith
6065793Smsmith  VERIFY(regex_match_debug("", std::regex("a?", std::regex::extended)));
6165793Smsmith  VERIFY(regex_match_debug("a", std::regex("a?", std::regex::extended)));
6265793Smsmith  VERIFY(!regex_match_debug("aa", std::regex("a?", std::regex::extended)));
6365793Smsmith}
6465793Smsmith
65111525Sscottl
66111525Sscottlint
67111525Sscottlmain()
68111220Sphk{
6965793Smsmith  test01();
7089112Smsmith  return 0;
7165793Smsmith}
7265793Smsmith
7383114Sscottl