]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/experimental/net/buffer/size.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / experimental / net / buffer / size.cc
CommitLineData
99dee823 1// Copyright (C) 2015-2021 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
23using std::experimental::net::const_buffer;
24using std::experimental::net::mutable_buffer;
25
26void
27test01()
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
44void
45test02()
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
57int
58main()
59{
60 test01();
61 test02();
62}