]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_syncbuf/basic_ops/1.cc
1 // Copyright (C) 2020-2024 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-additional-options "-pthread" { target pthread } }
19 // { dg-do run { target c++20 } }
20 // { dg-require-effective-target cxx11_abi }
23 #include <string_view>
26 #include <testsuite_allocator.h>
27 #include <testsuite_hooks.h>
30 test01() // construction
34 VERIFY( s1
.get_wrapped() == nullptr );
38 VERIFY( s2
.get_wrapped() == &b
);
42 using alloc_type
= __gnu_test::uneq_allocator
<char>;
43 using sbuf_t
= std::basic_syncbuf
<char, std::char_traits
<char>,
50 VERIFY( aa
== s1
.get_allocator() );
54 VERIFY( aaa
== s2
.get_allocator() );
56 VERIFY( s1
.get_allocator() != s2
.get_allocator() );
67 std::syncbuf
s2(std::move(s1
));
69 VERIFY( s1
.get_wrapped() == nullptr );
70 VERIFY( s2
.get_wrapped() == &b
);
80 VERIFY( s1
.get_wrapped() == nullptr );
81 VERIFY( s2
.get_wrapped() == &b
);
94 VERIFY( s1
.get_wrapped() == nullptr );
95 VERIFY( s2
.get_wrapped() == &b
);
105 const std::string_view
txt("This is a test");
106 s
.sputn(txt
.data(), txt
.size());
108 VERIFY( b
.str() != txt
);
109 VERIFY( s
.pubsync() == 0 );
110 VERIFY( b
.str() != txt
);
113 VERIFY( b
.str() == txt
);
119 s
.set_emit_on_sync(true);
121 const std::string_view
txt("This is a test");
122 s
.sputn(txt
.data(), txt
.size());
124 VERIFY( s
.pubsync() == 0 );
125 VERIFY( b
.str() == txt
);