Avoid deprecated Boost.Asio interfaces
Change-Id: I00d285893ff61619f49dff8a8a55d0d0e2c309a7
diff --git a/tests/unit/util/regex.t.cpp b/tests/unit/util/regex.t.cpp
index d09688e..07ec293 100644
--- a/tests/unit/util/regex.t.cpp
+++ b/tests/unit/util/regex.t.cpp
@@ -279,7 +279,7 @@
{
auto backRef = make_shared<RegexBackrefManager>();
auto cm = make_shared<RegexBackrefMatcher>("(<a><b>)", backRef);
- backRef->pushRef(static_pointer_cast<RegexMatcher>(cm));
+ backRef->pushRef(std::static_pointer_cast<RegexMatcher>(cm));
cm->compile();
bool res = cm->match(Name("/a/b/c"), 0, 2);
BOOST_CHECK_EQUAL(res, true);
diff --git a/tests/unit/util/scheduler.t.cpp b/tests/unit/util/scheduler.t.cpp
index e5c99e5..88c4313 100644
--- a/tests/unit/util/scheduler.t.cpp
+++ b/tests/unit/util/scheduler.t.cpp
@@ -51,23 +51,31 @@
BOOST_CHECK_EQUAL(count2, 1);
});
- EventId i = scheduler.schedule(1_s, [] { BOOST_ERROR("This event should not have been fired"); });
- i.cancel();
+ EventId eid = scheduler.schedule(1_s, [] { BOOST_ERROR("This event should not have been fired"); });
+ eid.cancel();
scheduler.schedule(250_ms, [&] {
BOOST_CHECK_EQUAL(count1, 0);
++count2;
});
- i = scheduler.schedule(50_ms, [&] { BOOST_ERROR("This event should not have been fired"); });
- i.cancel();
+ eid = scheduler.schedule(50_ms, [&] { BOOST_ERROR("This event should not have been fired"); });
+ eid.cancel();
advanceClocks(25_ms, 1000_ms);
BOOST_CHECK_EQUAL(count1, 1);
BOOST_CHECK_EQUAL(count2, 1);
}
-BOOST_AUTO_TEST_CASE(CallbackException)
+BOOST_AUTO_TEST_CASE(NegativeDelay)
+{
+ bool wasCallbackInvoked = false;
+ scheduler.schedule(-1_s, [&] { wasCallbackInvoked = true; });
+ advanceClocks(1_ns);
+ BOOST_CHECK(wasCallbackInvoked);
+}
+
+BOOST_AUTO_TEST_CASE(ThrowingCallback)
{
class MyException : public std::exception
{
@@ -79,12 +87,12 @@
throw MyException{};
});
- bool isCallbackInvoked = false;
- scheduler.schedule(20_ms, [&isCallbackInvoked] { isCallbackInvoked = true; });
+ bool wasCallbackInvoked = false;
+ scheduler.schedule(20_ms, [&] { wasCallbackInvoked = true; });
BOOST_CHECK_THROW(this->advanceClocks(6_ms, 2), MyException);
this->advanceClocks(6_ms, 2);
- BOOST_CHECK(isCallbackInvoked);
+ BOOST_CHECK(wasCallbackInvoked);
}
BOOST_AUTO_TEST_CASE(CancelEmptyEvent)
@@ -100,7 +108,7 @@
{
EventId selfEventId;
selfEventId = scheduler.schedule(100_ms, [&] { selfEventId.cancel(); });
- BOOST_REQUIRE_NO_THROW(advanceClocks(100_ms, 10));
+ BOOST_CHECK_NO_THROW(advanceClocks(100_ms, 10));
}
class SelfRescheduleFixture : public SchedulerFixture
@@ -143,7 +151,7 @@
scheduler.schedule(100_ms, [&] { ++count; });
}
-public:
+protected:
EventId selfEventId;
size_t count = 0;
};
@@ -151,21 +159,21 @@
BOOST_FIXTURE_TEST_CASE(Reschedule, SelfRescheduleFixture)
{
selfEventId = scheduler.schedule(0_s, [this] { reschedule(); });
- BOOST_REQUIRE_NO_THROW(advanceClocks(50_ms, 1000_ms));
+ advanceClocks(50_ms, 1000_ms);
BOOST_CHECK_EQUAL(count, 5);
}
BOOST_FIXTURE_TEST_CASE(Reschedule2, SelfRescheduleFixture)
{
selfEventId = scheduler.schedule(0_s, [this] { reschedule2(); });
- BOOST_REQUIRE_NO_THROW(advanceClocks(50_ms, 1000_ms));
+ advanceClocks(50_ms, 1000_ms);
BOOST_CHECK_EQUAL(count, 5);
}
BOOST_FIXTURE_TEST_CASE(Reschedule3, SelfRescheduleFixture)
{
selfEventId = scheduler.schedule(0_s, [this] { reschedule3(); });
- BOOST_REQUIRE_NO_THROW(advanceClocks(50_ms, 1000_ms));
+ advanceClocks(50_ms, 1000_ms);
BOOST_CHECK_EQUAL(count, 6);
}