| 1 | // Copyright (C) 2015-2025 Free Software Foundation, Inc. |
| 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 | |
| 18 | // { dg-do run { target c++14 } } |
| 19 | |
| 20 | #include <experimental/buffer> |
| 21 | #include <testsuite_hooks.h> |
| 22 | |
| 23 | using std::experimental::net::const_buffer; |
| 24 | using std::experimental::net::mutable_buffer; |
| 25 | |
| 26 | void |
| 27 | test01() |
| 28 | { |
| 29 | bool test __attribute__((unused)) = false; |
| 30 | char c[4]; |
| 31 | |
| 32 | mutable_buffer mb; |
| 33 | VERIFY( buffer_size(mb) == 0 ); |
| 34 | |
| 35 | mb = mutable_buffer(c, sizeof(c)); |
| 36 | VERIFY( buffer_size(mb) == mb.size() ); |
| 37 | |
| 38 | const_buffer cb; |
| 39 | VERIFY( buffer_size(cb) == 0 ); |
| 40 | cb = const_buffer(c, sizeof(c)); |
| 41 | VERIFY( buffer_size(cb) == cb.size() ); |
| 42 | } |
| 43 | |
| 44 | void |
| 45 | test02() |
| 46 | { |
| 47 | bool test __attribute__((unused)) = false; |
| 48 | char c[32]; |
| 49 | |
| 50 | std::vector<mutable_buffer> mv{ {c, 0}, {c, 32}, {c, 16}, {c, 3}, {c, 0} }; |
| 51 | VERIFY( buffer_size(mv) == (0 + 32 + 16 + 3 + 0) ); |
| 52 | |
| 53 | std::vector<const_buffer> cv{ {c, 0}, {c, 32}, {c, 16}, {c, 3}, {c, 0} }; |
| 54 | VERIFY( buffer_size(cv) == (0 + 32 + 16 + 3 + 0) ); |
| 55 | } |
| 56 | |
| 57 | int |
| 58 | main() |
| 59 | { |
| 60 | test01(); |
| 61 | test02(); |
| 62 | } |