File boost-add_timer_canceling_test.patch of Package boost
Add a test for timer canceling.
--- libs/asio/test/deadline_timer.cpp
+++ libs/asio/test/deadline_timer.cpp
@@ -180,8 +180,33 @@
}
+void timer_handler(const boost::system::error_code&)
+{
+}
+
+void deadline_timer_cancel_test()
+{
+ static boost::asio::io_service io_service;
+ struct timer
+ {
+ boost::asio::deadline_timer t;
+ timer() : t(io_service) { t.expires_at(boost::posix_time::pos_infin); }
+ } timers[50];
+
+ timers[2].t.async_wait(timer_handler);
+ timers[41].t.async_wait(timer_handler);
+ for (int i = 10; i < 20; ++i)
+ timers[i].t.async_wait(timer_handler);
+
+ BOOST_CHECK(timers[2].t.cancel() == 1);
+ BOOST_CHECK(timers[41].t.cancel() == 1);
+ for (int i = 10; i < 20; ++i)
+ BOOST_CHECK(timers[i].t.cancel() == 1);
+}
+
test_suite* init_unit_test_suite(int, char*[])
{
test_suite* test = BOOST_TEST_SUITE("deadline_timer");
test->add(BOOST_TEST_CASE(&deadline_timer_test));
+ test->add(BOOST_TEST_CASE(&deadline_timer_cancel_test));
return test;
}