111820Sjulian// { dg-options "-std=gnu++11" } 211820Sjulian 311820Sjulian// 411820Sjulian// 2010-06-21 Stephen M. Webb <stephen.webb@bregmasoft.ca> 511820Sjulian// 611820Sjulian// Copyright (C) 2010-2015 Free Software Foundation, Inc. 711820Sjulian// 811820Sjulian// This file is part of the GNU ISO C++ Library. This library is free 911820Sjulian// software; you can redistribute it and/or modify it under the 1011820Sjulian// terms of the GNU General Public License as published by the 1111820Sjulian// Free Software Foundation; either version 3, or (at your option) 1211820Sjulian// any later version. 1311820Sjulian// 1411820Sjulian// This library is distributed in the hope that it will be useful, 1511820Sjulian// but WITHOUT ANY WARRANTY; without even the implied warranty of 1611820Sjulian// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1711820Sjulian// GNU General Public License for more details. 1811820Sjulian// 1911820Sjulian// You should have received a copy of the GNU General Public License along 2011820Sjulian// with this library; see the file COPYING3. If not see 2111820Sjulian// <http://www.gnu.org/licenses/>. 2211820Sjulian 2311820Sjulian// 28.11.2 regex_match 2411820Sjulian// Tests ERE against a C-string target, plus-sign match. 2511820Sjulian 2611820Sjulian#include <regex> 2711820Sjulian#include <testsuite_hooks.h> 2811820Sjulian#include <testsuite_regex.h> 2911820Sjulian 3011820Sjulianusing namespace __gnu_test; 3111820Sjulianusing namespace std; 3211820Sjulian 3311820Sjulianvoid 3411820Sjuliantest01() 3511820Sjulian{ 3611820Sjulian bool test __attribute__((unused)) = true; 3711820Sjulian 3811820Sjulian std::regex re("(a+)", std::regex::extended); 3911820Sjulian const char target[] = "aa"; 4011820Sjulian std::cmatch m; 4111820Sjulian 4211820Sjulian VERIFY( regex_match_debug(target, m, re) ); 4311820Sjulian 4411820Sjulian VERIFY( re.mark_count() == 1 ); 4511820Sjulian VERIFY( m.size() == re.mark_count()+1 ); 4611820Sjulian VERIFY( m.empty() == false ); 4711820Sjulian VERIFY( m.prefix().first == target ); 4811820Sjulian VERIFY( m.prefix().second == target ); 4911820Sjulian VERIFY( m.prefix().matched == false ); 5011820Sjulian VERIFY( m.suffix().first == target+sizeof(target)-1 ); 5111820Sjulian VERIFY( m.suffix().second == target+sizeof(target)-1 ); 5211820Sjulian VERIFY( m.suffix().matched == false ); 5311820Sjulian VERIFY( m[0].first == target ); 5411820Sjulian VERIFY( m[0].second == target+sizeof(target)-1 ); 5511820Sjulian VERIFY( m[0].matched == true ); 5611820Sjulian VERIFY( m[1].first == target ); 5711820Sjulian VERIFY( m[1].second == target+sizeof(target)-1 ); 5811820Sjulian VERIFY( m[1].matched == true ); 5911820Sjulian 6011820Sjulian VERIFY(!regex_match_debug("", std::regex("a+", std::regex::extended))); 6111820Sjulian VERIFY(regex_match_debug("a", std::regex("a+", std::regex::extended))); 6211820Sjulian VERIFY(regex_match_debug("aa", std::regex("a+", std::regex::extended))); 6311820Sjulian} 6411820Sjulian 6511820Sjulian 6611820Sjulianint 6711820Sjulianmain() 6811820Sjulian{ 6911820Sjulian test01(); 7011820Sjulian return 0; 7111820Sjulian} 7211820Sjulian 7311820Sjulian