1//
2// read_at.cpp
3// ~~~~~~~~~~~
4//
5// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6//
7// Distributed under the Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9//
10
11// Disable autolinking for unit tests.
12#if !defined(BOOST_ALL_NO_LIB)
13#define BOOST_ALL_NO_LIB 1
14#endif // !defined(BOOST_ALL_NO_LIB)
15
16// Test that header file is self-contained.
17#include <boost/asio/read_at.hpp>
18
19#include <cstring>
20#include "archetypes/async_result.hpp"
21#include <boost/asio/io_service.hpp>
22#include <boost/asio/streambuf.hpp>
23#include "unit_test.hpp"
24
25#if defined(BOOST_ASIO_HAS_BOOST_BIND)
26# include <boost/bind.hpp>
27#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
28# include <functional>
29#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
30
31#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
32#include <boost/array.hpp>
33#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
34
35#if defined(BOOST_ASIO_HAS_STD_ARRAY)
36# include <array>
37#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
38
39using namespace std; // For memcmp, memcpy and memset.
40
41class test_random_access_device
42{
43public:
44 typedef boost::asio::io_service io_service_type;
45
46 test_random_access_device(boost::asio::io_service& io_service)
47 : io_service_(io_service),
48 length_(0),
49 next_read_length_(0)
50 {
51 }
52
53 io_service_type& get_io_service()
54 {
55 return io_service_;
56 }
57
58 void reset(const void* data, size_t length)
59 {
60 BOOST_ASIO_CHECK(length <= max_length);
61
62 length_ = 0;
63 while (length_ + length < max_length)
64 {
65 memcpy(data_ + length_, data, length);
66 length_ += length;
67 }
68
69 next_read_length_ = length;
70 }
71
72 void next_read_length(size_t length)
73 {
74 next_read_length_ = length;
75 }
76
77 template <typename Const_Buffers>
78 bool check_buffers(boost::asio::uint64_t offset,
79 const Const_Buffers& buffers, size_t length)
80 {
81 if (offset + length > max_length)
82 return false;
83
84 typename Const_Buffers::const_iterator iter = buffers.begin();
85 typename Const_Buffers::const_iterator end = buffers.end();
86 size_t checked_length = 0;
87 for (; iter != end && checked_length < length; ++iter)
88 {
89 size_t buffer_length = boost::asio::buffer_size(*iter);
90 if (buffer_length > length - checked_length)
91 buffer_length = length - checked_length;
92 if (memcmp(data_ + offset + checked_length,
93 boost::asio::buffer_cast<const void*>(*iter), buffer_length) != 0)
94 return false;
95 checked_length += buffer_length;
96 }
97
98 return true;
99 }
100
101 template <typename Mutable_Buffers>
102 size_t read_some_at(boost::asio::uint64_t offset,
103 const Mutable_Buffers& buffers)
104 {
105 return boost::asio::buffer_copy(buffers,
106 boost::asio::buffer(data_, length_) + offset,
107 next_read_length_);
108 }
109
110 template <typename Mutable_Buffers>
111 size_t read_some_at(boost::asio::uint64_t offset,
112 const Mutable_Buffers& buffers, boost::system::error_code& ec)
113 {
114 ec = boost::system::error_code();
115 return read_some_at(offset, buffers);
116 }
117
118 template <typename Mutable_Buffers, typename Handler>
119 void async_read_some_at(boost::asio::uint64_t offset,
120 const Mutable_Buffers& buffers, Handler handler)
121 {
122 size_t bytes_transferred = read_some_at(offset, buffers);
123 io_service_.post(boost::asio::detail::bind_handler(
124 handler, boost::system::error_code(), bytes_transferred));
125 }
126
127private:
128 io_service_type& io_service_;
129 enum { max_length = 8192 };
130 char data_[max_length];
131 size_t length_;
132 size_t next_read_length_;
133};
134
135static const char read_data[]
136 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
137
138void test_3_arg_mutable_buffers_1_read_at()
139{
140 boost::asio::io_service ios;
141 test_random_access_device s(ios);
142 char read_buf[sizeof(read_data)];
143 boost::asio::mutable_buffers_1 buffers
144 = boost::asio::buffer(read_buf, sizeof(read_buf));
145
146 s.reset(read_data, sizeof(read_data));
147 memset(read_buf, 0, sizeof(read_buf));
148 size_t bytes_transferred = boost::asio::read_at(s, 0, buffers);
149 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
150 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
151
152 s.reset(read_data, sizeof(read_data));
153 memset(read_buf, 0, sizeof(read_buf));
154 bytes_transferred = boost::asio::read_at(s, 1234, buffers);
155 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
156 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
157
158 s.reset(read_data, sizeof(read_data));
159 s.next_read_length(1);
160 memset(read_buf, 0, sizeof(read_buf));
161 bytes_transferred = boost::asio::read_at(s, 0, buffers);
162 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
163 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
164
165 s.reset(read_data, sizeof(read_data));
166 s.next_read_length(1);
167 memset(read_buf, 0, sizeof(read_buf));
168 bytes_transferred = boost::asio::read_at(s, 1234, buffers);
169 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
170 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
171
172 s.reset(read_data, sizeof(read_data));
173 s.next_read_length(10);
174 memset(read_buf, 0, sizeof(read_buf));
175 bytes_transferred = boost::asio::read_at(s, 0, buffers);
176 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
177 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
178
179 s.reset(read_data, sizeof(read_data));
180 s.next_read_length(10);
181 memset(read_buf, 0, sizeof(read_buf));
182 bytes_transferred = boost::asio::read_at(s, 1234, buffers);
183 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
184 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
185}
186
187void test_3_arg_vector_buffers_read_at()
188{
189 boost::asio::io_service ios;
190 test_random_access_device s(ios);
191 char read_buf[sizeof(read_data)];
192 std::vector<boost::asio::mutable_buffer> buffers;
193 buffers.push_back(boost::asio::buffer(read_buf, 32));
194 buffers.push_back(boost::asio::buffer(read_buf) + 32);
195
196 s.reset(read_data, sizeof(read_data));
197 memset(read_buf, 0, sizeof(read_buf));
198 size_t bytes_transferred = boost::asio::read_at(s, 0, buffers);
199 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
200 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
201
202 s.reset(read_data, sizeof(read_data));
203 memset(read_buf, 0, sizeof(read_buf));
204 bytes_transferred = boost::asio::read_at(s, 1234, buffers);
205 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
206 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
207
208 s.reset(read_data, sizeof(read_data));
209 s.next_read_length(1);
210 memset(read_buf, 0, sizeof(read_buf));
211 bytes_transferred = boost::asio::read_at(s, 0, buffers);
212 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
213 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
214
215 s.reset(read_data, sizeof(read_data));
216 s.next_read_length(1);
217 memset(read_buf, 0, sizeof(read_buf));
218 bytes_transferred = boost::asio::read_at(s, 1234, buffers);
219 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
220 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
221
222 s.reset(read_data, sizeof(read_data));
223 s.next_read_length(10);
224 memset(read_buf, 0, sizeof(read_buf));
225 bytes_transferred = boost::asio::read_at(s, 0, buffers);
226 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
227 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
228
229 s.reset(read_data, sizeof(read_data));
230 s.next_read_length(10);
231 memset(read_buf, 0, sizeof(read_buf));
232 bytes_transferred = boost::asio::read_at(s, 1234, buffers);
233 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
234 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
235}
236
237void test_3_arg_streambuf_read_at()
238{
239 boost::asio::io_service ios;
240 test_random_access_device s(ios);
241 boost::asio::streambuf sb(sizeof(read_data));
242
243 s.reset(read_data, sizeof(read_data));
244 sb.consume(sb.size());
245 size_t bytes_transferred = boost::asio::read_at(s, 0, sb);
246 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
247 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
248 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
249
250 s.reset(read_data, sizeof(read_data));
251 sb.consume(sb.size());
252 bytes_transferred = boost::asio::read_at(s, 1234, sb);
253 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
254 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
255 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
256
257 s.reset(read_data, sizeof(read_data));
258 s.next_read_length(1);
259 sb.consume(sb.size());
260 bytes_transferred = boost::asio::read_at(s, 0, sb);
261 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
262 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
263 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
264
265 s.reset(read_data, sizeof(read_data));
266 s.next_read_length(1);
267 sb.consume(sb.size());
268 bytes_transferred = boost::asio::read_at(s, 1234, sb);
269 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
270 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
271 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
272
273 s.reset(read_data, sizeof(read_data));
274 s.next_read_length(10);
275 sb.consume(sb.size());
276 bytes_transferred = boost::asio::read_at(s, 0, sb);
277 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
278 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
279 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
280
281 s.reset(read_data, sizeof(read_data));
282 s.next_read_length(10);
283 sb.consume(sb.size());
284 bytes_transferred = boost::asio::read_at(s, 1234, sb);
285 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
286 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
287 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
288}
289
290void test_4_arg_nothrow_mutable_buffers_1_read_at()
291{
292 boost::asio::io_service ios;
293 test_random_access_device s(ios);
294 char read_buf[sizeof(read_data)];
295 boost::asio::mutable_buffers_1 buffers
296 = boost::asio::buffer(read_buf, sizeof(read_buf));
297
298 s.reset(read_data, sizeof(read_data));
299 memset(read_buf, 0, sizeof(read_buf));
300 boost::system::error_code error;
301 size_t bytes_transferred = boost::asio::read_at(s, 0, buffers, error);
302 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
303 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
304 BOOST_ASIO_CHECK(!error);
305
306 s.reset(read_data, sizeof(read_data));
307 memset(read_buf, 0, sizeof(read_buf));
308 bytes_transferred = boost::asio::read_at(s, 1234, buffers, error);
309 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
310 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
311 BOOST_ASIO_CHECK(!error);
312
313 s.reset(read_data, sizeof(read_data));
314 s.next_read_length(1);
315 memset(read_buf, 0, sizeof(read_buf));
316 bytes_transferred = boost::asio::read_at(s, 0, buffers, error);
317 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
318 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
319 BOOST_ASIO_CHECK(!error);
320
321 s.reset(read_data, sizeof(read_data));
322 s.next_read_length(1);
323 memset(read_buf, 0, sizeof(read_buf));
324 bytes_transferred = boost::asio::read_at(s, 1234, buffers, error);
325 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
326 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
327 BOOST_ASIO_CHECK(!error);
328
329 s.reset(read_data, sizeof(read_data));
330 s.next_read_length(10);
331 memset(read_buf, 0, sizeof(read_buf));
332 bytes_transferred = boost::asio::read_at(s, 0, buffers, error);
333 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
334 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
335 BOOST_ASIO_CHECK(!error);
336
337 s.reset(read_data, sizeof(read_data));
338 s.next_read_length(10);
339 memset(read_buf, 0, sizeof(read_buf));
340 bytes_transferred = boost::asio::read_at(s, 1234, buffers, error);
341 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
342 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
343 BOOST_ASIO_CHECK(!error);
344}
345
346void test_4_arg_nothrow_vector_buffers_read_at()
347{
348 boost::asio::io_service ios;
349 test_random_access_device s(ios);
350 char read_buf[sizeof(read_data)];
351 std::vector<boost::asio::mutable_buffer> buffers;
352 buffers.push_back(boost::asio::buffer(read_buf, 32));
353 buffers.push_back(boost::asio::buffer(read_buf) + 32);
354
355 s.reset(read_data, sizeof(read_data));
356 memset(read_buf, 0, sizeof(read_buf));
357 boost::system::error_code error;
358 size_t bytes_transferred = boost::asio::read_at(s, 0, buffers, error);
359 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
360 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
361 BOOST_ASIO_CHECK(!error);
362
363 s.reset(read_data, sizeof(read_data));
364 memset(read_buf, 0, sizeof(read_buf));
365 bytes_transferred = boost::asio::read_at(s, 1234, buffers, error);
366 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
367 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
368 BOOST_ASIO_CHECK(!error);
369
370 s.reset(read_data, sizeof(read_data));
371 s.next_read_length(1);
372 memset(read_buf, 0, sizeof(read_buf));
373 bytes_transferred = boost::asio::read_at(s, 0, buffers, error);
374 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
375 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
376 BOOST_ASIO_CHECK(!error);
377
378 s.reset(read_data, sizeof(read_data));
379 s.next_read_length(1);
380 memset(read_buf, 0, sizeof(read_buf));
381 bytes_transferred = boost::asio::read_at(s, 1234, buffers, error);
382 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
383 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
384 BOOST_ASIO_CHECK(!error);
385
386 s.reset(read_data, sizeof(read_data));
387 s.next_read_length(10);
388 memset(read_buf, 0, sizeof(read_buf));
389 bytes_transferred = boost::asio::read_at(s, 0, buffers, error);
390 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
391 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
392 BOOST_ASIO_CHECK(!error);
393
394 s.reset(read_data, sizeof(read_data));
395 s.next_read_length(10);
396 memset(read_buf, 0, sizeof(read_buf));
397 bytes_transferred = boost::asio::read_at(s, 1234, buffers, error);
398 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
399 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
400 BOOST_ASIO_CHECK(!error);
401}
402
403void test_4_arg_nothrow_streambuf_read_at()
404{
405 boost::asio::io_service ios;
406 test_random_access_device s(ios);
407 boost::asio::streambuf sb(sizeof(read_data));
408
409 s.reset(read_data, sizeof(read_data));
410 sb.consume(sb.size());
411 boost::system::error_code error;
412 size_t bytes_transferred = boost::asio::read_at(s, 0, sb, error);
413 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
414 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
415 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
416 BOOST_ASIO_CHECK(!error);
417
418 s.reset(read_data, sizeof(read_data));
419 sb.consume(sb.size());
420 bytes_transferred = boost::asio::read_at(s, 1234, sb, error);
421 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
422 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
423 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
424 BOOST_ASIO_CHECK(!error);
425
426 s.reset(read_data, sizeof(read_data));
427 s.next_read_length(1);
428 sb.consume(sb.size());
429 bytes_transferred = boost::asio::read_at(s, 0, sb, error);
430 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
431 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
432 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
433 BOOST_ASIO_CHECK(!error);
434
435 s.reset(read_data, sizeof(read_data));
436 s.next_read_length(1);
437 sb.consume(sb.size());
438 bytes_transferred = boost::asio::read_at(s, 1234, sb, error);
439 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
440 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
441 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
442 BOOST_ASIO_CHECK(!error);
443
444 s.reset(read_data, sizeof(read_data));
445 s.next_read_length(10);
446 sb.consume(sb.size());
447 bytes_transferred = boost::asio::read_at(s, 0, sb, error);
448 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
449 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
450 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
451 BOOST_ASIO_CHECK(!error);
452
453 s.reset(read_data, sizeof(read_data));
454 s.next_read_length(10);
455 sb.consume(sb.size());
456 bytes_transferred = boost::asio::read_at(s, 1234, sb, error);
457 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
458 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
459 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
460 BOOST_ASIO_CHECK(!error);
461}
462
463bool old_style_transfer_all(const boost::system::error_code& ec,
464 size_t /*bytes_transferred*/)
465{
466 return !!ec;
467}
468
469size_t short_transfer(const boost::system::error_code& ec,
470 size_t /*bytes_transferred*/)
471{
472 return !!ec ? 0 : 3;
473}
474
475void test_4_arg_mutable_buffers_1_read_at()
476{
477 boost::asio::io_service ios;
478 test_random_access_device s(ios);
479 char read_buf[sizeof(read_data)];
480 boost::asio::mutable_buffers_1 buffers
481 = boost::asio::buffer(read_buf, sizeof(read_buf));
482
483 s.reset(read_data, sizeof(read_data));
484 memset(read_buf, 0, sizeof(read_buf));
485 size_t bytes_transferred = boost::asio::read_at(s, 0, buffers,
486 boost::asio::transfer_all());
487 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
488 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
489
490 s.reset(read_data, sizeof(read_data));
491 memset(read_buf, 0, sizeof(read_buf));
492 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
493 boost::asio::transfer_all());
494 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
495 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
496
497 s.reset(read_data, sizeof(read_data));
498 s.next_read_length(1);
499 memset(read_buf, 0, sizeof(read_buf));
500 bytes_transferred = boost::asio::read_at(s, 0, buffers,
501 boost::asio::transfer_all());
502 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
503 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
504
505 s.reset(read_data, sizeof(read_data));
506 s.next_read_length(1);
507 memset(read_buf, 0, sizeof(read_buf));
508 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
509 boost::asio::transfer_all());
510 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
511 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
512
513 s.reset(read_data, sizeof(read_data));
514 s.next_read_length(10);
515 memset(read_buf, 0, sizeof(read_buf));
516 bytes_transferred = boost::asio::read_at(s, 0, buffers,
517 boost::asio::transfer_all());
518 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
519 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
520
521 s.reset(read_data, sizeof(read_data));
522 s.next_read_length(10);
523 memset(read_buf, 0, sizeof(read_buf));
524 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
525 boost::asio::transfer_all());
526 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
527 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
528
529 s.reset(read_data, sizeof(read_data));
530 memset(read_buf, 0, sizeof(read_buf));
531 bytes_transferred = boost::asio::read_at(s, 0, buffers,
532 boost::asio::transfer_at_least(1));
533 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
534 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
535
536 s.reset(read_data, sizeof(read_data));
537 memset(read_buf, 0, sizeof(read_buf));
538 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
539 boost::asio::transfer_at_least(1));
540 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
541 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
542
543 s.reset(read_data, sizeof(read_data));
544 s.next_read_length(1);
545 memset(read_buf, 0, sizeof(read_buf));
546 bytes_transferred = boost::asio::read_at(s, 0, buffers,
547 boost::asio::transfer_at_least(1));
548 BOOST_ASIO_CHECK(bytes_transferred == 1);
549 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
550
551 s.reset(read_data, sizeof(read_data));
552 s.next_read_length(1);
553 memset(read_buf, 0, sizeof(read_buf));
554 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
555 boost::asio::transfer_at_least(1));
556 BOOST_ASIO_CHECK(bytes_transferred == 1);
557 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
558
559 s.reset(read_data, sizeof(read_data));
560 s.next_read_length(10);
561 memset(read_buf, 0, sizeof(read_buf));
562 bytes_transferred = boost::asio::read_at(s, 0, buffers,
563 boost::asio::transfer_at_least(1));
564 BOOST_ASIO_CHECK(bytes_transferred == 10);
565 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
566
567 s.reset(read_data, sizeof(read_data));
568 s.next_read_length(10);
569 memset(read_buf, 0, sizeof(read_buf));
570 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
571 boost::asio::transfer_at_least(1));
572 BOOST_ASIO_CHECK(bytes_transferred == 10);
573 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
574
575 s.reset(read_data, sizeof(read_data));
576 memset(read_buf, 0, sizeof(read_buf));
577 bytes_transferred = boost::asio::read_at(s, 0, buffers,
578 boost::asio::transfer_at_least(10));
579 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
580 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
581
582 s.reset(read_data, sizeof(read_data));
583 memset(read_buf, 0, sizeof(read_buf));
584 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
585 boost::asio::transfer_at_least(10));
586 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
587 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
588
589 s.reset(read_data, sizeof(read_data));
590 s.next_read_length(1);
591 memset(read_buf, 0, sizeof(read_buf));
592 bytes_transferred = boost::asio::read_at(s, 0, buffers,
593 boost::asio::transfer_at_least(10));
594 BOOST_ASIO_CHECK(bytes_transferred == 10);
595 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
596
597 s.reset(read_data, sizeof(read_data));
598 s.next_read_length(1);
599 memset(read_buf, 0, sizeof(read_buf));
600 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
601 boost::asio::transfer_at_least(10));
602 BOOST_ASIO_CHECK(bytes_transferred == 10);
603 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
604
605 s.reset(read_data, sizeof(read_data));
606 s.next_read_length(10);
607 memset(read_buf, 0, sizeof(read_buf));
608 bytes_transferred = boost::asio::read_at(s, 0, buffers,
609 boost::asio::transfer_at_least(10));
610 BOOST_ASIO_CHECK(bytes_transferred == 10);
611 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
612
613 s.reset(read_data, sizeof(read_data));
614 s.next_read_length(10);
615 memset(read_buf, 0, sizeof(read_buf));
616 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
617 boost::asio::transfer_at_least(10));
618 BOOST_ASIO_CHECK(bytes_transferred == 10);
619 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
620
621 s.reset(read_data, sizeof(read_data));
622 memset(read_buf, 0, sizeof(read_buf));
623 bytes_transferred = boost::asio::read_at(s, 0, buffers,
624 boost::asio::transfer_at_least(42));
625 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
626 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
627
628 s.reset(read_data, sizeof(read_data));
629 memset(read_buf, 0, sizeof(read_buf));
630 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
631 boost::asio::transfer_at_least(42));
632 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
633 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
634
635 s.reset(read_data, sizeof(read_data));
636 s.next_read_length(1);
637 memset(read_buf, 0, sizeof(read_buf));
638 bytes_transferred = boost::asio::read_at(s, 0, buffers,
639 boost::asio::transfer_at_least(42));
640 BOOST_ASIO_CHECK(bytes_transferred == 42);
641 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
642
643 s.reset(read_data, sizeof(read_data));
644 s.next_read_length(1);
645 memset(read_buf, 0, sizeof(read_buf));
646 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
647 boost::asio::transfer_at_least(42));
648 BOOST_ASIO_CHECK(bytes_transferred == 42);
649 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
650
651 s.reset(read_data, sizeof(read_data));
652 s.next_read_length(10);
653 memset(read_buf, 0, sizeof(read_buf));
654 bytes_transferred = boost::asio::read_at(s, 0, buffers,
655 boost::asio::transfer_at_least(42));
656 BOOST_ASIO_CHECK(bytes_transferred == 50);
657 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
658
659 s.reset(read_data, sizeof(read_data));
660 s.next_read_length(10);
661 memset(read_buf, 0, sizeof(read_buf));
662 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
663 boost::asio::transfer_at_least(42));
664 BOOST_ASIO_CHECK(bytes_transferred == 50);
665 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
666
667 s.reset(read_data, sizeof(read_data));
668 memset(read_buf, 0, sizeof(read_buf));
669 bytes_transferred = boost::asio::read_at(s, 0, buffers,
670 boost::asio::transfer_exactly(1));
671 BOOST_ASIO_CHECK(bytes_transferred == 1);
672 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
673
674 s.reset(read_data, sizeof(read_data));
675 memset(read_buf, 0, sizeof(read_buf));
676 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
677 boost::asio::transfer_exactly(1));
678 BOOST_ASIO_CHECK(bytes_transferred == 1);
679 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
680
681 s.reset(read_data, sizeof(read_data));
682 s.next_read_length(1);
683 memset(read_buf, 0, sizeof(read_buf));
684 bytes_transferred = boost::asio::read_at(s, 0, buffers,
685 boost::asio::transfer_exactly(1));
686 BOOST_ASIO_CHECK(bytes_transferred == 1);
687 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
688
689 s.reset(read_data, sizeof(read_data));
690 s.next_read_length(1);
691 memset(read_buf, 0, sizeof(read_buf));
692 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
693 boost::asio::transfer_exactly(1));
694 BOOST_ASIO_CHECK(bytes_transferred == 1);
695 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
696
697 s.reset(read_data, sizeof(read_data));
698 s.next_read_length(10);
699 memset(read_buf, 0, sizeof(read_buf));
700 bytes_transferred = boost::asio::read_at(s, 0, buffers,
701 boost::asio::transfer_exactly(1));
702 BOOST_ASIO_CHECK(bytes_transferred == 1);
703 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
704
705 s.reset(read_data, sizeof(read_data));
706 s.next_read_length(10);
707 memset(read_buf, 0, sizeof(read_buf));
708 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
709 boost::asio::transfer_exactly(1));
710 BOOST_ASIO_CHECK(bytes_transferred == 1);
711 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
712
713 s.reset(read_data, sizeof(read_data));
714 memset(read_buf, 0, sizeof(read_buf));
715 bytes_transferred = boost::asio::read_at(s, 0, buffers,
716 boost::asio::transfer_exactly(10));
717 BOOST_ASIO_CHECK(bytes_transferred == 10);
718 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
719
720 s.reset(read_data, sizeof(read_data));
721 memset(read_buf, 0, sizeof(read_buf));
722 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
723 boost::asio::transfer_exactly(10));
724 BOOST_ASIO_CHECK(bytes_transferred == 10);
725 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
726
727 s.reset(read_data, sizeof(read_data));
728 s.next_read_length(1);
729 memset(read_buf, 0, sizeof(read_buf));
730 bytes_transferred = boost::asio::read_at(s, 0, buffers,
731 boost::asio::transfer_exactly(10));
732 BOOST_ASIO_CHECK(bytes_transferred == 10);
733 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
734
735 s.reset(read_data, sizeof(read_data));
736 s.next_read_length(1);
737 memset(read_buf, 0, sizeof(read_buf));
738 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
739 boost::asio::transfer_exactly(10));
740 BOOST_ASIO_CHECK(bytes_transferred == 10);
741 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
742
743 s.reset(read_data, sizeof(read_data));
744 s.next_read_length(10);
745 memset(read_buf, 0, sizeof(read_buf));
746 bytes_transferred = boost::asio::read_at(s, 0, buffers,
747 boost::asio::transfer_exactly(10));
748 BOOST_ASIO_CHECK(bytes_transferred == 10);
749 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
750
751 s.reset(read_data, sizeof(read_data));
752 s.next_read_length(10);
753 memset(read_buf, 0, sizeof(read_buf));
754 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
755 boost::asio::transfer_exactly(10));
756 BOOST_ASIO_CHECK(bytes_transferred == 10);
757 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
758
759 s.reset(read_data, sizeof(read_data));
760 memset(read_buf, 0, sizeof(read_buf));
761 bytes_transferred = boost::asio::read_at(s, 0, buffers,
762 boost::asio::transfer_exactly(42));
763 BOOST_ASIO_CHECK(bytes_transferred == 42);
764 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
765
766 s.reset(read_data, sizeof(read_data));
767 memset(read_buf, 0, sizeof(read_buf));
768 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
769 boost::asio::transfer_exactly(42));
770 BOOST_ASIO_CHECK(bytes_transferred == 42);
771 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
772
773 s.reset(read_data, sizeof(read_data));
774 s.next_read_length(1);
775 memset(read_buf, 0, sizeof(read_buf));
776 bytes_transferred = boost::asio::read_at(s, 0, buffers,
777 boost::asio::transfer_exactly(42));
778 BOOST_ASIO_CHECK(bytes_transferred == 42);
779 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
780
781 s.reset(read_data, sizeof(read_data));
782 s.next_read_length(1);
783 memset(read_buf, 0, sizeof(read_buf));
784 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
785 boost::asio::transfer_exactly(42));
786 BOOST_ASIO_CHECK(bytes_transferred == 42);
787 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
788
789 s.reset(read_data, sizeof(read_data));
790 s.next_read_length(10);
791 memset(read_buf, 0, sizeof(read_buf));
792 bytes_transferred = boost::asio::read_at(s, 0, buffers,
793 boost::asio::transfer_exactly(42));
794 BOOST_ASIO_CHECK(bytes_transferred == 42);
795 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
796
797 s.reset(read_data, sizeof(read_data));
798 s.next_read_length(10);
799 memset(read_buf, 0, sizeof(read_buf));
800 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
801 boost::asio::transfer_exactly(42));
802 BOOST_ASIO_CHECK(bytes_transferred == 42);
803 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
804
805 s.reset(read_data, sizeof(read_data));
806 memset(read_buf, 0, sizeof(read_buf));
807 bytes_transferred = boost::asio::read_at(s, 0, buffers,
808 old_style_transfer_all);
809 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
810 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
811
812 s.reset(read_data, sizeof(read_data));
813 memset(read_buf, 0, sizeof(read_buf));
814 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
815 old_style_transfer_all);
816 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
817 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
818
819 s.reset(read_data, sizeof(read_data));
820 s.next_read_length(1);
821 memset(read_buf, 0, sizeof(read_buf));
822 bytes_transferred = boost::asio::read_at(s, 0, buffers,
823 old_style_transfer_all);
824 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
825 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
826
827 s.reset(read_data, sizeof(read_data));
828 s.next_read_length(1);
829 memset(read_buf, 0, sizeof(read_buf));
830 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
831 old_style_transfer_all);
832 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
833 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
834
835 s.reset(read_data, sizeof(read_data));
836 s.next_read_length(10);
837 memset(read_buf, 0, sizeof(read_buf));
838 bytes_transferred = boost::asio::read_at(s, 0, buffers,
839 old_style_transfer_all);
840 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
841 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
842
843 s.reset(read_data, sizeof(read_data));
844 s.next_read_length(10);
845 memset(read_buf, 0, sizeof(read_buf));
846 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
847 old_style_transfer_all);
848 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
849 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
850
851 s.reset(read_data, sizeof(read_data));
852 memset(read_buf, 0, sizeof(read_buf));
853 bytes_transferred = boost::asio::read_at(s, 0, buffers, short_transfer);
854 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
855 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
856
857 s.reset(read_data, sizeof(read_data));
858 memset(read_buf, 0, sizeof(read_buf));
859 bytes_transferred = boost::asio::read_at(s, 1234, buffers, short_transfer);
860 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
861 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
862
863 s.reset(read_data, sizeof(read_data));
864 s.next_read_length(1);
865 memset(read_buf, 0, sizeof(read_buf));
866 bytes_transferred = boost::asio::read_at(s, 0, buffers, short_transfer);
867 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
868 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
869
870 s.reset(read_data, sizeof(read_data));
871 s.next_read_length(1);
872 memset(read_buf, 0, sizeof(read_buf));
873 bytes_transferred = boost::asio::read_at(s, 1234, buffers, short_transfer);
874 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
875 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
876
877 s.reset(read_data, sizeof(read_data));
878 s.next_read_length(10);
879 memset(read_buf, 0, sizeof(read_buf));
880 bytes_transferred = boost::asio::read_at(s, 0, buffers, short_transfer);
881 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
882 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
883
884 s.reset(read_data, sizeof(read_data));
885 s.next_read_length(10);
886 memset(read_buf, 0, sizeof(read_buf));
887 bytes_transferred = boost::asio::read_at(s, 1234, buffers, short_transfer);
888 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
889 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
890}
891
892void test_4_arg_vector_buffers_read_at()
893{
894 boost::asio::io_service ios;
895 test_random_access_device s(ios);
896 char read_buf[sizeof(read_data)];
897 std::vector<boost::asio::mutable_buffer> buffers;
898 buffers.push_back(boost::asio::buffer(read_buf, 32));
899 buffers.push_back(boost::asio::buffer(read_buf) + 32);
900
901 s.reset(read_data, sizeof(read_data));
902 memset(read_buf, 0, sizeof(read_buf));
903 size_t bytes_transferred = boost::asio::read_at(s, 0, buffers,
904 boost::asio::transfer_all());
905 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
906 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
907
908 s.reset(read_data, sizeof(read_data));
909 memset(read_buf, 0, sizeof(read_buf));
910 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
911 boost::asio::transfer_all());
912 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
913 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
914
915 s.reset(read_data, sizeof(read_data));
916 s.next_read_length(1);
917 memset(read_buf, 0, sizeof(read_buf));
918 bytes_transferred = boost::asio::read_at(s, 0, buffers,
919 boost::asio::transfer_all());
920 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
921 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
922
923 s.reset(read_data, sizeof(read_data));
924 s.next_read_length(1);
925 memset(read_buf, 0, sizeof(read_buf));
926 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
927 boost::asio::transfer_all());
928 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
929 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
930
931 s.reset(read_data, sizeof(read_data));
932 s.next_read_length(10);
933 memset(read_buf, 0, sizeof(read_buf));
934 bytes_transferred = boost::asio::read_at(s, 0, buffers,
935 boost::asio::transfer_all());
936 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
937 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
938
939 s.reset(read_data, sizeof(read_data));
940 s.next_read_length(10);
941 memset(read_buf, 0, sizeof(read_buf));
942 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
943 boost::asio::transfer_all());
944 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
945 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
946
947 s.reset(read_data, sizeof(read_data));
948 memset(read_buf, 0, sizeof(read_buf));
949 bytes_transferred = boost::asio::read_at(s, 0, buffers,
950 boost::asio::transfer_at_least(1));
951 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
952 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
953
954 s.reset(read_data, sizeof(read_data));
955 memset(read_buf, 0, sizeof(read_buf));
956 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
957 boost::asio::transfer_at_least(1));
958 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
959 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
960
961 s.reset(read_data, sizeof(read_data));
962 s.next_read_length(1);
963 memset(read_buf, 0, sizeof(read_buf));
964 bytes_transferred = boost::asio::read_at(s, 0, buffers,
965 boost::asio::transfer_at_least(1));
966 BOOST_ASIO_CHECK(bytes_transferred == 1);
967 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
968
969 s.reset(read_data, sizeof(read_data));
970 s.next_read_length(1);
971 memset(read_buf, 0, sizeof(read_buf));
972 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
973 boost::asio::transfer_at_least(1));
974 BOOST_ASIO_CHECK(bytes_transferred == 1);
975 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
976
977 s.reset(read_data, sizeof(read_data));
978 s.next_read_length(10);
979 memset(read_buf, 0, sizeof(read_buf));
980 bytes_transferred = boost::asio::read_at(s, 0, buffers,
981 boost::asio::transfer_at_least(1));
982 BOOST_ASIO_CHECK(bytes_transferred == 10);
983 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
984
985 s.reset(read_data, sizeof(read_data));
986 s.next_read_length(10);
987 memset(read_buf, 0, sizeof(read_buf));
988 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
989 boost::asio::transfer_at_least(1));
990 BOOST_ASIO_CHECK(bytes_transferred == 10);
991 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
992
993 s.reset(read_data, sizeof(read_data));
994 memset(read_buf, 0, sizeof(read_buf));
995 bytes_transferred = boost::asio::read_at(s, 0, buffers,
996 boost::asio::transfer_at_least(10));
997 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
998 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
999
1000 s.reset(read_data, sizeof(read_data));
1001 memset(read_buf, 0, sizeof(read_buf));
1002 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1003 boost::asio::transfer_at_least(10));
1004 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1005 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
1006
1007 s.reset(read_data, sizeof(read_data));
1008 s.next_read_length(1);
1009 memset(read_buf, 0, sizeof(read_buf));
1010 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1011 boost::asio::transfer_at_least(10));
1012 BOOST_ASIO_CHECK(bytes_transferred == 10);
1013 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
1014
1015 s.reset(read_data, sizeof(read_data));
1016 s.next_read_length(1);
1017 memset(read_buf, 0, sizeof(read_buf));
1018 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1019 boost::asio::transfer_at_least(10));
1020 BOOST_ASIO_CHECK(bytes_transferred == 10);
1021 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
1022
1023 s.reset(read_data, sizeof(read_data));
1024 s.next_read_length(10);
1025 memset(read_buf, 0, sizeof(read_buf));
1026 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1027 boost::asio::transfer_at_least(10));
1028 BOOST_ASIO_CHECK(bytes_transferred == 10);
1029 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
1030
1031 s.reset(read_data, sizeof(read_data));
1032 s.next_read_length(10);
1033 memset(read_buf, 0, sizeof(read_buf));
1034 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1035 boost::asio::transfer_at_least(10));
1036 BOOST_ASIO_CHECK(bytes_transferred == 10);
1037 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
1038
1039 s.reset(read_data, sizeof(read_data));
1040 memset(read_buf, 0, sizeof(read_buf));
1041 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1042 boost::asio::transfer_at_least(42));
1043 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1044 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
1045
1046 s.reset(read_data, sizeof(read_data));
1047 memset(read_buf, 0, sizeof(read_buf));
1048 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1049 boost::asio::transfer_at_least(42));
1050 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1051 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
1052
1053 s.reset(read_data, sizeof(read_data));
1054 s.next_read_length(1);
1055 memset(read_buf, 0, sizeof(read_buf));
1056 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1057 boost::asio::transfer_at_least(42));
1058 BOOST_ASIO_CHECK(bytes_transferred == 42);
1059 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
1060
1061 s.reset(read_data, sizeof(read_data));
1062 s.next_read_length(1);
1063 memset(read_buf, 0, sizeof(read_buf));
1064 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1065 boost::asio::transfer_at_least(42));
1066 BOOST_ASIO_CHECK(bytes_transferred == 42);
1067 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
1068
1069 s.reset(read_data, sizeof(read_data));
1070 s.next_read_length(10);
1071 memset(read_buf, 0, sizeof(read_buf));
1072 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1073 boost::asio::transfer_at_least(42));
1074 BOOST_ASIO_CHECK(bytes_transferred == 50);
1075 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
1076
1077 s.reset(read_data, sizeof(read_data));
1078 s.next_read_length(10);
1079 memset(read_buf, 0, sizeof(read_buf));
1080 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1081 boost::asio::transfer_at_least(42));
1082 BOOST_ASIO_CHECK(bytes_transferred == 50);
1083 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
1084
1085 s.reset(read_data, sizeof(read_data));
1086 memset(read_buf, 0, sizeof(read_buf));
1087 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1088 boost::asio::transfer_exactly(1));
1089 BOOST_ASIO_CHECK(bytes_transferred == 1);
1090 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
1091
1092 s.reset(read_data, sizeof(read_data));
1093 memset(read_buf, 0, sizeof(read_buf));
1094 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1095 boost::asio::transfer_exactly(1));
1096 BOOST_ASIO_CHECK(bytes_transferred == 1);
1097 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
1098
1099 s.reset(read_data, sizeof(read_data));
1100 s.next_read_length(1);
1101 memset(read_buf, 0, sizeof(read_buf));
1102 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1103 boost::asio::transfer_exactly(1));
1104 BOOST_ASIO_CHECK(bytes_transferred == 1);
1105 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
1106
1107 s.reset(read_data, sizeof(read_data));
1108 s.next_read_length(1);
1109 memset(read_buf, 0, sizeof(read_buf));
1110 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1111 boost::asio::transfer_exactly(1));
1112 BOOST_ASIO_CHECK(bytes_transferred == 1);
1113 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
1114
1115 s.reset(read_data, sizeof(read_data));
1116 s.next_read_length(10);
1117 memset(read_buf, 0, sizeof(read_buf));
1118 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1119 boost::asio::transfer_exactly(1));
1120 BOOST_ASIO_CHECK(bytes_transferred == 1);
1121 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
1122
1123 s.reset(read_data, sizeof(read_data));
1124 s.next_read_length(10);
1125 memset(read_buf, 0, sizeof(read_buf));
1126 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1127 boost::asio::transfer_exactly(1));
1128 BOOST_ASIO_CHECK(bytes_transferred == 1);
1129 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
1130
1131 s.reset(read_data, sizeof(read_data));
1132 memset(read_buf, 0, sizeof(read_buf));
1133 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1134 boost::asio::transfer_exactly(10));
1135 BOOST_ASIO_CHECK(bytes_transferred == 10);
1136 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
1137
1138 s.reset(read_data, sizeof(read_data));
1139 memset(read_buf, 0, sizeof(read_buf));
1140 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1141 boost::asio::transfer_exactly(10));
1142 BOOST_ASIO_CHECK(bytes_transferred == 10);
1143 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
1144
1145 s.reset(read_data, sizeof(read_data));
1146 s.next_read_length(1);
1147 memset(read_buf, 0, sizeof(read_buf));
1148 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1149 boost::asio::transfer_exactly(10));
1150 BOOST_ASIO_CHECK(bytes_transferred == 10);
1151 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
1152
1153 s.reset(read_data, sizeof(read_data));
1154 s.next_read_length(1);
1155 memset(read_buf, 0, sizeof(read_buf));
1156 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1157 boost::asio::transfer_exactly(10));
1158 BOOST_ASIO_CHECK(bytes_transferred == 10);
1159 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
1160
1161 s.reset(read_data, sizeof(read_data));
1162 s.next_read_length(10);
1163 memset(read_buf, 0, sizeof(read_buf));
1164 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1165 boost::asio::transfer_exactly(10));
1166 BOOST_ASIO_CHECK(bytes_transferred == 10);
1167 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
1168
1169 s.reset(read_data, sizeof(read_data));
1170 s.next_read_length(10);
1171 memset(read_buf, 0, sizeof(read_buf));
1172 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1173 boost::asio::transfer_exactly(10));
1174 BOOST_ASIO_CHECK(bytes_transferred == 10);
1175 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
1176
1177 s.reset(read_data, sizeof(read_data));
1178 memset(read_buf, 0, sizeof(read_buf));
1179 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1180 boost::asio::transfer_exactly(42));
1181 BOOST_ASIO_CHECK(bytes_transferred == 42);
1182 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
1183
1184 s.reset(read_data, sizeof(read_data));
1185 memset(read_buf, 0, sizeof(read_buf));
1186 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1187 boost::asio::transfer_exactly(42));
1188 BOOST_ASIO_CHECK(bytes_transferred == 42);
1189 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
1190
1191 s.reset(read_data, sizeof(read_data));
1192 s.next_read_length(1);
1193 memset(read_buf, 0, sizeof(read_buf));
1194 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1195 boost::asio::transfer_exactly(42));
1196 BOOST_ASIO_CHECK(bytes_transferred == 42);
1197 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
1198
1199 s.reset(read_data, sizeof(read_data));
1200 s.next_read_length(1);
1201 memset(read_buf, 0, sizeof(read_buf));
1202 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1203 boost::asio::transfer_exactly(42));
1204 BOOST_ASIO_CHECK(bytes_transferred == 42);
1205 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
1206
1207 s.reset(read_data, sizeof(read_data));
1208 s.next_read_length(10);
1209 memset(read_buf, 0, sizeof(read_buf));
1210 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1211 boost::asio::transfer_exactly(42));
1212 BOOST_ASIO_CHECK(bytes_transferred == 42);
1213 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
1214
1215 s.reset(read_data, sizeof(read_data));
1216 s.next_read_length(10);
1217 memset(read_buf, 0, sizeof(read_buf));
1218 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1219 boost::asio::transfer_exactly(42));
1220 BOOST_ASIO_CHECK(bytes_transferred == 42);
1221 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
1222
1223 s.reset(read_data, sizeof(read_data));
1224 memset(read_buf, 0, sizeof(read_buf));
1225 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1226 old_style_transfer_all);
1227 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1228 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
1229
1230 s.reset(read_data, sizeof(read_data));
1231 memset(read_buf, 0, sizeof(read_buf));
1232 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1233 old_style_transfer_all);
1234 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1235 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
1236
1237 s.reset(read_data, sizeof(read_data));
1238 s.next_read_length(1);
1239 memset(read_buf, 0, sizeof(read_buf));
1240 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1241 old_style_transfer_all);
1242 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1243 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
1244
1245 s.reset(read_data, sizeof(read_data));
1246 s.next_read_length(1);
1247 memset(read_buf, 0, sizeof(read_buf));
1248 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1249 old_style_transfer_all);
1250 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1251 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
1252
1253 s.reset(read_data, sizeof(read_data));
1254 s.next_read_length(10);
1255 memset(read_buf, 0, sizeof(read_buf));
1256 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1257 old_style_transfer_all);
1258 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1259 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
1260
1261 s.reset(read_data, sizeof(read_data));
1262 s.next_read_length(10);
1263 memset(read_buf, 0, sizeof(read_buf));
1264 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1265 old_style_transfer_all);
1266 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1267 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
1268
1269 s.reset(read_data, sizeof(read_data));
1270 memset(read_buf, 0, sizeof(read_buf));
1271 bytes_transferred = boost::asio::read_at(s, 0, buffers, short_transfer);
1272 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1273 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
1274
1275 s.reset(read_data, sizeof(read_data));
1276 memset(read_buf, 0, sizeof(read_buf));
1277 bytes_transferred = boost::asio::read_at(s, 1234, buffers, short_transfer);
1278 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1279 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
1280
1281 s.reset(read_data, sizeof(read_data));
1282 s.next_read_length(1);
1283 memset(read_buf, 0, sizeof(read_buf));
1284 bytes_transferred = boost::asio::read_at(s, 0, buffers, short_transfer);
1285 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1286 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
1287
1288 s.reset(read_data, sizeof(read_data));
1289 s.next_read_length(1);
1290 memset(read_buf, 0, sizeof(read_buf));
1291 bytes_transferred = boost::asio::read_at(s, 1234, buffers, short_transfer);
1292 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1293 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
1294
1295 s.reset(read_data, sizeof(read_data));
1296 s.next_read_length(10);
1297 memset(read_buf, 0, sizeof(read_buf));
1298 bytes_transferred = boost::asio::read_at(s, 0, buffers, short_transfer);
1299 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1300 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
1301
1302 s.reset(read_data, sizeof(read_data));
1303 s.next_read_length(10);
1304 memset(read_buf, 0, sizeof(read_buf));
1305 bytes_transferred = boost::asio::read_at(s, 1234, buffers, short_transfer);
1306 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1307 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
1308}
1309
1310void test_4_arg_streambuf_read_at()
1311{
1312 boost::asio::io_service ios;
1313 test_random_access_device s(ios);
1314 boost::asio::streambuf sb(sizeof(read_data));
1315
1316 s.reset(read_data, sizeof(read_data));
1317 sb.consume(sb.size());
1318 size_t bytes_transferred = boost::asio::read_at(s, 0, sb,
1319 boost::asio::transfer_all());
1320 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1321 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1322 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
1323
1324 s.reset(read_data, sizeof(read_data));
1325 sb.consume(sb.size());
1326 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1327 boost::asio::transfer_all());
1328 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1329 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1330 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
1331
1332 s.reset(read_data, sizeof(read_data));
1333 s.next_read_length(1);
1334 sb.consume(sb.size());
1335 bytes_transferred = boost::asio::read_at(s, 0, sb,
1336 boost::asio::transfer_all());
1337 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1338 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1339 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
1340
1341 s.reset(read_data, sizeof(read_data));
1342 s.next_read_length(1);
1343 sb.consume(sb.size());
1344 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1345 boost::asio::transfer_all());
1346 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1347 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1348 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
1349
1350 s.reset(read_data, sizeof(read_data));
1351 s.next_read_length(10);
1352 sb.consume(sb.size());
1353 bytes_transferred = boost::asio::read_at(s, 0, sb,
1354 boost::asio::transfer_all());
1355 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1356 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1357 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
1358
1359 s.reset(read_data, sizeof(read_data));
1360 s.next_read_length(10);
1361 sb.consume(sb.size());
1362 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1363 boost::asio::transfer_all());
1364 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1365 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1366 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
1367
1368 s.reset(read_data, sizeof(read_data));
1369 sb.consume(sb.size());
1370 bytes_transferred = boost::asio::read_at(s, 0, sb,
1371 boost::asio::transfer_at_least(1));
1372 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1373 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1374 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
1375
1376 s.reset(read_data, sizeof(read_data));
1377 sb.consume(sb.size());
1378 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1379 boost::asio::transfer_at_least(1));
1380 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1381 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1382 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
1383
1384 s.reset(read_data, sizeof(read_data));
1385 s.next_read_length(1);
1386 sb.consume(sb.size());
1387 bytes_transferred = boost::asio::read_at(s, 0, sb,
1388 boost::asio::transfer_at_least(1));
1389 BOOST_ASIO_CHECK(bytes_transferred == 1);
1390 BOOST_ASIO_CHECK(sb.size() == 1);
1391 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
1392
1393 s.reset(read_data, sizeof(read_data));
1394 s.next_read_length(1);
1395 sb.consume(sb.size());
1396 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1397 boost::asio::transfer_at_least(1));
1398 BOOST_ASIO_CHECK(bytes_transferred == 1);
1399 BOOST_ASIO_CHECK(sb.size() == 1);
1400 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
1401
1402 s.reset(read_data, sizeof(read_data));
1403 s.next_read_length(10);
1404 sb.consume(sb.size());
1405 bytes_transferred = boost::asio::read_at(s, 0, sb,
1406 boost::asio::transfer_at_least(1));
1407 BOOST_ASIO_CHECK(bytes_transferred == 10);
1408 BOOST_ASIO_CHECK(sb.size() == 10);
1409 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
1410
1411 s.reset(read_data, sizeof(read_data));
1412 s.next_read_length(10);
1413 sb.consume(sb.size());
1414 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1415 boost::asio::transfer_at_least(1));
1416 BOOST_ASIO_CHECK(bytes_transferred == 10);
1417 BOOST_ASIO_CHECK(sb.size() == 10);
1418 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
1419
1420 s.reset(read_data, sizeof(read_data));
1421 sb.consume(sb.size());
1422 bytes_transferred = boost::asio::read_at(s, 0, sb,
1423 boost::asio::transfer_at_least(10));
1424 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1425 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1426 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
1427
1428 s.reset(read_data, sizeof(read_data));
1429 sb.consume(sb.size());
1430 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1431 boost::asio::transfer_at_least(10));
1432 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1433 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1434 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
1435
1436 s.reset(read_data, sizeof(read_data));
1437 s.next_read_length(1);
1438 sb.consume(sb.size());
1439 bytes_transferred = boost::asio::read_at(s, 0, sb,
1440 boost::asio::transfer_at_least(10));
1441 BOOST_ASIO_CHECK(bytes_transferred == 10);
1442 BOOST_ASIO_CHECK(sb.size() == 10);
1443 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
1444
1445 s.reset(read_data, sizeof(read_data));
1446 s.next_read_length(1);
1447 sb.consume(sb.size());
1448 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1449 boost::asio::transfer_at_least(10));
1450 BOOST_ASIO_CHECK(bytes_transferred == 10);
1451 BOOST_ASIO_CHECK(sb.size() == 10);
1452 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
1453
1454 s.reset(read_data, sizeof(read_data));
1455 s.next_read_length(10);
1456 sb.consume(sb.size());
1457 bytes_transferred = boost::asio::read_at(s, 0, sb,
1458 boost::asio::transfer_at_least(10));
1459 BOOST_ASIO_CHECK(bytes_transferred == 10);
1460 BOOST_ASIO_CHECK(sb.size() == 10);
1461 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
1462
1463 s.reset(read_data, sizeof(read_data));
1464 s.next_read_length(10);
1465 sb.consume(sb.size());
1466 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1467 boost::asio::transfer_at_least(10));
1468 BOOST_ASIO_CHECK(bytes_transferred == 10);
1469 BOOST_ASIO_CHECK(sb.size() == 10);
1470 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
1471
1472 s.reset(read_data, sizeof(read_data));
1473 sb.consume(sb.size());
1474 bytes_transferred = boost::asio::read_at(s, 0, sb,
1475 boost::asio::transfer_at_least(42));
1476 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1477 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1478 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
1479
1480 s.reset(read_data, sizeof(read_data));
1481 sb.consume(sb.size());
1482 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1483 boost::asio::transfer_at_least(42));
1484 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1485 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1486 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
1487
1488 s.reset(read_data, sizeof(read_data));
1489 s.next_read_length(1);
1490 sb.consume(sb.size());
1491 bytes_transferred = boost::asio::read_at(s, 0, sb,
1492 boost::asio::transfer_at_least(42));
1493 BOOST_ASIO_CHECK(bytes_transferred == 42);
1494 BOOST_ASIO_CHECK(sb.size() == 42);
1495 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
1496
1497 s.reset(read_data, sizeof(read_data));
1498 s.next_read_length(1);
1499 sb.consume(sb.size());
1500 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1501 boost::asio::transfer_at_least(42));
1502 BOOST_ASIO_CHECK(bytes_transferred == 42);
1503 BOOST_ASIO_CHECK(sb.size() == 42);
1504 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
1505
1506 s.reset(read_data, sizeof(read_data));
1507 s.next_read_length(10);
1508 sb.consume(sb.size());
1509 bytes_transferred = boost::asio::read_at(s, 0, sb,
1510 boost::asio::transfer_at_least(42));
1511 BOOST_ASIO_CHECK(bytes_transferred == 50);
1512 BOOST_ASIO_CHECK(sb.size() == 50);
1513 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 50));
1514
1515 s.reset(read_data, sizeof(read_data));
1516 s.next_read_length(10);
1517 sb.consume(sb.size());
1518 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1519 boost::asio::transfer_at_least(42));
1520 BOOST_ASIO_CHECK(bytes_transferred == 50);
1521 BOOST_ASIO_CHECK(sb.size() == 50);
1522 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 50));
1523
1524 s.reset(read_data, sizeof(read_data));
1525 sb.consume(sb.size());
1526 bytes_transferred = boost::asio::read_at(s, 0, sb,
1527 boost::asio::transfer_exactly(1));
1528 BOOST_ASIO_CHECK(bytes_transferred == 1);
1529 BOOST_ASIO_CHECK(sb.size() == 1);
1530 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
1531
1532 s.reset(read_data, sizeof(read_data));
1533 sb.consume(sb.size());
1534 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1535 boost::asio::transfer_exactly(1));
1536 BOOST_ASIO_CHECK(bytes_transferred == 1);
1537 BOOST_ASIO_CHECK(sb.size() == 1);
1538 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
1539
1540 s.reset(read_data, sizeof(read_data));
1541 s.next_read_length(1);
1542 sb.consume(sb.size());
1543 bytes_transferred = boost::asio::read_at(s, 0, sb,
1544 boost::asio::transfer_exactly(1));
1545 BOOST_ASIO_CHECK(bytes_transferred == 1);
1546 BOOST_ASIO_CHECK(sb.size() == 1);
1547 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
1548
1549 s.reset(read_data, sizeof(read_data));
1550 s.next_read_length(1);
1551 sb.consume(sb.size());
1552 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1553 boost::asio::transfer_exactly(1));
1554 BOOST_ASIO_CHECK(bytes_transferred == 1);
1555 BOOST_ASIO_CHECK(sb.size() == 1);
1556 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
1557
1558 s.reset(read_data, sizeof(read_data));
1559 s.next_read_length(10);
1560 sb.consume(sb.size());
1561 bytes_transferred = boost::asio::read_at(s, 0, sb,
1562 boost::asio::transfer_exactly(1));
1563 BOOST_ASIO_CHECK(bytes_transferred == 1);
1564 BOOST_ASIO_CHECK(sb.size() == 1);
1565 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
1566
1567 s.reset(read_data, sizeof(read_data));
1568 s.next_read_length(10);
1569 sb.consume(sb.size());
1570 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1571 boost::asio::transfer_exactly(1));
1572 BOOST_ASIO_CHECK(bytes_transferred == 1);
1573 BOOST_ASIO_CHECK(sb.size() == 1);
1574 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
1575
1576 s.reset(read_data, sizeof(read_data));
1577 sb.consume(sb.size());
1578 bytes_transferred = boost::asio::read_at(s, 0, sb,
1579 boost::asio::transfer_exactly(10));
1580 BOOST_ASIO_CHECK(bytes_transferred == 10);
1581 BOOST_ASIO_CHECK(sb.size() == 10);
1582 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
1583
1584 s.reset(read_data, sizeof(read_data));
1585 sb.consume(sb.size());
1586 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1587 boost::asio::transfer_exactly(10));
1588 BOOST_ASIO_CHECK(bytes_transferred == 10);
1589 BOOST_ASIO_CHECK(sb.size() == 10);
1590 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
1591
1592 s.reset(read_data, sizeof(read_data));
1593 s.next_read_length(1);
1594 sb.consume(sb.size());
1595 bytes_transferred = boost::asio::read_at(s, 0, sb,
1596 boost::asio::transfer_exactly(10));
1597 BOOST_ASIO_CHECK(bytes_transferred == 10);
1598 BOOST_ASIO_CHECK(sb.size() == 10);
1599 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
1600
1601 s.reset(read_data, sizeof(read_data));
1602 s.next_read_length(1);
1603 sb.consume(sb.size());
1604 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1605 boost::asio::transfer_exactly(10));
1606 BOOST_ASIO_CHECK(bytes_transferred == 10);
1607 BOOST_ASIO_CHECK(sb.size() == 10);
1608 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
1609
1610 s.reset(read_data, sizeof(read_data));
1611 s.next_read_length(10);
1612 sb.consume(sb.size());
1613 bytes_transferred = boost::asio::read_at(s, 0, sb,
1614 boost::asio::transfer_exactly(10));
1615 BOOST_ASIO_CHECK(bytes_transferred == 10);
1616 BOOST_ASIO_CHECK(sb.size() == 10);
1617 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
1618
1619 s.reset(read_data, sizeof(read_data));
1620 s.next_read_length(10);
1621 sb.consume(sb.size());
1622 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1623 boost::asio::transfer_exactly(10));
1624 BOOST_ASIO_CHECK(bytes_transferred == 10);
1625 BOOST_ASIO_CHECK(sb.size() == 10);
1626 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
1627
1628 s.reset(read_data, sizeof(read_data));
1629 sb.consume(sb.size());
1630 bytes_transferred = boost::asio::read_at(s, 0, sb,
1631 boost::asio::transfer_exactly(42));
1632 BOOST_ASIO_CHECK(bytes_transferred == 42);
1633 BOOST_ASIO_CHECK(sb.size() == 42);
1634 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
1635
1636 s.reset(read_data, sizeof(read_data));
1637 sb.consume(sb.size());
1638 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1639 boost::asio::transfer_exactly(42));
1640 BOOST_ASIO_CHECK(bytes_transferred == 42);
1641 BOOST_ASIO_CHECK(sb.size() == 42);
1642 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
1643
1644 s.reset(read_data, sizeof(read_data));
1645 s.next_read_length(1);
1646 sb.consume(sb.size());
1647 bytes_transferred = boost::asio::read_at(s, 0, sb,
1648 boost::asio::transfer_exactly(42));
1649 BOOST_ASIO_CHECK(bytes_transferred == 42);
1650 BOOST_ASIO_CHECK(sb.size() == 42);
1651 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
1652
1653 s.reset(read_data, sizeof(read_data));
1654 s.next_read_length(1);
1655 sb.consume(sb.size());
1656 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1657 boost::asio::transfer_exactly(42));
1658 BOOST_ASIO_CHECK(bytes_transferred == 42);
1659 BOOST_ASIO_CHECK(sb.size() == 42);
1660 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
1661
1662 s.reset(read_data, sizeof(read_data));
1663 s.next_read_length(10);
1664 sb.consume(sb.size());
1665 bytes_transferred = boost::asio::read_at(s, 0, sb,
1666 boost::asio::transfer_exactly(42));
1667 BOOST_ASIO_CHECK(bytes_transferred == 42);
1668 BOOST_ASIO_CHECK(sb.size() == 42);
1669 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
1670
1671 s.reset(read_data, sizeof(read_data));
1672 s.next_read_length(10);
1673 sb.consume(sb.size());
1674 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1675 boost::asio::transfer_exactly(42));
1676 BOOST_ASIO_CHECK(bytes_transferred == 42);
1677 BOOST_ASIO_CHECK(sb.size() == 42);
1678 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
1679
1680 s.reset(read_data, sizeof(read_data));
1681 sb.consume(sb.size());
1682 bytes_transferred = boost::asio::read_at(s, 0, sb,
1683 old_style_transfer_all);
1684 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1685 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1686 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
1687
1688 s.reset(read_data, sizeof(read_data));
1689 sb.consume(sb.size());
1690 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1691 old_style_transfer_all);
1692 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1693 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1694 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
1695
1696 s.reset(read_data, sizeof(read_data));
1697 s.next_read_length(1);
1698 sb.consume(sb.size());
1699 bytes_transferred = boost::asio::read_at(s, 0, sb,
1700 old_style_transfer_all);
1701 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1702 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1703 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
1704
1705 s.reset(read_data, sizeof(read_data));
1706 s.next_read_length(1);
1707 sb.consume(sb.size());
1708 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1709 old_style_transfer_all);
1710 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1711 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1712 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
1713
1714 s.reset(read_data, sizeof(read_data));
1715 s.next_read_length(10);
1716 sb.consume(sb.size());
1717 bytes_transferred = boost::asio::read_at(s, 0, sb,
1718 old_style_transfer_all);
1719 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1720 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1721 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
1722
1723 s.reset(read_data, sizeof(read_data));
1724 s.next_read_length(10);
1725 sb.consume(sb.size());
1726 bytes_transferred = boost::asio::read_at(s, 1234, sb,
1727 old_style_transfer_all);
1728 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1729 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1730 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
1731
1732 s.reset(read_data, sizeof(read_data));
1733 sb.consume(sb.size());
1734 bytes_transferred = boost::asio::read_at(s, 0, sb, short_transfer);
1735 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1736 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1737 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
1738
1739 s.reset(read_data, sizeof(read_data));
1740 sb.consume(sb.size());
1741 bytes_transferred = boost::asio::read_at(s, 1234, sb, short_transfer);
1742 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1743 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1744 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
1745
1746 s.reset(read_data, sizeof(read_data));
1747 s.next_read_length(1);
1748 sb.consume(sb.size());
1749 bytes_transferred = boost::asio::read_at(s, 0, sb, short_transfer);
1750 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1751 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1752 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
1753
1754 s.reset(read_data, sizeof(read_data));
1755 s.next_read_length(1);
1756 sb.consume(sb.size());
1757 bytes_transferred = boost::asio::read_at(s, 1234, sb, short_transfer);
1758 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1759 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1760 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
1761
1762 s.reset(read_data, sizeof(read_data));
1763 s.next_read_length(10);
1764 sb.consume(sb.size());
1765 bytes_transferred = boost::asio::read_at(s, 0, sb, short_transfer);
1766 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1767 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1768 BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
1769
1770 s.reset(read_data, sizeof(read_data));
1771 s.next_read_length(10);
1772 sb.consume(sb.size());
1773 bytes_transferred = boost::asio::read_at(s, 1234, sb, short_transfer);
1774 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1775 BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
1776 BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
1777}
1778
1779void test_5_arg_mutable_buffers_1_read_at()
1780{
1781 boost::asio::io_service ios;
1782 test_random_access_device s(ios);
1783 char read_buf[sizeof(read_data)];
1784 boost::asio::mutable_buffers_1 buffers
1785 = boost::asio::buffer(read_buf, sizeof(read_buf));
1786
1787 s.reset(read_data, sizeof(read_data));
1788 memset(read_buf, 0, sizeof(read_buf));
1789 boost::system::error_code error;
1790 size_t bytes_transferred = boost::asio::read_at(s, 0, buffers,
1791 boost::asio::transfer_all(), error);
1792 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1793 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
1794 BOOST_ASIO_CHECK(!error);
1795
1796 s.reset(read_data, sizeof(read_data));
1797 memset(read_buf, 0, sizeof(read_buf));
1798 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1799 boost::asio::transfer_all(), error);
1800 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1801 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
1802 BOOST_ASIO_CHECK(!error);
1803
1804 s.reset(read_data, sizeof(read_data));
1805 s.next_read_length(1);
1806 memset(read_buf, 0, sizeof(read_buf));
1807 error = boost::system::error_code();
1808 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1809 boost::asio::transfer_all(), error);
1810 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1811 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
1812 BOOST_ASIO_CHECK(!error);
1813
1814 s.reset(read_data, sizeof(read_data));
1815 s.next_read_length(1);
1816 memset(read_buf, 0, sizeof(read_buf));
1817 error = boost::system::error_code();
1818 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1819 boost::asio::transfer_all(), error);
1820 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1821 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
1822 BOOST_ASIO_CHECK(!error);
1823
1824 s.reset(read_data, sizeof(read_data));
1825 s.next_read_length(10);
1826 memset(read_buf, 0, sizeof(read_buf));
1827 error = boost::system::error_code();
1828 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1829 boost::asio::transfer_all(), error);
1830 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1831 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
1832 BOOST_ASIO_CHECK(!error);
1833
1834 s.reset(read_data, sizeof(read_data));
1835 s.next_read_length(10);
1836 memset(read_buf, 0, sizeof(read_buf));
1837 error = boost::system::error_code();
1838 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1839 boost::asio::transfer_all(), error);
1840 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1841 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
1842 BOOST_ASIO_CHECK(!error);
1843
1844 s.reset(read_data, sizeof(read_data));
1845 memset(read_buf, 0, sizeof(read_buf));
1846 error = boost::system::error_code();
1847 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1848 boost::asio::transfer_at_least(1), error);
1849 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1850 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
1851 BOOST_ASIO_CHECK(!error);
1852
1853 s.reset(read_data, sizeof(read_data));
1854 memset(read_buf, 0, sizeof(read_buf));
1855 error = boost::system::error_code();
1856 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1857 boost::asio::transfer_at_least(1), error);
1858 BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
1859 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
1860 BOOST_ASIO_CHECK(!error);
1861
1862 s.reset(read_data, sizeof(read_data));
1863 s.next_read_length(1);
1864 memset(read_buf, 0, sizeof(read_buf));
1865 error = boost::system::error_code();
1866 bytes_transferred = boost::asio::read_at(s, 0, buffers,
1867 boost::asio::transfer_at_least(1), error);
1868 BOOST_ASIO_CHECK(bytes_transferred == 1);
1869 BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
1870 BOOST_ASIO_CHECK(!error);
1871
1872 s.reset(read_data, sizeof(read_data));
1873 s.next_read_length(1);
1874 memset(read_buf, 0, sizeof(read_buf));
1875 error = boost::system::error_code();
1876 bytes_transferred = boost::asio::read_at(s, 1234, buffers,
1877 boost::asio::transfer_at_least(1), error);
1878 BOOST_ASIO_CHECK(bytes_transferred == 1);
1879 BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
1880 BOOST_ASIO_CHECK(!error);
1881
1882 s.reset(read_data, sizeof(read_data));
1883 s.next_read_length(10);
1884 memset(read_buf, 0, sizeof(read_buf));
1885