]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/experimental/net/buffer/arithmetic.cc
1 // Copyright (C) 2015-2021 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++14 } }
20 #include <experimental/buffer>
21 #include <testsuite_hooks.h>
23 using std::experimental::net::mutable_buffer
;
24 using std::experimental::net::const_buffer
;
29 bool test
__attribute__((unused
)) = false;
34 VERIFY( mb
.data() == nullptr );
35 VERIFY( mb
.size() == 0 );
38 VERIFY( mb
.data() == nullptr );
39 VERIFY( mb
.size() == 0 );
41 mb
= mutable_buffer(c
, sizeof(c
));
43 VERIFY( mb
.data() == c
+1 );
44 VERIFY( mb
.size() == 3 );
47 VERIFY( mb
.data() == c
+3 );
48 VERIFY( mb
.size() == 1 );
51 VERIFY( mb
.data() == c
+4 );
52 VERIFY( mb
.size() == 0 );
54 mb
= mutable_buffer(c
, sizeof(c
));
56 VERIFY( mb
.data() == c
+3 );
57 VERIFY( mb
.size() == 1 );
60 VERIFY( mb
.data() == c
+4 );
61 VERIFY( mb
.size() == 0 );
67 bool test
__attribute__((unused
)) = false;
72 VERIFY( cb
.data() == nullptr );
73 VERIFY( cb
.size() == 0 );
76 VERIFY( cb
.data() == nullptr );
77 VERIFY( cb
.size() == 0 );
79 cb
= const_buffer(c
, sizeof(c
));
81 VERIFY( cb
.data() == c
+1 );
82 VERIFY( cb
.size() == 3 );
85 VERIFY( cb
.data() == c
+3 );
86 VERIFY( cb
.size() == 1 );
89 VERIFY( cb
.data() == c
+4 );
90 VERIFY( cb
.size() == 0 );
92 cb
= const_buffer(c
, sizeof(c
));
94 VERIFY( cb
.data() == c
+3 );
95 VERIFY( cb
.size() == 1 );
98 VERIFY( cb
.data() == c
+4 );
99 VERIFY( cb
.size() == 0 );