]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/25_algorithms/copy_n/istreambuf_iterator/1.cc
1 // Copyright (C) 2019-2022 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do run { target c++11 } }
24 #include <testsuite_hooks.h>
28 std::stringstream
ss("12345");
30 std::string
ostr(5, '0');
31 typedef std::istreambuf_iterator
<char> istrb_ite
;
32 auto res
= std::copy_n(istrb_ite(ss
), 0, ostr
.begin());
33 VERIFY( res
== ostr
.begin() );
34 VERIFY( ostr
.front() == '0' );
36 res
= std::copy_n(istrb_ite(ss
), 2, ostr
.begin());
37 VERIFY( res
== ostr
.begin() + 2 );
38 VERIFY( ostr
== "12000" );
40 res
= std::copy_n(istrb_ite(ss
), 3, ostr
.begin() + 2);
41 VERIFY( res
== ostr
.begin() + 5 );
42 VERIFY( ostr
== "12345" );
47 std::stringstream
ss("12345");
49 std::string
ostr(5, '0');
50 typedef std::istreambuf_iterator
<char> istrb_ite
;
53 auto res
= std::copy_n(ibfit
, 3, std::copy_n(ibfit
, 2, ostr
.begin()));
54 VERIFY( res
== ostr
.begin() + 5 );
55 VERIFY( ostr
== "12345" );
60 std::string
ostr(5, '0');
61 typedef std::istreambuf_iterator
<char> istrb_ite
;
63 auto res
= std::copy_n(istrb_ite(), 0, ostr
.begin());
64 VERIFY( res
== ostr
.begin() );