diff options
author | timshen <timshen@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-02-26 19:45:15 +0000 |
---|---|---|
committer | timshen <timshen@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-02-26 19:45:15 +0000 |
commit | e92400748dd016b621b55905a1ad9cc5e10331e4 (patch) | |
tree | 46a4b83ab67df5459975d8f47c6a5dc6f1a9001e /libstdc++-v3/testsuite/28_regex/algorithms | |
parent | e5a3303f90fcbcba4d8cd9cdcc0a2c7f45958b25 (diff) | |
download | gcc-e92400748dd016b621b55905a1ad9cc5e10331e4.tar.gz |
2014-02-26 Tim Shen <timshen91@gmail.com>
* include/bits/regex.tcc (match_results<>::format,
regex_replace<>): Update __out after calling std::copy.
* testsuite/28_regex/algorithms/regex_replace/char/dr2213.cc:
Add testcase.
* testsuite/28_regex/match_results/format.cc: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208179 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/28_regex/algorithms')
-rw-r--r-- | libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/dr2213.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/dr2213.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/dr2213.cc new file mode 100644 index 00000000000..b2aeac0230e --- /dev/null +++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/dr2213.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++11" } + +// +// Copyright (C) 2014 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 28.11.4 regex_replace +// Tests ECMAScript regex_replace's _Out_iter return value. + +#include <regex> +#include <testsuite_hooks.h> + +using namespace std; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + char buff[4096] = {0}; + regex re("asdf"); + cmatch m; + string s = "asdf"; + string res = "|asdf|asdf|"; + VERIFY(regex_replace(buff, s.data(), s.data() + s.size(), re, "|&|\\0|", + regex_constants::format_sed) == buff + res.size()); + VERIFY(res == buff); +} + +int +main() +{ + test01(); + return 0; +} |