]>
Commit | Line | Data |
---|---|---|
a945c346 | 1 | // Copyright (C) 2015-2024 Free Software Foundation, Inc. |
e5989e71 JW |
2 | // |
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) | |
7 | // any later version. | |
8 | ||
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. | |
13 | ||
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/>. | |
17 | ||
7e8b87e9 | 18 | // { dg-do run { target c++14 } } |
e5989e71 JW |
19 | |
20 | #include <experimental/buffer> | |
21 | #include <testsuite_hooks.h> | |
22 | ||
23 | using std::experimental::net::mutable_buffer; | |
24 | ||
25 | void | |
26 | test01() | |
27 | { | |
28 | using B = mutable_buffer; | |
29 | const B b; | |
30 | ||
31 | static_assert( std::is_nothrow_default_constructible<B>::value, | |
32 | "const_mutable is nothrow default constructible" ); | |
33 | static_assert( std::is_copy_assignable<B>::value, | |
34 | "const_mutable is copy assignable" ); | |
35 | static_assert( std::is_nothrow_constructible<B, void*, size_t>::value, | |
36 | "const_mutable is nothrow default constructible" ); | |
37 | static_assert( std::is_same<decltype(b.data()), void*>::value, | |
38 | "data() return const void*" ); | |
39 | static_assert( noexcept(b.data()), | |
40 | "data() is nothrow" ); | |
41 | static_assert( std::is_same<decltype(b.size()), size_t>::value, | |
42 | "size() return size_t" ); | |
43 | static_assert( noexcept(b.size()), | |
44 | "size() is nothrow" ); | |
45 | } | |
46 | ||
47 | void | |
48 | test02() | |
49 | { | |
50 | bool test __attribute__((unused)) = false; | |
51 | char c[4]; | |
52 | ||
53 | mutable_buffer b; | |
54 | VERIFY( b.data() == nullptr ); | |
55 | VERIFY( b.size() == 0 ); | |
56 | ||
57 | b = mutable_buffer(c, sizeof(c)); | |
58 | VERIFY( b.data() == c ); | |
59 | VERIFY( b.size() == sizeof(c) ); | |
60 | ||
61 | b = mutable_buffer{}; | |
62 | VERIFY( b.data() == nullptr ); | |
63 | VERIFY( b.size() == 0 ); | |
64 | } | |
65 | ||
66 | int | |
67 | main() | |
68 | { | |
69 | test01(); | |
70 | test02(); | |
71 | } |