5 // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
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)
16 // Test that header file is self-contained.
17 #include <boost/asio/write.hpp>
21 #include "archetypes/async_result.hpp"
22 #include <boost/asio/io_service.hpp>
23 #include <boost/asio/streambuf.hpp>
24 #include "unit_test.hpp"
26 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
27 # include <boost/bind.hpp>
28 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
29 # include <functional>
30 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
32 #if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
33 #include <boost/array.hpp>
34 #endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
36 #if defined(BOOST_ASIO_HAS_STD_ARRAY)
38 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
40 using namespace std
; // For memcmp, memcpy and memset.
45 typedef boost::asio::io_service io_service_type
;
47 test_stream(boost::asio::io_service
& io_service
)
48 : io_service_(io_service
),
51 next_write_length_(max_length
)
53 memset(data_
, 0, max_length
);
56 io_service_type
& get_io_service()
61 void reset(size_t length
= max_length
)
63 BOOST_ASIO_CHECK(length
<= max_length
);
65 memset(data_
, 0, max_length
);
68 next_write_length_
= length
;
71 void next_write_length(size_t length
)
73 next_write_length_
= length
;
76 template <typename Const_Buffers
>
77 bool check_buffers(const Const_Buffers
& buffers
, size_t length
)
79 if (length
!= position_
)
82 typename
Const_Buffers::const_iterator iter
= buffers
.begin();
83 typename
Const_Buffers::const_iterator end
= buffers
.end();
84 size_t checked_length
= 0;
85 for (; iter
!= end
&& checked_length
< length
; ++iter
)
87 size_t buffer_length
= boost::asio::buffer_size(*iter
);
88 if (buffer_length
> length
- checked_length
)
89 buffer_length
= length
- checked_length
;
90 if (memcmp(data_
+ checked_length
,
91 boost::asio::buffer_cast
<const void*>(*iter
), buffer_length
) != 0)
93 checked_length
+= buffer_length
;
99 template <typename Const_Buffers
>
100 size_t write_some(const Const_Buffers
& buffers
)
102 size_t n
= boost::asio::buffer_copy(
103 boost::asio::buffer(data_
, length_
) + position_
,
104 buffers
, next_write_length_
);
109 template <typename Const_Buffers
>
110 size_t write_some(const Const_Buffers
& buffers
, boost::system::error_code
& ec
)
112 ec
= boost::system::error_code();
113 return write_some(buffers
);
116 template <typename Const_Buffers
, typename Handler
>
117 void async_write_some(const Const_Buffers
& buffers
, Handler handler
)
119 size_t bytes_transferred
= write_some(buffers
);
120 io_service_
.post(boost::asio::detail::bind_handler(
121 handler
, boost::system::error_code(), bytes_transferred
));
125 io_service_type
& io_service_
;
126 enum { max_length
= 8192 };
127 char data_
[max_length
];
130 size_t next_write_length_
;
133 static const char write_data
[]
134 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
135 static char mutable_write_data
[]
136 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
138 void test_2_arg_zero_buffers_write()
140 boost::asio::io_service ios
;
142 std::vector
<boost::asio::const_buffer
> buffers
;
144 size_t bytes_transferred
= boost::asio::write(s
, buffers
);
145 BOOST_ASIO_CHECK(bytes_transferred
== 0);
148 void test_2_arg_const_buffers_1_write()
150 boost::asio::io_service ios
;
152 boost::asio::const_buffers_1 buffers
153 = boost::asio::buffer(write_data
, sizeof(write_data
));
156 size_t bytes_transferred
= boost::asio::write(s
, buffers
);
157 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
158 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
161 s
.next_write_length(1);
162 bytes_transferred
= boost::asio::write(s
, buffers
);
163 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
164 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
167 s
.next_write_length(10);
168 bytes_transferred
= boost::asio::write(s
, buffers
);
169 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
170 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
173 void test_2_arg_mutable_buffers_1_write()
175 boost::asio::io_service ios
;
177 boost::asio::mutable_buffers_1 buffers
178 = boost::asio::buffer(mutable_write_data
, sizeof(mutable_write_data
));
181 size_t bytes_transferred
= boost::asio::write(s
, buffers
);
182 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
183 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
186 s
.next_write_length(1);
187 bytes_transferred
= boost::asio::write(s
, buffers
);
188 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
189 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
192 s
.next_write_length(10);
193 bytes_transferred
= boost::asio::write(s
, buffers
);
194 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
195 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
198 void test_2_arg_vector_buffers_write()
200 boost::asio::io_service ios
;
202 std::vector
<boost::asio::const_buffer
> buffers
;
203 buffers
.push_back(boost::asio::buffer(write_data
, 32));
204 buffers
.push_back(boost::asio::buffer(write_data
) + 32);
207 size_t bytes_transferred
= boost::asio::write(s
, buffers
);
208 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
209 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
212 s
.next_write_length(1);
213 bytes_transferred
= boost::asio::write(s
, buffers
);
214 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
215 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
218 s
.next_write_length(10);
219 bytes_transferred
= boost::asio::write(s
, buffers
);
220 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
221 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
224 void test_3_arg_nothrow_zero_buffers_write()
226 boost::asio::io_service ios
;
228 std::vector
<boost::asio::const_buffer
> buffers
;
230 boost::system::error_code error
;
231 size_t bytes_transferred
= boost::asio::write(s
, buffers
, error
);
232 BOOST_ASIO_CHECK(bytes_transferred
== 0);
233 BOOST_ASIO_CHECK(!error
);
236 void test_3_arg_nothrow_const_buffers_1_write()
238 boost::asio::io_service ios
;
240 boost::asio::const_buffers_1 buffers
241 = boost::asio::buffer(write_data
, sizeof(write_data
));
244 boost::system::error_code error
;
245 size_t bytes_transferred
= boost::asio::write(s
, buffers
, error
);
246 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
247 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
248 BOOST_ASIO_CHECK(!error
);
251 s
.next_write_length(1);
252 bytes_transferred
= boost::asio::write(s
, buffers
, error
);
253 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
254 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
255 BOOST_ASIO_CHECK(!error
);
258 s
.next_write_length(10);
259 bytes_transferred
= boost::asio::write(s
, buffers
, error
);
260 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
261 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
262 BOOST_ASIO_CHECK(!error
);
265 void test_3_arg_nothrow_mutable_buffers_1_write()
267 boost::asio::io_service ios
;
269 boost::asio::mutable_buffers_1 buffers
270 = boost::asio::buffer(mutable_write_data
, sizeof(mutable_write_data
));
273 boost::system::error_code error
;
274 size_t bytes_transferred
= boost::asio::write(s
, buffers
, error
);
275 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
276 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
277 BOOST_ASIO_CHECK(!error
);
280 s
.next_write_length(1);
281 bytes_transferred
= boost::asio::write(s
, buffers
, error
);
282 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
283 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
284 BOOST_ASIO_CHECK(!error
);
287 s
.next_write_length(10);
288 bytes_transferred
= boost::asio::write(s
, buffers
, error
);
289 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
290 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
291 BOOST_ASIO_CHECK(!error
);
294 void test_3_arg_nothrow_vector_buffers_write()
296 boost::asio::io_service ios
;
298 std::vector
<boost::asio::const_buffer
> buffers
;
299 buffers
.push_back(boost::asio::buffer(write_data
, 32));
300 buffers
.push_back(boost::asio::buffer(write_data
) + 32);
303 boost::system::error_code error
;
304 size_t bytes_transferred
= boost::asio::write(s
, buffers
, error
);
305 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
306 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
307 BOOST_ASIO_CHECK(!error
);
310 s
.next_write_length(1);
311 bytes_transferred
= boost::asio::write(s
, buffers
, error
);
312 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
313 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
314 BOOST_ASIO_CHECK(!error
);
317 s
.next_write_length(10);
318 bytes_transferred
= boost::asio::write(s
, buffers
, error
);
319 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
320 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
321 BOOST_ASIO_CHECK(!error
);
324 bool old_style_transfer_all(const boost::system::error_code
& ec
,
325 size_t /*bytes_transferred*/)
330 size_t short_transfer(const boost::system::error_code
& ec
,
331 size_t /*bytes_transferred*/)
336 void test_3_arg_const_buffers_1_write()
338 boost::asio::io_service ios
;
340 boost::asio::const_buffers_1 buffers
341 = boost::asio::buffer(write_data
, sizeof(write_data
));
344 size_t bytes_transferred
= boost::asio::write(s
, buffers
,
345 boost::asio::transfer_all());
346 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
347 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
350 s
.next_write_length(1);
351 bytes_transferred
= boost::asio::write(s
, buffers
,
352 boost::asio::transfer_all());
353 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
354 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
357 s
.next_write_length(10);
358 bytes_transferred
= boost::asio::write(s
, buffers
,
359 boost::asio::transfer_all());
360 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
361 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
364 bytes_transferred
= boost::asio::write(s
, buffers
,
365 boost::asio::transfer_at_least(1));
366 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
367 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
370 s
.next_write_length(1);
371 bytes_transferred
= boost::asio::write(s
, buffers
,
372 boost::asio::transfer_at_least(1));
373 BOOST_ASIO_CHECK(bytes_transferred
== 1);
374 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
377 s
.next_write_length(10);
378 bytes_transferred
= boost::asio::write(s
, buffers
,
379 boost::asio::transfer_at_least(1));
380 BOOST_ASIO_CHECK(bytes_transferred
== 10);
381 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
384 bytes_transferred
= boost::asio::write(s
, buffers
,
385 boost::asio::transfer_at_least(10));
386 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
387 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
390 s
.next_write_length(1);
391 bytes_transferred
= boost::asio::write(s
, buffers
,
392 boost::asio::transfer_at_least(10));
393 BOOST_ASIO_CHECK(bytes_transferred
== 10);
394 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
397 s
.next_write_length(10);
398 bytes_transferred
= boost::asio::write(s
, buffers
,
399 boost::asio::transfer_at_least(10));
400 BOOST_ASIO_CHECK(bytes_transferred
== 10);
401 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
404 bytes_transferred
= boost::asio::write(s
, buffers
,
405 boost::asio::transfer_at_least(42));
406 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
407 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
410 s
.next_write_length(1);
411 bytes_transferred
= boost::asio::write(s
, buffers
,
412 boost::asio::transfer_at_least(42));
413 BOOST_ASIO_CHECK(bytes_transferred
== 42);
414 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
417 s
.next_write_length(10);
418 bytes_transferred
= boost::asio::write(s
, buffers
,
419 boost::asio::transfer_at_least(42));
420 BOOST_ASIO_CHECK(bytes_transferred
== 50);
421 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 50));
424 bytes_transferred
= boost::asio::write(s
, buffers
,
425 boost::asio::transfer_exactly(1));
426 BOOST_ASIO_CHECK(bytes_transferred
== 1);
427 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
430 s
.next_write_length(1);
431 bytes_transferred
= boost::asio::write(s
, buffers
,
432 boost::asio::transfer_exactly(1));
433 BOOST_ASIO_CHECK(bytes_transferred
== 1);
434 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
437 s
.next_write_length(10);
438 bytes_transferred
= boost::asio::write(s
, buffers
,
439 boost::asio::transfer_exactly(1));
440 BOOST_ASIO_CHECK(bytes_transferred
== 1);
441 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
444 bytes_transferred
= boost::asio::write(s
, buffers
,
445 boost::asio::transfer_exactly(10));
446 BOOST_ASIO_CHECK(bytes_transferred
== 10);
447 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
450 s
.next_write_length(1);
451 bytes_transferred
= boost::asio::write(s
, buffers
,
452 boost::asio::transfer_exactly(10));
453 BOOST_ASIO_CHECK(bytes_transferred
== 10);
454 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
457 s
.next_write_length(10);
458 bytes_transferred
= boost::asio::write(s
, buffers
,
459 boost::asio::transfer_exactly(10));
460 BOOST_ASIO_CHECK(bytes_transferred
== 10);
461 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
464 bytes_transferred
= boost::asio::write(s
, buffers
,
465 boost::asio::transfer_exactly(42));
466 BOOST_ASIO_CHECK(bytes_transferred
== 42);
467 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
470 s
.next_write_length(1);
471 bytes_transferred
= boost::asio::write(s
, buffers
,
472 boost::asio::transfer_exactly(42));
473 BOOST_ASIO_CHECK(bytes_transferred
== 42);
474 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
477 s
.next_write_length(10);
478 bytes_transferred
= boost::asio::write(s
, buffers
,
479 boost::asio::transfer_exactly(42));
480 BOOST_ASIO_CHECK(bytes_transferred
== 42);
481 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
484 bytes_transferred
= boost::asio::write(s
, buffers
, old_style_transfer_all
);
485 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
486 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
489 s
.next_write_length(1);
490 bytes_transferred
= boost::asio::write(s
, buffers
, old_style_transfer_all
);
491 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
492 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
495 s
.next_write_length(10);
496 bytes_transferred
= boost::asio::write(s
, buffers
, old_style_transfer_all
);
497 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
498 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
501 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
);
502 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
503 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
506 s
.next_write_length(1);
507 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
);
508 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
509 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
512 s
.next_write_length(10);
513 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
);
514 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
515 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
518 void test_3_arg_mutable_buffers_1_write()
520 boost::asio::io_service ios
;
522 boost::asio::mutable_buffers_1 buffers
523 = boost::asio::buffer(mutable_write_data
, sizeof(mutable_write_data
));
526 size_t bytes_transferred
= boost::asio::write(s
, buffers
,
527 boost::asio::transfer_all());
528 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
529 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
532 s
.next_write_length(1);
533 bytes_transferred
= boost::asio::write(s
, buffers
,
534 boost::asio::transfer_all());
535 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
536 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
539 s
.next_write_length(10);
540 bytes_transferred
= boost::asio::write(s
, buffers
,
541 boost::asio::transfer_all());
542 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
543 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
546 bytes_transferred
= boost::asio::write(s
, buffers
,
547 boost::asio::transfer_at_least(1));
548 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
549 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
552 s
.next_write_length(1);
553 bytes_transferred
= boost::asio::write(s
, buffers
,
554 boost::asio::transfer_at_least(1));
555 BOOST_ASIO_CHECK(bytes_transferred
== 1);
556 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
559 s
.next_write_length(10);
560 bytes_transferred
= boost::asio::write(s
, buffers
,
561 boost::asio::transfer_at_least(1));
562 BOOST_ASIO_CHECK(bytes_transferred
== 10);
563 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
566 bytes_transferred
= boost::asio::write(s
, buffers
,
567 boost::asio::transfer_at_least(10));
568 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
569 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
572 s
.next_write_length(1);
573 bytes_transferred
= boost::asio::write(s
, buffers
,
574 boost::asio::transfer_at_least(10));
575 BOOST_ASIO_CHECK(bytes_transferred
== 10);
576 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
579 s
.next_write_length(10);
580 bytes_transferred
= boost::asio::write(s
, buffers
,
581 boost::asio::transfer_at_least(10));
582 BOOST_ASIO_CHECK(bytes_transferred
== 10);
583 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
586 bytes_transferred
= boost::asio::write(s
, buffers
,
587 boost::asio::transfer_at_least(42));
588 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
589 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
592 s
.next_write_length(1);
593 bytes_transferred
= boost::asio::write(s
, buffers
,
594 boost::asio::transfer_at_least(42));
595 BOOST_ASIO_CHECK(bytes_transferred
== 42);
596 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
599 s
.next_write_length(10);
600 bytes_transferred
= boost::asio::write(s
, buffers
,
601 boost::asio::transfer_at_least(42));
602 BOOST_ASIO_CHECK(bytes_transferred
== 50);
603 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 50));
606 bytes_transferred
= boost::asio::write(s
, buffers
,
607 boost::asio::transfer_exactly(1));
608 BOOST_ASIO_CHECK(bytes_transferred
== 1);
609 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
612 s
.next_write_length(1);
613 bytes_transferred
= boost::asio::write(s
, buffers
,
614 boost::asio::transfer_exactly(1));
615 BOOST_ASIO_CHECK(bytes_transferred
== 1);
616 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
619 s
.next_write_length(10);
620 bytes_transferred
= boost::asio::write(s
, buffers
,
621 boost::asio::transfer_exactly(1));
622 BOOST_ASIO_CHECK(bytes_transferred
== 1);
623 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
626 bytes_transferred
= boost::asio::write(s
, buffers
,
627 boost::asio::transfer_exactly(10));
628 BOOST_ASIO_CHECK(bytes_transferred
== 10);
629 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
632 s
.next_write_length(1);
633 bytes_transferred
= boost::asio::write(s
, buffers
,
634 boost::asio::transfer_exactly(10));
635 BOOST_ASIO_CHECK(bytes_transferred
== 10);
636 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
639 s
.next_write_length(10);
640 bytes_transferred
= boost::asio::write(s
, buffers
,
641 boost::asio::transfer_exactly(10));
642 BOOST_ASIO_CHECK(bytes_transferred
== 10);
643 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
646 bytes_transferred
= boost::asio::write(s
, buffers
,
647 boost::asio::transfer_exactly(42));
648 BOOST_ASIO_CHECK(bytes_transferred
== 42);
649 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
652 s
.next_write_length(1);
653 bytes_transferred
= boost::asio::write(s
, buffers
,
654 boost::asio::transfer_exactly(42));
655 BOOST_ASIO_CHECK(bytes_transferred
== 42);
656 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
659 s
.next_write_length(10);
660 bytes_transferred
= boost::asio::write(s
, buffers
,
661 boost::asio::transfer_exactly(42));
662 BOOST_ASIO_CHECK(bytes_transferred
== 42);
663 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
666 bytes_transferred
= boost::asio::write(s
, buffers
, old_style_transfer_all
);
667 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
668 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
671 s
.next_write_length(1);
672 bytes_transferred
= boost::asio::write(s
, buffers
, old_style_transfer_all
);
673 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
674 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
677 s
.next_write_length(10);
678 bytes_transferred
= boost::asio::write(s
, buffers
, old_style_transfer_all
);
679 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
680 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
683 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
);
684 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
685 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
688 s
.next_write_length(1);
689 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
);
690 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
691 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
694 s
.next_write_length(10);
695 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
);
696 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
697 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
700 void test_3_arg_vector_buffers_write()
702 boost::asio::io_service ios
;
704 std::vector
<boost::asio::const_buffer
> buffers
;
705 buffers
.push_back(boost::asio::buffer(write_data
, 32));
706 buffers
.push_back(boost::asio::buffer(write_data
) + 32);
709 size_t bytes_transferred
= boost::asio::write(s
, buffers
,
710 boost::asio::transfer_all());
711 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
712 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
715 s
.next_write_length(1);
716 bytes_transferred
= boost::asio::write(s
, buffers
,
717 boost::asio::transfer_all());
718 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
719 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
722 s
.next_write_length(10);
723 bytes_transferred
= boost::asio::write(s
, buffers
,
724 boost::asio::transfer_all());
725 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
726 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
729 bytes_transferred
= boost::asio::write(s
, buffers
,
730 boost::asio::transfer_at_least(1));
731 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
732 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
735 s
.next_write_length(1);
736 bytes_transferred
= boost::asio::write(s
, buffers
,
737 boost::asio::transfer_at_least(1));
738 BOOST_ASIO_CHECK(bytes_transferred
== 1);
739 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
742 s
.next_write_length(10);
743 bytes_transferred
= boost::asio::write(s
, buffers
,
744 boost::asio::transfer_at_least(1));
745 BOOST_ASIO_CHECK(bytes_transferred
== 10);
746 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
749 bytes_transferred
= boost::asio::write(s
, buffers
,
750 boost::asio::transfer_at_least(10));
751 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
752 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
755 s
.next_write_length(1);
756 bytes_transferred
= boost::asio::write(s
, buffers
,
757 boost::asio::transfer_at_least(10));
758 BOOST_ASIO_CHECK(bytes_transferred
== 10);
759 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
762 s
.next_write_length(10);
763 bytes_transferred
= boost::asio::write(s
, buffers
,
764 boost::asio::transfer_at_least(10));
765 BOOST_ASIO_CHECK(bytes_transferred
== 10);
766 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
769 bytes_transferred
= boost::asio::write(s
, buffers
,
770 boost::asio::transfer_at_least(42));
771 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
772 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
775 s
.next_write_length(1);
776 bytes_transferred
= boost::asio::write(s
, buffers
,
777 boost::asio::transfer_at_least(42));
778 BOOST_ASIO_CHECK(bytes_transferred
== 42);
779 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
782 s
.next_write_length(10);
783 bytes_transferred
= boost::asio::write(s
, buffers
,
784 boost::asio::transfer_at_least(42));
785 BOOST_ASIO_CHECK(bytes_transferred
== 50);
786 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 50));
789 bytes_transferred
= boost::asio::write(s
, buffers
,
790 boost::asio::transfer_exactly(1));
791 BOOST_ASIO_CHECK(bytes_transferred
== 1);
792 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
795 s
.next_write_length(1);
796 bytes_transferred
= boost::asio::write(s
, buffers
,
797 boost::asio::transfer_exactly(1));
798 BOOST_ASIO_CHECK(bytes_transferred
== 1);
799 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
802 s
.next_write_length(10);
803 bytes_transferred
= boost::asio::write(s
, buffers
,
804 boost::asio::transfer_exactly(1));
805 BOOST_ASIO_CHECK(bytes_transferred
== 1);
806 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
809 bytes_transferred
= boost::asio::write(s
, buffers
,
810 boost::asio::transfer_exactly(10));
811 BOOST_ASIO_CHECK(bytes_transferred
== 10);
812 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
815 s
.next_write_length(1);
816 bytes_transferred
= boost::asio::write(s
, buffers
,
817 boost::asio::transfer_exactly(10));
818 BOOST_ASIO_CHECK(bytes_transferred
== 10);
819 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
822 s
.next_write_length(10);
823 bytes_transferred
= boost::asio::write(s
, buffers
,
824 boost::asio::transfer_exactly(10));
825 BOOST_ASIO_CHECK(bytes_transferred
== 10);
826 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
829 bytes_transferred
= boost::asio::write(s
, buffers
,
830 boost::asio::transfer_exactly(42));
831 BOOST_ASIO_CHECK(bytes_transferred
== 42);
832 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
835 s
.next_write_length(1);
836 bytes_transferred
= boost::asio::write(s
, buffers
,
837 boost::asio::transfer_exactly(42));
838 BOOST_ASIO_CHECK(bytes_transferred
== 42);
839 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
842 s
.next_write_length(10);
843 bytes_transferred
= boost::asio::write(s
, buffers
,
844 boost::asio::transfer_exactly(42));
845 BOOST_ASIO_CHECK(bytes_transferred
== 42);
846 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
849 bytes_transferred
= boost::asio::write(s
, buffers
, old_style_transfer_all
);
850 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
851 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
854 s
.next_write_length(1);
855 bytes_transferred
= boost::asio::write(s
, buffers
, old_style_transfer_all
);
856 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
857 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
860 s
.next_write_length(10);
861 bytes_transferred
= boost::asio::write(s
, buffers
, old_style_transfer_all
);
862 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
863 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
866 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
);
867 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
868 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
871 s
.next_write_length(1);
872 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
);
873 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
874 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
877 s
.next_write_length(10);
878 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
);
879 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
880 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
883 void test_4_arg_const_buffers_1_write()
885 boost::asio::io_service ios
;
887 boost::asio::const_buffers_1 buffers
888 = boost::asio::buffer(write_data
, sizeof(write_data
));
891 boost::system::error_code error
;
892 size_t bytes_transferred
= boost::asio::write(s
, buffers
,
893 boost::asio::transfer_all(), error
);
894 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
895 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
896 BOOST_ASIO_CHECK(!error
);
899 s
.next_write_length(1);
900 error
= boost::system::error_code();
901 bytes_transferred
= boost::asio::write(s
, buffers
,
902 boost::asio::transfer_all(), error
);
903 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
904 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
905 BOOST_ASIO_CHECK(!error
);
908 s
.next_write_length(10);
909 error
= boost::system::error_code();
910 bytes_transferred
= boost::asio::write(s
, buffers
,
911 boost::asio::transfer_all(), error
);
912 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
913 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
914 BOOST_ASIO_CHECK(!error
);
917 error
= boost::system::error_code();
918 bytes_transferred
= boost::asio::write(s
, buffers
,
919 boost::asio::transfer_at_least(1), error
);
920 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
921 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
922 BOOST_ASIO_CHECK(!error
);
925 s
.next_write_length(1);
926 error
= boost::system::error_code();
927 bytes_transferred
= boost::asio::write(s
, buffers
,
928 boost::asio::transfer_at_least(1), error
);
929 BOOST_ASIO_CHECK(bytes_transferred
== 1);
930 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
931 BOOST_ASIO_CHECK(!error
);
934 s
.next_write_length(10);
935 error
= boost::system::error_code();
936 bytes_transferred
= boost::asio::write(s
, buffers
,
937 boost::asio::transfer_at_least(1), error
);
938 BOOST_ASIO_CHECK(bytes_transferred
== 10);
939 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
940 BOOST_ASIO_CHECK(!error
);
943 error
= boost::system::error_code();
944 bytes_transferred
= boost::asio::write(s
, buffers
,
945 boost::asio::transfer_at_least(10), error
);
946 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
947 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
948 BOOST_ASIO_CHECK(!error
);
951 s
.next_write_length(1);
952 error
= boost::system::error_code();
953 bytes_transferred
= boost::asio::write(s
, buffers
,
954 boost::asio::transfer_at_least(10), error
);
955 BOOST_ASIO_CHECK(bytes_transferred
== 10);
956 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
957 BOOST_ASIO_CHECK(!error
);
960 s
.next_write_length(10);
961 error
= boost::system::error_code();
962 bytes_transferred
= boost::asio::write(s
, buffers
,
963 boost::asio::transfer_at_least(10), error
);
964 BOOST_ASIO_CHECK(bytes_transferred
== 10);
965 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
966 BOOST_ASIO_CHECK(!error
);
969 error
= boost::system::error_code();
970 bytes_transferred
= boost::asio::write(s
, buffers
,
971 boost::asio::transfer_at_least(42), error
);
972 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
973 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
974 BOOST_ASIO_CHECK(!error
);
977 s
.next_write_length(1);
978 error
= boost::system::error_code();
979 bytes_transferred
= boost::asio::write(s
, buffers
,
980 boost::asio::transfer_at_least(42), error
);
981 BOOST_ASIO_CHECK(bytes_transferred
== 42);
982 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
983 BOOST_ASIO_CHECK(!error
);
986 s
.next_write_length(10);
987 error
= boost::system::error_code();
988 bytes_transferred
= boost::asio::write(s
, buffers
,
989 boost::asio::transfer_at_least(42), error
);
990 BOOST_ASIO_CHECK(bytes_transferred
== 50);
991 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 50));
992 BOOST_ASIO_CHECK(!error
);
995 error
= boost::system::error_code();
996 bytes_transferred
= boost::asio::write(s
, buffers
,
997 boost::asio::transfer_exactly(1), error
);
998 BOOST_ASIO_CHECK(bytes_transferred
== 1);
999 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
1000 BOOST_ASIO_CHECK(!error
);
1003 s
.next_write_length(1);
1004 error
= boost::system::error_code();
1005 bytes_transferred
= boost::asio::write(s
, buffers
,
1006 boost::asio::transfer_exactly(1), error
);
1007 BOOST_ASIO_CHECK(bytes_transferred
== 1);
1008 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
1009 BOOST_ASIO_CHECK(!error
);
1012 s
.next_write_length(10);
1013 error
= boost::system::error_code();
1014 bytes_transferred
= boost::asio::write(s
, buffers
,
1015 boost::asio::transfer_exactly(1), error
);
1016 BOOST_ASIO_CHECK(bytes_transferred
== 1);
1017 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
1018 BOOST_ASIO_CHECK(!error
);
1021 error
= boost::system::error_code();
1022 bytes_transferred
= boost::asio::write(s
, buffers
,
1023 boost::asio::transfer_exactly(10), error
);
1024 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1025 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1026 BOOST_ASIO_CHECK(!error
);
1029 s
.next_write_length(1);
1030 error
= boost::system::error_code();
1031 bytes_transferred
= boost::asio::write(s
, buffers
,
1032 boost::asio::transfer_exactly(10), error
);
1033 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1034 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1035 BOOST_ASIO_CHECK(!error
);
1038 s
.next_write_length(10);
1039 error
= boost::system::error_code();
1040 bytes_transferred
= boost::asio::write(s
, buffers
,
1041 boost::asio::transfer_exactly(10), error
);
1042 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1043 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1044 BOOST_ASIO_CHECK(!error
);
1047 error
= boost::system::error_code();
1048 bytes_transferred
= boost::asio::write(s
, buffers
,
1049 boost::asio::transfer_exactly(42), error
);
1050 BOOST_ASIO_CHECK(bytes_transferred
== 42);
1051 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
1052 BOOST_ASIO_CHECK(!error
);
1055 s
.next_write_length(1);
1056 error
= boost::system::error_code();
1057 bytes_transferred
= boost::asio::write(s
, buffers
,
1058 boost::asio::transfer_exactly(42), error
);
1059 BOOST_ASIO_CHECK(bytes_transferred
== 42);
1060 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
1061 BOOST_ASIO_CHECK(!error
);
1064 s
.next_write_length(10);
1065 error
= boost::system::error_code();
1066 bytes_transferred
= boost::asio::write(s
, buffers
,
1067 boost::asio::transfer_exactly(42), error
);
1068 BOOST_ASIO_CHECK(bytes_transferred
== 42);
1069 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
1070 BOOST_ASIO_CHECK(!error
);
1073 bytes_transferred
= boost::asio::write(s
, buffers
,
1074 old_style_transfer_all
, error
);
1075 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1076 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1077 BOOST_ASIO_CHECK(!error
);
1080 s
.next_write_length(1);
1081 error
= boost::system::error_code();
1082 bytes_transferred
= boost::asio::write(s
, buffers
,
1083 old_style_transfer_all
, error
);
1084 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1085 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1086 BOOST_ASIO_CHECK(!error
);
1089 s
.next_write_length(10);
1090 error
= boost::system::error_code();
1091 bytes_transferred
= boost::asio::write(s
, buffers
,
1092 old_style_transfer_all
, error
);
1093 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1094 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1095 BOOST_ASIO_CHECK(!error
);
1098 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
, error
);
1099 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1100 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1101 BOOST_ASIO_CHECK(!error
);
1104 s
.next_write_length(1);
1105 error
= boost::system::error_code();
1106 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
, error
);
1107 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1108 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1109 BOOST_ASIO_CHECK(!error
);
1112 s
.next_write_length(10);
1113 error
= boost::system::error_code();
1114 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
, error
);
1115 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1116 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1117 BOOST_ASIO_CHECK(!error
);
1120 void test_4_arg_mutable_buffers_1_write()
1122 boost::asio::io_service ios
;
1124 boost::asio::mutable_buffers_1 buffers
1125 = boost::asio::buffer(mutable_write_data
, sizeof(mutable_write_data
));
1128 boost::system::error_code error
;
1129 size_t bytes_transferred
= boost::asio::write(s
, buffers
,
1130 boost::asio::transfer_all(), error
);
1131 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
1132 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1133 BOOST_ASIO_CHECK(!error
);
1136 s
.next_write_length(1);
1137 error
= boost::system::error_code();
1138 bytes_transferred
= boost::asio::write(s
, buffers
,
1139 boost::asio::transfer_all(), error
);
1140 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
1141 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1142 BOOST_ASIO_CHECK(!error
);
1145 s
.next_write_length(10);
1146 error
= boost::system::error_code();
1147 bytes_transferred
= boost::asio::write(s
, buffers
,
1148 boost::asio::transfer_all(), error
);
1149 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
1150 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1151 BOOST_ASIO_CHECK(!error
);
1154 error
= boost::system::error_code();
1155 bytes_transferred
= boost::asio::write(s
, buffers
,
1156 boost::asio::transfer_at_least(1), error
);
1157 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
1158 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1159 BOOST_ASIO_CHECK(!error
);
1162 s
.next_write_length(1);
1163 error
= boost::system::error_code();
1164 bytes_transferred
= boost::asio::write(s
, buffers
,
1165 boost::asio::transfer_at_least(1), error
);
1166 BOOST_ASIO_CHECK(bytes_transferred
== 1);
1167 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
1168 BOOST_ASIO_CHECK(!error
);
1171 s
.next_write_length(10);
1172 error
= boost::system::error_code();
1173 bytes_transferred
= boost::asio::write(s
, buffers
,
1174 boost::asio::transfer_at_least(1), error
);
1175 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1176 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1177 BOOST_ASIO_CHECK(!error
);
1180 error
= boost::system::error_code();
1181 bytes_transferred
= boost::asio::write(s
, buffers
,
1182 boost::asio::transfer_at_least(10), error
);
1183 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
1184 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1185 BOOST_ASIO_CHECK(!error
);
1188 s
.next_write_length(1);
1189 error
= boost::system::error_code();
1190 bytes_transferred
= boost::asio::write(s
, buffers
,
1191 boost::asio::transfer_at_least(10), error
);
1192 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1193 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1194 BOOST_ASIO_CHECK(!error
);
1197 s
.next_write_length(10);
1198 error
= boost::system::error_code();
1199 bytes_transferred
= boost::asio::write(s
, buffers
,
1200 boost::asio::transfer_at_least(10), error
);
1201 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1202 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1203 BOOST_ASIO_CHECK(!error
);
1206 error
= boost::system::error_code();
1207 bytes_transferred
= boost::asio::write(s
, buffers
,
1208 boost::asio::transfer_at_least(42), error
);
1209 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
1210 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1211 BOOST_ASIO_CHECK(!error
);
1214 s
.next_write_length(1);
1215 error
= boost::system::error_code();
1216 bytes_transferred
= boost::asio::write(s
, buffers
,
1217 boost::asio::transfer_at_least(42), error
);
1218 BOOST_ASIO_CHECK(bytes_transferred
== 42);
1219 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
1220 BOOST_ASIO_CHECK(!error
);
1223 s
.next_write_length(10);
1224 error
= boost::system::error_code();
1225 bytes_transferred
= boost::asio::write(s
, buffers
,
1226 boost::asio::transfer_at_least(42), error
);
1227 BOOST_ASIO_CHECK(bytes_transferred
== 50);
1228 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 50));
1229 BOOST_ASIO_CHECK(!error
);
1232 error
= boost::system::error_code();
1233 bytes_transferred
= boost::asio::write(s
, buffers
,
1234 boost::asio::transfer_exactly(1), error
);
1235 BOOST_ASIO_CHECK(bytes_transferred
== 1);
1236 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
1237 BOOST_ASIO_CHECK(!error
);
1240 s
.next_write_length(1);
1241 error
= boost::system::error_code();
1242 bytes_transferred
= boost::asio::write(s
, buffers
,
1243 boost::asio::transfer_exactly(1), error
);
1244 BOOST_ASIO_CHECK(bytes_transferred
== 1);
1245 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
1246 BOOST_ASIO_CHECK(!error
);
1249 s
.next_write_length(10);
1250 error
= boost::system::error_code();
1251 bytes_transferred
= boost::asio::write(s
, buffers
,
1252 boost::asio::transfer_exactly(1), error
);
1253 BOOST_ASIO_CHECK(bytes_transferred
== 1);
1254 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
1255 BOOST_ASIO_CHECK(!error
);
1258 error
= boost::system::error_code();
1259 bytes_transferred
= boost::asio::write(s
, buffers
,
1260 boost::asio::transfer_exactly(10), error
);
1261 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1262 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1263 BOOST_ASIO_CHECK(!error
);
1266 s
.next_write_length(1);
1267 error
= boost::system::error_code();
1268 bytes_transferred
= boost::asio::write(s
, buffers
,
1269 boost::asio::transfer_exactly(10), error
);
1270 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1271 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1272 BOOST_ASIO_CHECK(!error
);
1275 s
.next_write_length(10);
1276 error
= boost::system::error_code();
1277 bytes_transferred
= boost::asio::write(s
, buffers
,
1278 boost::asio::transfer_exactly(10), error
);
1279 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1280 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1281 BOOST_ASIO_CHECK(!error
);
1284 error
= boost::system::error_code();
1285 bytes_transferred
= boost::asio::write(s
, buffers
,
1286 boost::asio::transfer_exactly(42), error
);
1287 BOOST_ASIO_CHECK(bytes_transferred
== 42);
1288 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
1289 BOOST_ASIO_CHECK(!error
);
1292 s
.next_write_length(1);
1293 error
= boost::system::error_code();
1294 bytes_transferred
= boost::asio::write(s
, buffers
,
1295 boost::asio::transfer_exactly(42), error
);
1296 BOOST_ASIO_CHECK(bytes_transferred
== 42);
1297 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
1298 BOOST_ASIO_CHECK(!error
);
1301 s
.next_write_length(10);
1302 error
= boost::system::error_code();
1303 bytes_transferred
= boost::asio::write(s
, buffers
,
1304 boost::asio::transfer_exactly(42), error
);
1305 BOOST_ASIO_CHECK(bytes_transferred
== 42);
1306 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
1307 BOOST_ASIO_CHECK(!error
);
1310 bytes_transferred
= boost::asio::write(s
, buffers
,
1311 old_style_transfer_all
, error
);
1312 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
1313 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1314 BOOST_ASIO_CHECK(!error
);
1317 s
.next_write_length(1);
1318 error
= boost::system::error_code();
1319 bytes_transferred
= boost::asio::write(s
, buffers
,
1320 old_style_transfer_all
, error
);
1321 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
1322 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1323 BOOST_ASIO_CHECK(!error
);
1326 s
.next_write_length(10);
1327 error
= boost::system::error_code();
1328 bytes_transferred
= boost::asio::write(s
, buffers
,
1329 old_style_transfer_all
, error
);
1330 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
1331 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1332 BOOST_ASIO_CHECK(!error
);
1335 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
, error
);
1336 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
1337 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1338 BOOST_ASIO_CHECK(!error
);
1341 s
.next_write_length(1);
1342 error
= boost::system::error_code();
1343 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
, error
);
1344 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
1345 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1346 BOOST_ASIO_CHECK(!error
);
1349 s
.next_write_length(10);
1350 error
= boost::system::error_code();
1351 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
, error
);
1352 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(mutable_write_data
));
1353 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1354 BOOST_ASIO_CHECK(!error
);
1357 void test_4_arg_vector_buffers_write()
1359 boost::asio::io_service ios
;
1361 std::vector
<boost::asio::const_buffer
> buffers
;
1362 buffers
.push_back(boost::asio::buffer(write_data
, 32));
1363 buffers
.push_back(boost::asio::buffer(write_data
) + 32);
1366 boost::system::error_code error
;
1367 size_t bytes_transferred
= boost::asio::write(s
, buffers
,
1368 boost::asio::transfer_all(), error
);
1369 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1370 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1371 BOOST_ASIO_CHECK(!error
);
1374 s
.next_write_length(1);
1375 error
= boost::system::error_code();
1376 bytes_transferred
= boost::asio::write(s
, buffers
,
1377 boost::asio::transfer_all(), error
);
1378 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1379 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1380 BOOST_ASIO_CHECK(!error
);
1383 s
.next_write_length(10);
1384 error
= boost::system::error_code();
1385 bytes_transferred
= boost::asio::write(s
, buffers
,
1386 boost::asio::transfer_all(), error
);
1387 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1388 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1389 BOOST_ASIO_CHECK(!error
);
1392 error
= boost::system::error_code();
1393 bytes_transferred
= boost::asio::write(s
, buffers
,
1394 boost::asio::transfer_at_least(1), error
);
1395 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1396 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1397 BOOST_ASIO_CHECK(!error
);
1400 s
.next_write_length(1);
1401 error
= boost::system::error_code();
1402 bytes_transferred
= boost::asio::write(s
, buffers
,
1403 boost::asio::transfer_at_least(1), error
);
1404 BOOST_ASIO_CHECK(bytes_transferred
== 1);
1405 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
1406 BOOST_ASIO_CHECK(!error
);
1409 s
.next_write_length(10);
1410 error
= boost::system::error_code();
1411 bytes_transferred
= boost::asio::write(s
, buffers
,
1412 boost::asio::transfer_at_least(1), error
);
1413 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1414 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1415 BOOST_ASIO_CHECK(!error
);
1418 error
= boost::system::error_code();
1419 bytes_transferred
= boost::asio::write(s
, buffers
,
1420 boost::asio::transfer_at_least(10), error
);
1421 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1422 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1423 BOOST_ASIO_CHECK(!error
);
1426 s
.next_write_length(1);
1427 error
= boost::system::error_code();
1428 bytes_transferred
= boost::asio::write(s
, buffers
,
1429 boost::asio::transfer_at_least(10), error
);
1430 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1431 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1432 BOOST_ASIO_CHECK(!error
);
1435 s
.next_write_length(10);
1436 error
= boost::system::error_code();
1437 bytes_transferred
= boost::asio::write(s
, buffers
,
1438 boost::asio::transfer_at_least(10), error
);
1439 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1440 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1441 BOOST_ASIO_CHECK(!error
);
1444 error
= boost::system::error_code();
1445 bytes_transferred
= boost::asio::write(s
, buffers
,
1446 boost::asio::transfer_at_least(42), error
);
1447 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1448 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1449 BOOST_ASIO_CHECK(!error
);
1452 s
.next_write_length(1);
1453 error
= boost::system::error_code();
1454 bytes_transferred
= boost::asio::write(s
, buffers
,
1455 boost::asio::transfer_at_least(42), error
);
1456 BOOST_ASIO_CHECK(bytes_transferred
== 42);
1457 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
1458 BOOST_ASIO_CHECK(!error
);
1461 s
.next_write_length(10);
1462 error
= boost::system::error_code();
1463 bytes_transferred
= boost::asio::write(s
, buffers
,
1464 boost::asio::transfer_at_least(42), error
);
1465 BOOST_ASIO_CHECK(bytes_transferred
== 50);
1466 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 50));
1467 BOOST_ASIO_CHECK(!error
);
1470 error
= boost::system::error_code();
1471 bytes_transferred
= boost::asio::write(s
, buffers
,
1472 boost::asio::transfer_exactly(1), error
);
1473 BOOST_ASIO_CHECK(bytes_transferred
== 1);
1474 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
1475 BOOST_ASIO_CHECK(!error
);
1478 s
.next_write_length(1);
1479 error
= boost::system::error_code();
1480 bytes_transferred
= boost::asio::write(s
, buffers
,
1481 boost::asio::transfer_exactly(1), error
);
1482 BOOST_ASIO_CHECK(bytes_transferred
== 1);
1483 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
1484 BOOST_ASIO_CHECK(!error
);
1487 s
.next_write_length(10);
1488 error
= boost::system::error_code();
1489 bytes_transferred
= boost::asio::write(s
, buffers
,
1490 boost::asio::transfer_exactly(1), error
);
1491 BOOST_ASIO_CHECK(bytes_transferred
== 1);
1492 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
1493 BOOST_ASIO_CHECK(!error
);
1496 error
= boost::system::error_code();
1497 bytes_transferred
= boost::asio::write(s
, buffers
,
1498 boost::asio::transfer_exactly(10), error
);
1499 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1500 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1501 BOOST_ASIO_CHECK(!error
);
1504 s
.next_write_length(1);
1505 error
= boost::system::error_code();
1506 bytes_transferred
= boost::asio::write(s
, buffers
,
1507 boost::asio::transfer_exactly(10), error
);
1508 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1509 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1510 BOOST_ASIO_CHECK(!error
);
1513 s
.next_write_length(10);
1514 error
= boost::system::error_code();
1515 bytes_transferred
= boost::asio::write(s
, buffers
,
1516 boost::asio::transfer_exactly(10), error
);
1517 BOOST_ASIO_CHECK(bytes_transferred
== 10);
1518 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
1519 BOOST_ASIO_CHECK(!error
);
1522 error
= boost::system::error_code();
1523 bytes_transferred
= boost::asio::write(s
, buffers
,
1524 boost::asio::transfer_exactly(42), error
);
1525 BOOST_ASIO_CHECK(bytes_transferred
== 42);
1526 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
1527 BOOST_ASIO_CHECK(!error
);
1530 s
.next_write_length(1);
1531 error
= boost::system::error_code();
1532 bytes_transferred
= boost::asio::write(s
, buffers
,
1533 boost::asio::transfer_exactly(42), error
);
1534 BOOST_ASIO_CHECK(bytes_transferred
== 42);
1535 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
1536 BOOST_ASIO_CHECK(!error
);
1539 s
.next_write_length(10);
1540 error
= boost::system::error_code();
1541 bytes_transferred
= boost::asio::write(s
, buffers
,
1542 boost::asio::transfer_exactly(42), error
);
1543 BOOST_ASIO_CHECK(bytes_transferred
== 42);
1544 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
1545 BOOST_ASIO_CHECK(!error
);
1548 bytes_transferred
= boost::asio::write(s
, buffers
,
1549 old_style_transfer_all
, error
);
1550 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1551 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1552 BOOST_ASIO_CHECK(!error
);
1555 s
.next_write_length(1);
1556 error
= boost::system::error_code();
1557 bytes_transferred
= boost::asio::write(s
, buffers
,
1558 old_style_transfer_all
, error
);
1559 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1560 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1561 BOOST_ASIO_CHECK(!error
);
1564 s
.next_write_length(10);
1565 error
= boost::system::error_code();
1566 bytes_transferred
= boost::asio::write(s
, buffers
,
1567 old_style_transfer_all
, error
);
1568 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1569 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1570 BOOST_ASIO_CHECK(!error
);
1573 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
, error
);
1574 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1575 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1576 BOOST_ASIO_CHECK(!error
);
1579 s
.next_write_length(1);
1580 error
= boost::system::error_code();
1581 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
, error
);
1582 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1583 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1584 BOOST_ASIO_CHECK(!error
);
1587 s
.next_write_length(10);
1588 error
= boost::system::error_code();
1589 bytes_transferred
= boost::asio::write(s
, buffers
, short_transfer
, error
);
1590 BOOST_ASIO_CHECK(bytes_transferred
== sizeof(write_data
));
1591 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1592 BOOST_ASIO_CHECK(!error
);
1595 void async_write_handler(const boost::system::error_code
& e
,
1596 size_t bytes_transferred
, size_t expected_bytes_transferred
, bool* called
)
1599 BOOST_ASIO_CHECK(!e
);
1600 BOOST_ASIO_CHECK(bytes_transferred
== expected_bytes_transferred
);
1603 void test_3_arg_const_buffers_1_async_write()
1605 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
1606 namespace bindns
= boost
;
1607 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
1608 namespace bindns
= std
;
1609 using std::placeholders::_1
;
1610 using std::placeholders::_2
;
1611 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
1613 boost::asio::io_service ios
;
1615 boost::asio::const_buffers_1 buffers
1616 = boost::asio::buffer(write_data
, sizeof(write_data
));
1619 bool called
= false;
1620 boost::asio::async_write(s
, buffers
,
1621 bindns::bind(async_write_handler
,
1622 _1
, _2
, sizeof(write_data
), &called
));
1625 BOOST_ASIO_CHECK(called
);
1626 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1629 s
.next_write_length(1);
1631 boost::asio::async_write(s
, buffers
,
1632 bindns::bind(async_write_handler
,
1633 _1
, _2
, sizeof(write_data
), &called
));
1636 BOOST_ASIO_CHECK(called
);
1637 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1640 s
.next_write_length(10);
1642 boost::asio::async_write(s
, buffers
,
1643 bindns::bind(async_write_handler
,
1644 _1
, _2
, sizeof(write_data
), &called
));
1647 BOOST_ASIO_CHECK(called
);
1648 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1651 int i
= boost::asio::async_write(s
, buffers
, archetypes::lazy_handler());
1652 BOOST_ASIO_CHECK(i
== 42);
1655 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1658 void test_3_arg_mutable_buffers_1_async_write()
1660 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
1661 namespace bindns
= boost
;
1662 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
1663 namespace bindns
= std
;
1664 using std::placeholders::_1
;
1665 using std::placeholders::_2
;
1666 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
1668 boost::asio::io_service ios
;
1670 boost::asio::mutable_buffers_1 buffers
1671 = boost::asio::buffer(mutable_write_data
, sizeof(mutable_write_data
));
1674 bool called
= false;
1675 boost::asio::async_write(s
, buffers
,
1676 bindns::bind(async_write_handler
,
1677 _1
, _2
, sizeof(mutable_write_data
), &called
));
1680 BOOST_ASIO_CHECK(called
);
1681 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1684 s
.next_write_length(1);
1686 boost::asio::async_write(s
, buffers
,
1687 bindns::bind(async_write_handler
,
1688 _1
, _2
, sizeof(mutable_write_data
), &called
));
1691 BOOST_ASIO_CHECK(called
);
1692 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1695 s
.next_write_length(10);
1697 boost::asio::async_write(s
, buffers
,
1698 bindns::bind(async_write_handler
,
1699 _1
, _2
, sizeof(mutable_write_data
), &called
));
1702 BOOST_ASIO_CHECK(called
);
1703 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1706 int i
= boost::asio::async_write(s
, buffers
, archetypes::lazy_handler());
1707 BOOST_ASIO_CHECK(i
== 42);
1710 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
1713 void test_3_arg_boost_array_buffers_async_write()
1715 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
1716 namespace bindns
= boost
;
1717 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
1718 namespace bindns
= std
;
1719 using std::placeholders::_1
;
1720 using std::placeholders::_2
;
1721 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
1723 #if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
1724 boost::asio::io_service ios
;
1726 boost::array
<boost::asio::const_buffer
, 2> buffers
= { {
1727 boost::asio::buffer(write_data
, 32),
1728 boost::asio::buffer(write_data
) + 32 } };
1731 bool called
= false;
1732 boost::asio::async_write(s
, buffers
,
1733 bindns::bind(async_write_handler
,
1734 _1
, _2
, sizeof(write_data
), &called
));
1737 BOOST_ASIO_CHECK(called
);
1738 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1741 s
.next_write_length(1);
1743 boost::asio::async_write(s
, buffers
,
1744 bindns::bind(async_write_handler
,
1745 _1
, _2
, sizeof(write_data
), &called
));
1748 BOOST_ASIO_CHECK(called
);
1749 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1752 s
.next_write_length(10);
1754 boost::asio::async_write(s
, buffers
,
1755 bindns::bind(async_write_handler
,
1756 _1
, _2
, sizeof(write_data
), &called
));
1759 BOOST_ASIO_CHECK(called
);
1760 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1763 int i
= boost::asio::async_write(s
, buffers
, archetypes::lazy_handler());
1764 BOOST_ASIO_CHECK(i
== 42);
1767 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1768 #endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
1771 void test_3_arg_std_array_buffers_async_write()
1773 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
1774 namespace bindns
= boost
;
1775 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
1776 namespace bindns
= std
;
1777 using std::placeholders::_1
;
1778 using std::placeholders::_2
;
1779 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
1781 #if defined(BOOST_ASIO_HAS_STD_ARRAY)
1782 boost::asio::io_service ios
;
1784 std::array
<boost::asio::const_buffer
, 2> buffers
= { {
1785 boost::asio::buffer(write_data
, 32),
1786 boost::asio::buffer(write_data
) + 32 } };
1789 bool called
= false;
1790 boost::asio::async_write(s
, buffers
,
1791 bindns::bind(async_write_handler
,
1792 _1
, _2
, sizeof(write_data
), &called
));
1795 BOOST_ASIO_CHECK(called
);
1796 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1799 s
.next_write_length(1);
1801 boost::asio::async_write(s
, buffers
,
1802 bindns::bind(async_write_handler
,
1803 _1
, _2
, sizeof(write_data
), &called
));
1806 BOOST_ASIO_CHECK(called
);
1807 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1810 s
.next_write_length(10);
1812 boost::asio::async_write(s
, buffers
,
1813 bindns::bind(async_write_handler
,
1814 _1
, _2
, sizeof(write_data
), &called
));
1817 BOOST_ASIO_CHECK(called
);
1818 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1821 int i
= boost::asio::async_write(s
, buffers
, archetypes::lazy_handler());
1822 BOOST_ASIO_CHECK(i
== 42);
1825 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1826 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
1829 void test_3_arg_vector_buffers_async_write()
1831 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
1832 namespace bindns
= boost
;
1833 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
1834 namespace bindns
= std
;
1835 using std::placeholders::_1
;
1836 using std::placeholders::_2
;
1837 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
1839 boost::asio::io_service ios
;
1841 std::vector
<boost::asio::const_buffer
> buffers
;
1842 buffers
.push_back(boost::asio::buffer(write_data
, 32));
1843 buffers
.push_back(boost::asio::buffer(write_data
) + 32);
1846 bool called
= false;
1847 boost::asio::async_write(s
, buffers
,
1848 bindns::bind(async_write_handler
,
1849 _1
, _2
, sizeof(write_data
), &called
));
1852 BOOST_ASIO_CHECK(called
);
1853 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1856 s
.next_write_length(1);
1858 boost::asio::async_write(s
, buffers
,
1859 bindns::bind(async_write_handler
,
1860 _1
, _2
, sizeof(write_data
), &called
));
1863 BOOST_ASIO_CHECK(called
);
1864 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1867 s
.next_write_length(10);
1869 boost::asio::async_write(s
, buffers
,
1870 bindns::bind(async_write_handler
,
1871 _1
, _2
, sizeof(write_data
), &called
));
1874 BOOST_ASIO_CHECK(called
);
1875 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1878 int i
= boost::asio::async_write(s
, buffers
, archetypes::lazy_handler());
1879 BOOST_ASIO_CHECK(i
== 42);
1882 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1885 void test_3_arg_streambuf_async_write()
1887 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
1888 namespace bindns
= boost
;
1889 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
1890 namespace bindns
= std
;
1891 using std::placeholders::_1
;
1892 using std::placeholders::_2
;
1893 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
1895 boost::asio::io_service ios
;
1897 boost::asio::streambuf sb
;
1898 boost::asio::const_buffers_1 buffers
1899 = boost::asio::buffer(write_data
, sizeof(write_data
));
1902 sb
.consume(sb
.size());
1903 sb
.sputn(write_data
, sizeof(write_data
));
1904 bool called
= false;
1905 boost::asio::async_write(s
, sb
,
1906 bindns::bind(async_write_handler
,
1907 _1
, _2
, sizeof(write_data
), &called
));
1910 BOOST_ASIO_CHECK(called
);
1911 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1914 sb
.consume(sb
.size());
1915 sb
.sputn(write_data
, sizeof(write_data
));
1916 s
.next_write_length(1);
1918 boost::asio::async_write(s
, sb
,
1919 bindns::bind(async_write_handler
,
1920 _1
, _2
, sizeof(write_data
), &called
));
1923 BOOST_ASIO_CHECK(called
);
1924 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1927 sb
.consume(sb
.size());
1928 sb
.sputn(write_data
, sizeof(write_data
));
1929 s
.next_write_length(10);
1931 boost::asio::async_write(s
, sb
,
1932 bindns::bind(async_write_handler
,
1933 _1
, _2
, sizeof(write_data
), &called
));
1936 BOOST_ASIO_CHECK(called
);
1937 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1940 sb
.consume(sb
.size());
1941 sb
.sputn(write_data
, sizeof(write_data
));
1942 int i
= boost::asio::async_write(s
, sb
, archetypes::lazy_handler());
1943 BOOST_ASIO_CHECK(i
== 42);
1946 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1949 void test_4_arg_const_buffers_1_async_write()
1951 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
1952 namespace bindns
= boost
;
1953 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
1954 namespace bindns
= std
;
1955 using std::placeholders::_1
;
1956 using std::placeholders::_2
;
1957 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
1959 boost::asio::io_service ios
;
1961 boost::asio::const_buffers_1 buffers
1962 = boost::asio::buffer(write_data
, sizeof(write_data
));
1965 bool called
= false;
1966 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
1967 bindns::bind(async_write_handler
,
1968 _1
, _2
, sizeof(write_data
), &called
));
1971 BOOST_ASIO_CHECK(called
);
1972 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1975 s
.next_write_length(1);
1977 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
1978 bindns::bind(async_write_handler
,
1979 _1
, _2
, sizeof(write_data
), &called
));
1982 BOOST_ASIO_CHECK(called
);
1983 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1986 s
.next_write_length(10);
1988 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
1989 bindns::bind(async_write_handler
,
1990 _1
, _2
, sizeof(write_data
), &called
));
1993 BOOST_ASIO_CHECK(called
);
1994 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
1998 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
1999 bindns::bind(async_write_handler
,
2000 _1
, _2
, sizeof(write_data
), &called
));
2003 BOOST_ASIO_CHECK(called
);
2004 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2007 s
.next_write_length(1);
2009 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
2010 bindns::bind(async_write_handler
,
2011 _1
, _2
, 1, &called
));
2014 BOOST_ASIO_CHECK(called
);
2015 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
2018 s
.next_write_length(10);
2020 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
2021 bindns::bind(async_write_handler
,
2022 _1
, _2
, 10, &called
));
2025 BOOST_ASIO_CHECK(called
);
2026 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2030 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
2031 bindns::bind(async_write_handler
,
2032 _1
, _2
, sizeof(write_data
), &called
));
2035 BOOST_ASIO_CHECK(called
);
2036 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2039 s
.next_write_length(1);
2041 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
2042 bindns::bind(async_write_handler
,
2043 _1
, _2
, 10, &called
));
2046 BOOST_ASIO_CHECK(called
);
2047 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2050 s
.next_write_length(10);
2052 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
2053 bindns::bind(async_write_handler
,
2054 _1
, _2
, 10, &called
));
2057 BOOST_ASIO_CHECK(called
);
2058 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2062 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
2063 bindns::bind(async_write_handler
,
2064 _1
, _2
, sizeof(write_data
), &called
));
2067 BOOST_ASIO_CHECK(called
);
2068 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2071 s
.next_write_length(1);
2073 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
2074 bindns::bind(async_write_handler
,
2075 _1
, _2
, 42, &called
));
2078 BOOST_ASIO_CHECK(called
);
2079 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
2082 s
.next_write_length(10);
2084 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
2085 bindns::bind(async_write_handler
,
2086 _1
, _2
, 50, &called
));
2089 BOOST_ASIO_CHECK(called
);
2090 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 50));
2094 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
2095 bindns::bind(async_write_handler
,
2096 _1
, _2
, 1, &called
));
2099 BOOST_ASIO_CHECK(called
);
2100 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
2103 s
.next_write_length(1);
2105 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
2106 bindns::bind(async_write_handler
,
2107 _1
, _2
, 1, &called
));
2110 BOOST_ASIO_CHECK(called
);
2111 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
2114 s
.next_write_length(10);
2116 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
2117 bindns::bind(async_write_handler
,
2118 _1
, _2
, 1, &called
));
2121 BOOST_ASIO_CHECK(called
);
2122 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
2126 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
2127 bindns::bind(async_write_handler
,
2128 _1
, _2
, 10, &called
));
2131 BOOST_ASIO_CHECK(called
);
2132 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2135 s
.next_write_length(1);
2137 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
2138 bindns::bind(async_write_handler
,
2139 _1
, _2
, 10, &called
));
2142 BOOST_ASIO_CHECK(called
);
2143 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2146 s
.next_write_length(10);
2148 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
2149 bindns::bind(async_write_handler
,
2150 _1
, _2
, 10, &called
));
2153 BOOST_ASIO_CHECK(called
);
2154 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2158 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
2159 bindns::bind(async_write_handler
,
2160 _1
, _2
, 42, &called
));
2163 BOOST_ASIO_CHECK(called
);
2164 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
2167 s
.next_write_length(1);
2169 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
2170 bindns::bind(async_write_handler
,
2171 _1
, _2
, 42, &called
));
2174 BOOST_ASIO_CHECK(called
);
2175 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
2178 s
.next_write_length(10);
2180 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
2181 bindns::bind(async_write_handler
,
2182 _1
, _2
, 42, &called
));
2185 BOOST_ASIO_CHECK(called
);
2186 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
2190 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
2191 bindns::bind(async_write_handler
,
2192 _1
, _2
, sizeof(write_data
), &called
));
2195 BOOST_ASIO_CHECK(called
);
2196 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2199 s
.next_write_length(1);
2201 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
2202 bindns::bind(async_write_handler
,
2203 _1
, _2
, sizeof(write_data
), &called
));
2206 BOOST_ASIO_CHECK(called
);
2207 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2210 s
.next_write_length(10);
2212 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
2213 bindns::bind(async_write_handler
,
2214 _1
, _2
, sizeof(write_data
), &called
));
2217 BOOST_ASIO_CHECK(called
);
2218 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2222 boost::asio::async_write(s
, buffers
, short_transfer
,
2223 bindns::bind(async_write_handler
,
2224 _1
, _2
, sizeof(write_data
), &called
));
2227 BOOST_ASIO_CHECK(called
);
2228 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2231 s
.next_write_length(1);
2233 boost::asio::async_write(s
, buffers
, short_transfer
,
2234 bindns::bind(async_write_handler
,
2235 _1
, _2
, sizeof(write_data
), &called
));
2238 BOOST_ASIO_CHECK(called
);
2239 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2242 s
.next_write_length(10);
2244 boost::asio::async_write(s
, buffers
, short_transfer
,
2245 bindns::bind(async_write_handler
,
2246 _1
, _2
, sizeof(write_data
), &called
));
2249 BOOST_ASIO_CHECK(called
);
2250 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2253 int i
= boost::asio::async_write(s
, buffers
, short_transfer
,
2254 archetypes::lazy_handler());
2255 BOOST_ASIO_CHECK(i
== 42);
2258 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2261 void test_4_arg_mutable_buffers_1_async_write()
2263 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
2264 namespace bindns
= boost
;
2265 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
2266 namespace bindns
= std
;
2267 using std::placeholders::_1
;
2268 using std::placeholders::_2
;
2269 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
2271 boost::asio::io_service ios
;
2273 boost::asio::mutable_buffers_1 buffers
2274 = boost::asio::buffer(mutable_write_data
, sizeof(mutable_write_data
));
2277 bool called
= false;
2278 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
2279 bindns::bind(async_write_handler
,
2280 _1
, _2
, sizeof(mutable_write_data
), &called
));
2283 BOOST_ASIO_CHECK(called
);
2284 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
2287 s
.next_write_length(1);
2289 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
2290 bindns::bind(async_write_handler
,
2291 _1
, _2
, sizeof(mutable_write_data
), &called
));
2294 BOOST_ASIO_CHECK(called
);
2295 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
2298 s
.next_write_length(10);
2300 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
2301 bindns::bind(async_write_handler
,
2302 _1
, _2
, sizeof(mutable_write_data
), &called
));
2305 BOOST_ASIO_CHECK(called
);
2306 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
2310 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
2311 bindns::bind(async_write_handler
,
2312 _1
, _2
, sizeof(mutable_write_data
), &called
));
2315 BOOST_ASIO_CHECK(called
);
2316 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
2319 s
.next_write_length(1);
2321 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
2322 bindns::bind(async_write_handler
,
2323 _1
, _2
, 1, &called
));
2326 BOOST_ASIO_CHECK(called
);
2327 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
2330 s
.next_write_length(10);
2332 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
2333 bindns::bind(async_write_handler
,
2334 _1
, _2
, 10, &called
));
2337 BOOST_ASIO_CHECK(called
);
2338 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2342 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
2343 bindns::bind(async_write_handler
,
2344 _1
, _2
, sizeof(mutable_write_data
), &called
));
2347 BOOST_ASIO_CHECK(called
);
2348 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
2351 s
.next_write_length(1);
2353 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
2354 bindns::bind(async_write_handler
,
2355 _1
, _2
, 10, &called
));
2358 BOOST_ASIO_CHECK(called
);
2359 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2362 s
.next_write_length(10);
2364 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
2365 bindns::bind(async_write_handler
,
2366 _1
, _2
, 10, &called
));
2369 BOOST_ASIO_CHECK(called
);
2370 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2374 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
2375 bindns::bind(async_write_handler
,
2376 _1
, _2
, sizeof(mutable_write_data
), &called
));
2379 BOOST_ASIO_CHECK(called
);
2380 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
2383 s
.next_write_length(1);
2385 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
2386 bindns::bind(async_write_handler
,
2387 _1
, _2
, 42, &called
));
2390 BOOST_ASIO_CHECK(called
);
2391 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
2394 s
.next_write_length(10);
2396 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
2397 bindns::bind(async_write_handler
,
2398 _1
, _2
, 50, &called
));
2401 BOOST_ASIO_CHECK(called
);
2402 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 50));
2406 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
2407 bindns::bind(async_write_handler
,
2408 _1
, _2
, 1, &called
));
2411 BOOST_ASIO_CHECK(called
);
2412 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
2415 s
.next_write_length(1);
2417 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
2418 bindns::bind(async_write_handler
,
2419 _1
, _2
, 1, &called
));
2422 BOOST_ASIO_CHECK(called
);
2423 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
2426 s
.next_write_length(10);
2428 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
2429 bindns::bind(async_write_handler
,
2430 _1
, _2
, 1, &called
));
2433 BOOST_ASIO_CHECK(called
);
2434 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
2438 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
2439 bindns::bind(async_write_handler
,
2440 _1
, _2
, 10, &called
));
2443 BOOST_ASIO_CHECK(called
);
2444 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2447 s
.next_write_length(1);
2449 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
2450 bindns::bind(async_write_handler
,
2451 _1
, _2
, 10, &called
));
2454 BOOST_ASIO_CHECK(called
);
2455 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2458 s
.next_write_length(10);
2460 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
2461 bindns::bind(async_write_handler
,
2462 _1
, _2
, 10, &called
));
2465 BOOST_ASIO_CHECK(called
);
2466 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2470 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
2471 bindns::bind(async_write_handler
,
2472 _1
, _2
, 42, &called
));
2475 BOOST_ASIO_CHECK(called
);
2476 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
2479 s
.next_write_length(1);
2481 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
2482 bindns::bind(async_write_handler
,
2483 _1
, _2
, 42, &called
));
2486 BOOST_ASIO_CHECK(called
);
2487 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
2490 s
.next_write_length(10);
2492 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
2493 bindns::bind(async_write_handler
,
2494 _1
, _2
, 42, &called
));
2497 BOOST_ASIO_CHECK(called
);
2498 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
2502 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
2503 bindns::bind(async_write_handler
,
2504 _1
, _2
, sizeof(mutable_write_data
), &called
));
2507 BOOST_ASIO_CHECK(called
);
2508 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
2511 s
.next_write_length(1);
2513 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
2514 bindns::bind(async_write_handler
,
2515 _1
, _2
, sizeof(mutable_write_data
), &called
));
2518 BOOST_ASIO_CHECK(called
);
2519 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
2522 s
.next_write_length(10);
2524 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
2525 bindns::bind(async_write_handler
,
2526 _1
, _2
, sizeof(mutable_write_data
), &called
));
2529 BOOST_ASIO_CHECK(called
);
2530 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
2534 boost::asio::async_write(s
, buffers
, short_transfer
,
2535 bindns::bind(async_write_handler
,
2536 _1
, _2
, sizeof(mutable_write_data
), &called
));
2539 BOOST_ASIO_CHECK(called
);
2540 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
2543 s
.next_write_length(1);
2545 boost::asio::async_write(s
, buffers
, short_transfer
,
2546 bindns::bind(async_write_handler
,
2547 _1
, _2
, sizeof(mutable_write_data
), &called
));
2550 BOOST_ASIO_CHECK(called
);
2551 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
2554 s
.next_write_length(10);
2556 boost::asio::async_write(s
, buffers
, short_transfer
,
2557 bindns::bind(async_write_handler
,
2558 _1
, _2
, sizeof(mutable_write_data
), &called
));
2561 BOOST_ASIO_CHECK(called
);
2562 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(mutable_write_data
)));
2565 int i
= boost::asio::async_write(s
, buffers
, short_transfer
,
2566 archetypes::lazy_handler());
2567 BOOST_ASIO_CHECK(i
== 42);
2570 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2573 void test_4_arg_boost_array_buffers_async_write()
2575 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
2576 namespace bindns
= boost
;
2577 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
2578 namespace bindns
= std
;
2579 using std::placeholders::_1
;
2580 using std::placeholders::_2
;
2581 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
2583 #if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
2584 boost::asio::io_service ios
;
2586 boost::array
<boost::asio::const_buffer
, 2> buffers
= { {
2587 boost::asio::buffer(write_data
, 32),
2588 boost::asio::buffer(write_data
) + 32 } };
2591 bool called
= false;
2592 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
2593 bindns::bind(async_write_handler
,
2594 _1
, _2
, sizeof(write_data
), &called
));
2597 BOOST_ASIO_CHECK(called
);
2598 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2601 s
.next_write_length(1);
2603 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
2604 bindns::bind(async_write_handler
,
2605 _1
, _2
, sizeof(write_data
), &called
));
2608 BOOST_ASIO_CHECK(called
);
2609 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2612 s
.next_write_length(10);
2614 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
2615 bindns::bind(async_write_handler
,
2616 _1
, _2
, sizeof(write_data
), &called
));
2619 BOOST_ASIO_CHECK(called
);
2620 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2624 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
2625 bindns::bind(async_write_handler
,
2626 _1
, _2
, sizeof(write_data
), &called
));
2629 BOOST_ASIO_CHECK(called
);
2630 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2633 s
.next_write_length(1);
2635 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
2636 bindns::bind(async_write_handler
,
2637 _1
, _2
, 1, &called
));
2640 BOOST_ASIO_CHECK(called
);
2641 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
2644 s
.next_write_length(10);
2646 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
2647 bindns::bind(async_write_handler
,
2648 _1
, _2
, 10, &called
));
2651 BOOST_ASIO_CHECK(called
);
2652 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2656 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
2657 bindns::bind(async_write_handler
,
2658 _1
, _2
, sizeof(write_data
), &called
));
2661 BOOST_ASIO_CHECK(called
);
2662 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2665 s
.next_write_length(1);
2667 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
2668 bindns::bind(async_write_handler
,
2669 _1
, _2
, 10, &called
));
2672 BOOST_ASIO_CHECK(called
);
2673 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2676 s
.next_write_length(10);
2678 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
2679 bindns::bind(async_write_handler
,
2680 _1
, _2
, 10, &called
));
2683 BOOST_ASIO_CHECK(called
);
2684 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2688 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
2689 bindns::bind(async_write_handler
,
2690 _1
, _2
, sizeof(write_data
), &called
));
2693 BOOST_ASIO_CHECK(called
);
2694 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2697 s
.next_write_length(1);
2699 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
2700 bindns::bind(async_write_handler
,
2701 _1
, _2
, 42, &called
));
2704 BOOST_ASIO_CHECK(called
);
2705 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
2708 s
.next_write_length(10);
2710 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
2711 bindns::bind(async_write_handler
,
2712 _1
, _2
, 50, &called
));
2715 BOOST_ASIO_CHECK(called
);
2716 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 50));
2720 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
2721 bindns::bind(async_write_handler
,
2722 _1
, _2
, 1, &called
));
2725 BOOST_ASIO_CHECK(called
);
2726 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
2729 s
.next_write_length(1);
2731 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
2732 bindns::bind(async_write_handler
,
2733 _1
, _2
, 1, &called
));
2736 BOOST_ASIO_CHECK(called
);
2737 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
2740 s
.next_write_length(10);
2742 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
2743 bindns::bind(async_write_handler
,
2744 _1
, _2
, 1, &called
));
2747 BOOST_ASIO_CHECK(called
);
2748 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
2752 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
2753 bindns::bind(async_write_handler
,
2754 _1
, _2
, 10, &called
));
2757 BOOST_ASIO_CHECK(called
);
2758 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2761 s
.next_write_length(1);
2763 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
2764 bindns::bind(async_write_handler
,
2765 _1
, _2
, 10, &called
));
2768 BOOST_ASIO_CHECK(called
);
2769 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2772 s
.next_write_length(10);
2774 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
2775 bindns::bind(async_write_handler
,
2776 _1
, _2
, 10, &called
));
2779 BOOST_ASIO_CHECK(called
);
2780 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2784 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
2785 bindns::bind(async_write_handler
,
2786 _1
, _2
, 42, &called
));
2789 BOOST_ASIO_CHECK(called
);
2790 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
2793 s
.next_write_length(1);
2795 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
2796 bindns::bind(async_write_handler
,
2797 _1
, _2
, 42, &called
));
2800 BOOST_ASIO_CHECK(called
);
2801 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
2804 s
.next_write_length(10);
2806 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
2807 bindns::bind(async_write_handler
,
2808 _1
, _2
, 42, &called
));
2811 BOOST_ASIO_CHECK(called
);
2812 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
2816 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
2817 bindns::bind(async_write_handler
,
2818 _1
, _2
, sizeof(write_data
), &called
));
2821 BOOST_ASIO_CHECK(called
);
2822 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2825 s
.next_write_length(1);
2827 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
2828 bindns::bind(async_write_handler
,
2829 _1
, _2
, sizeof(write_data
), &called
));
2832 BOOST_ASIO_CHECK(called
);
2833 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2836 s
.next_write_length(10);
2838 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
2839 bindns::bind(async_write_handler
,
2840 _1
, _2
, sizeof(write_data
), &called
));
2843 BOOST_ASIO_CHECK(called
);
2844 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2848 boost::asio::async_write(s
, buffers
, short_transfer
,
2849 bindns::bind(async_write_handler
,
2850 _1
, _2
, sizeof(write_data
), &called
));
2853 BOOST_ASIO_CHECK(called
);
2854 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2857 s
.next_write_length(1);
2859 boost::asio::async_write(s
, buffers
, short_transfer
,
2860 bindns::bind(async_write_handler
,
2861 _1
, _2
, sizeof(write_data
), &called
));
2864 BOOST_ASIO_CHECK(called
);
2865 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2868 s
.next_write_length(10);
2870 boost::asio::async_write(s
, buffers
, short_transfer
,
2871 bindns::bind(async_write_handler
,
2872 _1
, _2
, sizeof(write_data
), &called
));
2875 BOOST_ASIO_CHECK(called
);
2876 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2879 int i
= boost::asio::async_write(s
, buffers
, short_transfer
,
2880 archetypes::lazy_handler());
2881 BOOST_ASIO_CHECK(i
== 42);
2884 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2885 #endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
2888 void test_4_arg_std_array_buffers_async_write()
2890 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
2891 namespace bindns
= boost
;
2892 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
2893 namespace bindns
= std
;
2894 using std::placeholders::_1
;
2895 using std::placeholders::_2
;
2896 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
2898 #if defined(BOOST_ASIO_HAS_STD_ARRAY)
2899 boost::asio::io_service ios
;
2901 std::array
<boost::asio::const_buffer
, 2> buffers
= { {
2902 boost::asio::buffer(write_data
, 32),
2903 boost::asio::buffer(write_data
) + 32 } };
2906 bool called
= false;
2907 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
2908 bindns::bind(async_write_handler
,
2909 _1
, _2
, sizeof(write_data
), &called
));
2912 BOOST_ASIO_CHECK(called
);
2913 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2916 s
.next_write_length(1);
2918 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
2919 bindns::bind(async_write_handler
,
2920 _1
, _2
, sizeof(write_data
), &called
));
2923 BOOST_ASIO_CHECK(called
);
2924 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2927 s
.next_write_length(10);
2929 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
2930 bindns::bind(async_write_handler
,
2931 _1
, _2
, sizeof(write_data
), &called
));
2934 BOOST_ASIO_CHECK(called
);
2935 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2939 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
2940 bindns::bind(async_write_handler
,
2941 _1
, _2
, sizeof(write_data
), &called
));
2944 BOOST_ASIO_CHECK(called
);
2945 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2948 s
.next_write_length(1);
2950 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
2951 bindns::bind(async_write_handler
,
2952 _1
, _2
, 1, &called
));
2955 BOOST_ASIO_CHECK(called
);
2956 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
2959 s
.next_write_length(10);
2961 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
2962 bindns::bind(async_write_handler
,
2963 _1
, _2
, 10, &called
));
2966 BOOST_ASIO_CHECK(called
);
2967 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2971 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
2972 bindns::bind(async_write_handler
,
2973 _1
, _2
, sizeof(write_data
), &called
));
2976 BOOST_ASIO_CHECK(called
);
2977 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
2980 s
.next_write_length(1);
2982 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
2983 bindns::bind(async_write_handler
,
2984 _1
, _2
, 10, &called
));
2987 BOOST_ASIO_CHECK(called
);
2988 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
2991 s
.next_write_length(10);
2993 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
2994 bindns::bind(async_write_handler
,
2995 _1
, _2
, 10, &called
));
2998 BOOST_ASIO_CHECK(called
);
2999 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3003 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
3004 bindns::bind(async_write_handler
,
3005 _1
, _2
, sizeof(write_data
), &called
));
3008 BOOST_ASIO_CHECK(called
);
3009 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3012 s
.next_write_length(1);
3014 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
3015 bindns::bind(async_write_handler
,
3016 _1
, _2
, 42, &called
));
3019 BOOST_ASIO_CHECK(called
);
3020 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
3023 s
.next_write_length(10);
3025 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
3026 bindns::bind(async_write_handler
,
3027 _1
, _2
, 50, &called
));
3030 BOOST_ASIO_CHECK(called
);
3031 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 50));
3035 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
3036 bindns::bind(async_write_handler
,
3037 _1
, _2
, 1, &called
));
3040 BOOST_ASIO_CHECK(called
);
3041 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
3044 s
.next_write_length(1);
3046 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
3047 bindns::bind(async_write_handler
,
3048 _1
, _2
, 1, &called
));
3051 BOOST_ASIO_CHECK(called
);
3052 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
3055 s
.next_write_length(10);
3057 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
3058 bindns::bind(async_write_handler
,
3059 _1
, _2
, 1, &called
));
3062 BOOST_ASIO_CHECK(called
);
3063 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
3067 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
3068 bindns::bind(async_write_handler
,
3069 _1
, _2
, 10, &called
));
3072 BOOST_ASIO_CHECK(called
);
3073 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3076 s
.next_write_length(1);
3078 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
3079 bindns::bind(async_write_handler
,
3080 _1
, _2
, 10, &called
));
3083 BOOST_ASIO_CHECK(called
);
3084 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3087 s
.next_write_length(10);
3089 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
3090 bindns::bind(async_write_handler
,
3091 _1
, _2
, 10, &called
));
3094 BOOST_ASIO_CHECK(called
);
3095 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3099 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
3100 bindns::bind(async_write_handler
,
3101 _1
, _2
, 42, &called
));
3104 BOOST_ASIO_CHECK(called
);
3105 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
3108 s
.next_write_length(1);
3110 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
3111 bindns::bind(async_write_handler
,
3112 _1
, _2
, 42, &called
));
3115 BOOST_ASIO_CHECK(called
);
3116 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
3119 s
.next_write_length(10);
3121 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
3122 bindns::bind(async_write_handler
,
3123 _1
, _2
, 42, &called
));
3126 BOOST_ASIO_CHECK(called
);
3127 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
3131 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
3132 bindns::bind(async_write_handler
,
3133 _1
, _2
, sizeof(write_data
), &called
));
3136 BOOST_ASIO_CHECK(called
);
3137 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3140 s
.next_write_length(1);
3142 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
3143 bindns::bind(async_write_handler
,
3144 _1
, _2
, sizeof(write_data
), &called
));
3147 BOOST_ASIO_CHECK(called
);
3148 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3151 s
.next_write_length(10);
3153 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
3154 bindns::bind(async_write_handler
,
3155 _1
, _2
, sizeof(write_data
), &called
));
3158 BOOST_ASIO_CHECK(called
);
3159 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3163 boost::asio::async_write(s
, buffers
, short_transfer
,
3164 bindns::bind(async_write_handler
,
3165 _1
, _2
, sizeof(write_data
), &called
));
3168 BOOST_ASIO_CHECK(called
);
3169 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3172 s
.next_write_length(1);
3174 boost::asio::async_write(s
, buffers
, short_transfer
,
3175 bindns::bind(async_write_handler
,
3176 _1
, _2
, sizeof(write_data
), &called
));
3179 BOOST_ASIO_CHECK(called
);
3180 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3183 s
.next_write_length(10);
3185 boost::asio::async_write(s
, buffers
, short_transfer
,
3186 bindns::bind(async_write_handler
,
3187 _1
, _2
, sizeof(write_data
), &called
));
3190 BOOST_ASIO_CHECK(called
);
3191 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3194 int i
= boost::asio::async_write(s
, buffers
, short_transfer
,
3195 archetypes::lazy_handler());
3196 BOOST_ASIO_CHECK(i
== 42);
3199 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3200 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
3203 void test_4_arg_vector_buffers_async_write()
3205 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
3206 namespace bindns
= boost
;
3207 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
3208 namespace bindns
= std
;
3209 using std::placeholders::_1
;
3210 using std::placeholders::_2
;
3211 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
3213 boost::asio::io_service ios
;
3215 std::vector
<boost::asio::const_buffer
> buffers
;
3216 buffers
.push_back(boost::asio::buffer(write_data
, 32));
3217 buffers
.push_back(boost::asio::buffer(write_data
) + 32);
3220 bool called
= false;
3221 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
3222 bindns::bind(async_write_handler
,
3223 _1
, _2
, sizeof(write_data
), &called
));
3226 BOOST_ASIO_CHECK(called
);
3227 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3230 s
.next_write_length(1);
3232 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
3233 bindns::bind(async_write_handler
,
3234 _1
, _2
, sizeof(write_data
), &called
));
3237 BOOST_ASIO_CHECK(called
);
3238 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3241 s
.next_write_length(10);
3243 boost::asio::async_write(s
, buffers
, boost::asio::transfer_all(),
3244 bindns::bind(async_write_handler
,
3245 _1
, _2
, sizeof(write_data
), &called
));
3248 BOOST_ASIO_CHECK(called
);
3249 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3253 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
3254 bindns::bind(async_write_handler
,
3255 _1
, _2
, sizeof(write_data
), &called
));
3258 BOOST_ASIO_CHECK(called
);
3259 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3262 s
.next_write_length(1);
3264 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
3265 bindns::bind(async_write_handler
,
3266 _1
, _2
, 1, &called
));
3269 BOOST_ASIO_CHECK(called
);
3270 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
3273 s
.next_write_length(10);
3275 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(1),
3276 bindns::bind(async_write_handler
,
3277 _1
, _2
, 10, &called
));
3280 BOOST_ASIO_CHECK(called
);
3281 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3285 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
3286 bindns::bind(async_write_handler
,
3287 _1
, _2
, sizeof(write_data
), &called
));
3290 BOOST_ASIO_CHECK(called
);
3291 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3294 s
.next_write_length(1);
3296 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
3297 bindns::bind(async_write_handler
,
3298 _1
, _2
, 10, &called
));
3301 BOOST_ASIO_CHECK(called
);
3302 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3305 s
.next_write_length(10);
3307 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(10),
3308 bindns::bind(async_write_handler
,
3309 _1
, _2
, 10, &called
));
3312 BOOST_ASIO_CHECK(called
);
3313 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3317 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
3318 bindns::bind(async_write_handler
,
3319 _1
, _2
, sizeof(write_data
), &called
));
3322 BOOST_ASIO_CHECK(called
);
3323 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3326 s
.next_write_length(1);
3328 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
3329 bindns::bind(async_write_handler
,
3330 _1
, _2
, 42, &called
));
3333 BOOST_ASIO_CHECK(called
);
3334 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
3337 s
.next_write_length(10);
3339 boost::asio::async_write(s
, buffers
, boost::asio::transfer_at_least(42),
3340 bindns::bind(async_write_handler
,
3341 _1
, _2
, 50, &called
));
3344 BOOST_ASIO_CHECK(called
);
3345 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 50));
3349 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
3350 bindns::bind(async_write_handler
,
3351 _1
, _2
, 1, &called
));
3354 BOOST_ASIO_CHECK(called
);
3355 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
3358 s
.next_write_length(1);
3360 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
3361 bindns::bind(async_write_handler
,
3362 _1
, _2
, 1, &called
));
3365 BOOST_ASIO_CHECK(called
);
3366 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
3369 s
.next_write_length(10);
3371 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(1),
3372 bindns::bind(async_write_handler
,
3373 _1
, _2
, 1, &called
));
3376 BOOST_ASIO_CHECK(called
);
3377 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
3381 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
3382 bindns::bind(async_write_handler
,
3383 _1
, _2
, 10, &called
));
3386 BOOST_ASIO_CHECK(called
);
3387 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3390 s
.next_write_length(1);
3392 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
3393 bindns::bind(async_write_handler
,
3394 _1
, _2
, 10, &called
));
3397 BOOST_ASIO_CHECK(called
);
3398 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3401 s
.next_write_length(10);
3403 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(10),
3404 bindns::bind(async_write_handler
,
3405 _1
, _2
, 10, &called
));
3408 BOOST_ASIO_CHECK(called
);
3409 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3413 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
3414 bindns::bind(async_write_handler
,
3415 _1
, _2
, 42, &called
));
3418 BOOST_ASIO_CHECK(called
);
3419 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
3422 s
.next_write_length(1);
3424 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
3425 bindns::bind(async_write_handler
,
3426 _1
, _2
, 42, &called
));
3429 BOOST_ASIO_CHECK(called
);
3430 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
3433 s
.next_write_length(10);
3435 boost::asio::async_write(s
, buffers
, boost::asio::transfer_exactly(42),
3436 bindns::bind(async_write_handler
,
3437 _1
, _2
, 42, &called
));
3440 BOOST_ASIO_CHECK(called
);
3441 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
3445 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
3446 bindns::bind(async_write_handler
,
3447 _1
, _2
, sizeof(write_data
), &called
));
3450 BOOST_ASIO_CHECK(called
);
3451 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3454 s
.next_write_length(1);
3456 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
3457 bindns::bind(async_write_handler
,
3458 _1
, _2
, sizeof(write_data
), &called
));
3461 BOOST_ASIO_CHECK(called
);
3462 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3465 s
.next_write_length(10);
3467 boost::asio::async_write(s
, buffers
, old_style_transfer_all
,
3468 bindns::bind(async_write_handler
,
3469 _1
, _2
, sizeof(write_data
), &called
));
3472 BOOST_ASIO_CHECK(called
);
3473 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3477 boost::asio::async_write(s
, buffers
, short_transfer
,
3478 bindns::bind(async_write_handler
,
3479 _1
, _2
, sizeof(write_data
), &called
));
3482 BOOST_ASIO_CHECK(called
);
3483 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3486 s
.next_write_length(1);
3488 boost::asio::async_write(s
, buffers
, short_transfer
,
3489 bindns::bind(async_write_handler
,
3490 _1
, _2
, sizeof(write_data
), &called
));
3493 BOOST_ASIO_CHECK(called
);
3494 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3497 s
.next_write_length(10);
3499 boost::asio::async_write(s
, buffers
, short_transfer
,
3500 bindns::bind(async_write_handler
,
3501 _1
, _2
, sizeof(write_data
), &called
));
3504 BOOST_ASIO_CHECK(called
);
3505 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3508 int i
= boost::asio::async_write(s
, buffers
, short_transfer
,
3509 archetypes::lazy_handler());
3510 BOOST_ASIO_CHECK(i
== 42);
3513 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3516 void test_4_arg_streambuf_async_write()
3518 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
3519 namespace bindns
= boost
;
3520 #else // defined(BOOST_ASIO_HAS_BOOST_BIND)
3521 namespace bindns
= std
;
3522 using std::placeholders::_1
;
3523 using std::placeholders::_2
;
3524 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
3526 boost::asio::io_service ios
;
3528 boost::asio::streambuf sb
;
3529 boost::asio::const_buffers_1 buffers
3530 = boost::asio::buffer(write_data
, sizeof(write_data
));
3533 sb
.consume(sb
.size());
3534 sb
.sputn(write_data
, sizeof(write_data
));
3535 bool called
= false;
3536 boost::asio::async_write(s
, sb
, boost::asio::transfer_all(),
3537 bindns::bind(async_write_handler
,
3538 _1
, _2
, sizeof(write_data
), &called
));
3541 BOOST_ASIO_CHECK(called
);
3542 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3545 sb
.consume(sb
.size());
3546 sb
.sputn(write_data
, sizeof(write_data
));
3547 s
.next_write_length(1);
3549 boost::asio::async_write(s
, sb
, boost::asio::transfer_all(),
3550 bindns::bind(async_write_handler
,
3551 _1
, _2
, sizeof(write_data
), &called
));
3554 BOOST_ASIO_CHECK(called
);
3555 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3558 sb
.consume(sb
.size());
3559 sb
.sputn(write_data
, sizeof(write_data
));
3560 s
.next_write_length(10);
3562 boost::asio::async_write(s
, sb
, boost::asio::transfer_all(),
3563 bindns::bind(async_write_handler
,
3564 _1
, _2
, sizeof(write_data
), &called
));
3567 BOOST_ASIO_CHECK(called
);
3568 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3571 sb
.consume(sb
.size());
3572 sb
.sputn(write_data
, sizeof(write_data
));
3574 boost::asio::async_write(s
, sb
, boost::asio::transfer_at_least(1),
3575 bindns::bind(async_write_handler
,
3576 _1
, _2
, sizeof(write_data
), &called
));
3579 BOOST_ASIO_CHECK(called
);
3580 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3583 sb
.consume(sb
.size());
3584 sb
.sputn(write_data
, sizeof(write_data
));
3585 s
.next_write_length(1);
3587 boost::asio::async_write(s
, sb
, boost::asio::transfer_at_least(1),
3588 bindns::bind(async_write_handler
,
3589 _1
, _2
, 1, &called
));
3592 BOOST_ASIO_CHECK(called
);
3593 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
3596 sb
.consume(sb
.size());
3597 sb
.sputn(write_data
, sizeof(write_data
));
3598 s
.next_write_length(10);
3600 boost::asio::async_write(s
, sb
, boost::asio::transfer_at_least(1),
3601 bindns::bind(async_write_handler
,
3602 _1
, _2
, 10, &called
));
3605 BOOST_ASIO_CHECK(called
);
3606 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3609 sb
.consume(sb
.size());
3610 sb
.sputn(write_data
, sizeof(write_data
));
3612 boost::asio::async_write(s
, sb
, boost::asio::transfer_at_least(10),
3613 bindns::bind(async_write_handler
,
3614 _1
, _2
, sizeof(write_data
), &called
));
3617 BOOST_ASIO_CHECK(called
);
3618 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3621 sb
.consume(sb
.size());
3622 sb
.sputn(write_data
, sizeof(write_data
));
3623 s
.next_write_length(1);
3625 boost::asio::async_write(s
, sb
, boost::asio::transfer_at_least(10),
3626 bindns::bind(async_write_handler
,
3627 _1
, _2
, 10, &called
));
3630 BOOST_ASIO_CHECK(called
);
3631 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3634 sb
.consume(sb
.size());
3635 sb
.sputn(write_data
, sizeof(write_data
));
3636 s
.next_write_length(10);
3638 boost::asio::async_write(s
, sb
, boost::asio::transfer_at_least(10),
3639 bindns::bind(async_write_handler
,
3640 _1
, _2
, 10, &called
));
3643 BOOST_ASIO_CHECK(called
);
3644 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3647 sb
.consume(sb
.size());
3648 sb
.sputn(write_data
, sizeof(write_data
));
3650 boost::asio::async_write(s
, sb
, boost::asio::transfer_at_least(42),
3651 bindns::bind(async_write_handler
,
3652 _1
, _2
, sizeof(write_data
), &called
));
3655 BOOST_ASIO_CHECK(called
);
3656 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3659 sb
.consume(sb
.size());
3660 sb
.sputn(write_data
, sizeof(write_data
));
3661 s
.next_write_length(1);
3663 boost::asio::async_write(s
, sb
, boost::asio::transfer_at_least(42),
3664 bindns::bind(async_write_handler
,
3665 _1
, _2
, 42, &called
));
3668 BOOST_ASIO_CHECK(called
);
3669 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
3672 sb
.consume(sb
.size());
3673 sb
.sputn(write_data
, sizeof(write_data
));
3674 s
.next_write_length(10);
3676 boost::asio::async_write(s
, sb
, boost::asio::transfer_at_least(42),
3677 bindns::bind(async_write_handler
,
3678 _1
, _2
, 50, &called
));
3681 BOOST_ASIO_CHECK(called
);
3682 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 50));
3685 sb
.consume(sb
.size());
3686 sb
.sputn(write_data
, sizeof(write_data
));
3688 boost::asio::async_write(s
, sb
, boost::asio::transfer_exactly(1),
3689 bindns::bind(async_write_handler
,
3690 _1
, _2
, 1, &called
));
3693 BOOST_ASIO_CHECK(called
);
3694 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
3697 sb
.consume(sb
.size());
3698 sb
.sputn(write_data
, sizeof(write_data
));
3699 s
.next_write_length(1);
3701 boost::asio::async_write(s
, sb
, boost::asio::transfer_exactly(1),
3702 bindns::bind(async_write_handler
,
3703 _1
, _2
, 1, &called
));
3706 BOOST_ASIO_CHECK(called
);
3707 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
3710 sb
.consume(sb
.size());
3711 sb
.sputn(write_data
, sizeof(write_data
));
3712 s
.next_write_length(10);
3714 boost::asio::async_write(s
, sb
, boost::asio::transfer_exactly(1),
3715 bindns::bind(async_write_handler
,
3716 _1
, _2
, 1, &called
));
3719 BOOST_ASIO_CHECK(called
);
3720 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 1));
3723 sb
.consume(sb
.size());
3724 sb
.sputn(write_data
, sizeof(write_data
));
3726 boost::asio::async_write(s
, sb
, boost::asio::transfer_exactly(10),
3727 bindns::bind(async_write_handler
,
3728 _1
, _2
, 10, &called
));
3731 BOOST_ASIO_CHECK(called
);
3732 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3735 sb
.consume(sb
.size());
3736 sb
.sputn(write_data
, sizeof(write_data
));
3737 s
.next_write_length(1);
3739 boost::asio::async_write(s
, sb
, boost::asio::transfer_exactly(10),
3740 bindns::bind(async_write_handler
,
3741 _1
, _2
, 10, &called
));
3744 BOOST_ASIO_CHECK(called
);
3745 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3748 sb
.consume(sb
.size());
3749 sb
.sputn(write_data
, sizeof(write_data
));
3750 s
.next_write_length(10);
3752 boost::asio::async_write(s
, sb
, boost::asio::transfer_exactly(10),
3753 bindns::bind(async_write_handler
,
3754 _1
, _2
, 10, &called
));
3757 BOOST_ASIO_CHECK(called
);
3758 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 10));
3761 sb
.consume(sb
.size());
3762 sb
.sputn(write_data
, sizeof(write_data
));
3764 boost::asio::async_write(s
, sb
, boost::asio::transfer_exactly(42),
3765 bindns::bind(async_write_handler
,
3766 _1
, _2
, 42, &called
));
3769 BOOST_ASIO_CHECK(called
);
3770 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
3773 sb
.consume(sb
.size());
3774 sb
.sputn(write_data
, sizeof(write_data
));
3775 s
.next_write_length(1);
3777 boost::asio::async_write(s
, sb
, boost::asio::transfer_exactly(42),
3778 bindns::bind(async_write_handler
,
3779 _1
, _2
, 42, &called
));
3782 BOOST_ASIO_CHECK(called
);
3783 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
3786 sb
.consume(sb
.size());
3787 sb
.sputn(write_data
, sizeof(write_data
));
3788 s
.next_write_length(10);
3790 boost::asio::async_write(s
, sb
, boost::asio::transfer_exactly(42),
3791 bindns::bind(async_write_handler
,
3792 _1
, _2
, 42, &called
));
3795 BOOST_ASIO_CHECK(called
);
3796 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, 42));
3799 sb
.consume(sb
.size());
3800 sb
.sputn(write_data
, sizeof(write_data
));
3802 boost::asio::async_write(s
, sb
, old_style_transfer_all
,
3803 bindns::bind(async_write_handler
,
3804 _1
, _2
, sizeof(write_data
), &called
));
3807 BOOST_ASIO_CHECK(called
);
3808 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3811 sb
.consume(sb
.size());
3812 sb
.sputn(write_data
, sizeof(write_data
));
3813 s
.next_write_length(1);
3815 boost::asio::async_write(s
, sb
, old_style_transfer_all
,
3816 bindns::bind(async_write_handler
,
3817 _1
, _2
, sizeof(write_data
), &called
));
3820 BOOST_ASIO_CHECK(called
);
3821 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3824 sb
.consume(sb
.size());
3825 sb
.sputn(write_data
, sizeof(write_data
));
3826 s
.next_write_length(10);
3828 boost::asio::async_write(s
, sb
, old_style_transfer_all
,
3829 bindns::bind(async_write_handler
,
3830 _1
, _2
, sizeof(write_data
), &called
));
3833 BOOST_ASIO_CHECK(called
);
3834 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3837 sb
.consume(sb
.size());
3838 sb
.sputn(write_data
, sizeof(write_data
));
3840 boost::asio::async_write(s
, sb
, short_transfer
,
3841 bindns::bind(async_write_handler
,
3842 _1
, _2
, sizeof(write_data
), &called
));
3845 BOOST_ASIO_CHECK(called
);
3846 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3849 sb
.consume(sb
.size());
3850 sb
.sputn(write_data
, sizeof(write_data
));
3851 s
.next_write_length(1);
3853 boost::asio::async_write(s
, sb
, short_transfer
,
3854 bindns::bind(async_write_handler
,
3855 _1
, _2
, sizeof(write_data
), &called
));
3858 BOOST_ASIO_CHECK(called
);
3859 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3862 sb
.consume(sb
.size());
3863 sb
.sputn(write_data
, sizeof(write_data
));
3864 s
.next_write_length(10);
3866 boost::asio::async_write(s
, sb
, short_transfer
,
3867 bindns::bind(async_write_handler
,
3868 _1
, _2
, sizeof(write_data
), &called
));
3871 BOOST_ASIO_CHECK(called
);
3872 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3875 sb
.consume(sb
.size());
3876 sb
.sputn(write_data
, sizeof(write_data
));
3877 int i
= boost::asio::async_write(s
, sb
, short_transfer
,
3878 archetypes::lazy_handler());
3879 BOOST_ASIO_CHECK(i
== 42);
3882 BOOST_ASIO_CHECK(s
.check_buffers(buffers
, sizeof(write_data
)));
3885 BOOST_ASIO_TEST_SUITE
3888 BOOST_ASIO_TEST_CASE(test_2_arg_zero_buffers_write
)
3889 BOOST_ASIO_TEST_CASE(test_2_arg_const_buffers_1_write
)
3890 BOOST_ASIO_TEST_CASE(test_2_arg_mutable_buffers_1_write
)
3891 BOOST_ASIO_TEST_CASE(test_2_arg_vector_buffers_write
)
3892 BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_zero_buffers_write
)
3893 BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_const_buffers_1_write
)
3894 BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_mutable_buffers_1_write
)
3895 BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_vector_buffers_write
)
3896 BOOST_ASIO_TEST_CASE(test_3_arg_const_buffers_1_write
)
3897 BOOST_ASIO_TEST_CASE(test_3_arg_mutable_buffers_1_write
)
3898 BOOST_ASIO_TEST_CASE(test_3_arg_vector_buffers_write
)
3899 BOOST_ASIO_TEST_CASE(test_4_arg_const_buffers_1_write
)
3900 BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffers_1_write
)
3901 BOOST_ASIO_TEST_CASE(test_4_arg_vector_buffers_write
)
3902 BOOST_ASIO_TEST_CASE(test_3_arg_const_buffers_1_async_write
)
3903 BOOST_ASIO_TEST_CASE(test_3_arg_mutable_buffers_1_async_write
)
3904 BOOST_ASIO_TEST_CASE(test_3_arg_boost_array_buffers_async_write
)
3905 BOOST_ASIO_TEST_CASE(test_3_arg_std_array_buffers_async_write
)
3906 BOOST_ASIO_TEST_CASE(test_3_arg_vector_buffers_async_write
)
3907 BOOST_ASIO_TEST_CASE(test_3_arg_streambuf_async_write
)
3908 BOOST_ASIO_TEST_CASE(test_4_arg_const_buffers_1_async_write
)
3909 BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffers_1_async_write
)
3910 BOOST_ASIO_TEST_CASE(test_4_arg_boost_array_buffers_async_write
)
3911 BOOST_ASIO_TEST_CASE(test_4_arg_std_array_buffers_async_write
)
3912 BOOST_ASIO_TEST_CASE(test_4_arg_vector_buffers_async_write
)
3913 BOOST_ASIO_TEST_CASE(test_4_arg_streambuf_async_write
)