Avoid deprecated Boost.Asio interfaces
Change-Id: I00d285893ff61619f49dff8a8a55d0d0e2c309a7
diff --git a/tests/benchmarks/scheduler-bench.cpp b/tests/benchmarks/scheduler-bench.cpp
index 46af278..e1e3433 100644
--- a/tests/benchmarks/scheduler-bench.cpp
+++ b/tests/benchmarks/scheduler-bench.cpp
@@ -25,14 +25,14 @@
#include "ndn-cxx/util/scheduler.hpp"
#include "tests/benchmarks/timed-execute.hpp"
-#include <boost/asio/io_service.hpp>
+#include <boost/asio/io_context.hpp>
#include <iostream>
namespace ndn::tests {
BOOST_AUTO_TEST_CASE(ScheduleCancel)
{
- boost::asio::io_service io;
+ boost::asio::io_context io;
Scheduler sched(io);
const size_t nEvents = 1000000;
@@ -56,7 +56,7 @@
BOOST_AUTO_TEST_CASE(Execute)
{
- boost::asio::io_service io;
+ boost::asio::io_context io;
Scheduler sched(io);
const size_t nEvents = 1000000;
diff --git a/tests/integration/face.cpp b/tests/integration/face.cpp
index 7bd2408..a759e35 100644
--- a/tests/integration/face.cpp
+++ b/tests/integration/face.cpp
@@ -68,7 +68,7 @@
protected:
FaceFixture()
: face(TransportType::create(""), m_keyChain)
- , sched(face.getIoService())
+ , sched(face.getIoContext())
{
}
@@ -82,7 +82,7 @@
sendInterest(time::nanoseconds delay, const Interest& interest, char& outcome)
{
if (face2 == nullptr) {
- face2 = make_unique<Face>(TransportType::create(""), face.getIoService(), m_keyChain);
+ face2 = make_unique<Face>(TransportType::create(""), face.getIoContext(), m_keyChain);
}
outcome = '?';
@@ -101,13 +101,13 @@
return sendInterest(delay, interest, ignoredOutcome);
}
- /** \brief Stop io_service after a delay
+ /** \brief Stop io_context after a delay
* \return scheduled event id
*/
scheduler::EventId
terminateAfter(time::nanoseconds delay)
{
- return sched.schedule(delay, [this] { face.getIoService().stop(); });
+ return sched.schedule(delay, [this] { face.getIoContext().stop(); });
}
protected:
diff --git a/tests/integration/network-monitor.cpp b/tests/integration/network-monitor.cpp
index cf6d8bd..ff4d932 100644
--- a/tests/integration/network-monitor.cpp
+++ b/tests/integration/network-monitor.cpp
@@ -30,7 +30,7 @@
#include "ndn-cxx/util/string-helper.hpp"
#include "ndn-cxx/util/time.hpp"
-#include <boost/asio/io_service.hpp>
+#include <boost/asio/io_context.hpp>
#include <iostream>
namespace ndn::tests {
@@ -48,7 +48,7 @@
BOOST_AUTO_TEST_CASE(Signals)
{
- boost::asio::io_service io;
+ boost::asio::io_context io;
NetworkMonitor monitor(io);
std::cout << "capabilities=" << AsHex{monitor.getCapabilities()} << std::endl;
diff --git a/tests/unit/encoding/block.t.cpp b/tests/unit/encoding/block.t.cpp
index c93a307..b4f2cf8 100644
--- a/tests/unit/encoding/block.t.cpp
+++ b/tests/unit/encoding/block.t.cpp
@@ -649,8 +649,8 @@
{
Block block = "0101A0"_block;
boost::asio::const_buffer buffer(block);
- BOOST_CHECK_EQUAL(boost::asio::buffer_cast<const uint8_t*>(buffer), block.data());
- BOOST_CHECK_EQUAL(boost::asio::buffer_size(buffer), block.size());
+ BOOST_CHECK_EQUAL(buffer.data(), block.data());
+ BOOST_CHECK_EQUAL(buffer.size(), block.size());
}
BOOST_AUTO_TEST_CASE(Equality)
diff --git a/tests/unit/face.t.cpp b/tests/unit/face.t.cpp
index f369d6f..78d7c67 100644
--- a/tests/unit/face.t.cpp
+++ b/tests/unit/face.t.cpp
@@ -96,8 +96,8 @@
BOOST_CHECK_EQUAL(i.getName(), "/Hello/World");
++nData;
},
- std::bind([] { BOOST_FAIL("Unexpected Nack"); }),
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected Nack"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
advanceClocks(40_ms);
@@ -112,9 +112,9 @@
size_t nTimeouts = 0;
face.expressInterest(*makeInterest("/Hello/World/a/2", false, 50_ms),
- std::bind([]{}),
- std::bind([]{}),
- std::bind([&nTimeouts] { ++nTimeouts; }));
+ [] (auto&&...) {},
+ [] (auto&&...) {},
+ [&] (auto&&...) { ++nTimeouts; });
advanceClocks(200_ms, 5);
BOOST_CHECK_EQUAL(nTimeouts, 1);
}
@@ -124,14 +124,14 @@
size_t nData = 0;
face.expressInterest(*makeInterest("/Hello/World", true, 50_ms),
- [&] (const auto&, const auto&) { ++nData; },
- std::bind([] { BOOST_FAIL("Unexpected Nack"); }),
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [&] (auto&&...) { ++nData; },
+ [] (auto&&...) { BOOST_FAIL("Unexpected Nack"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
face.expressInterest(*makeInterest("/Hello/World/a", true, 50_ms),
- [&] (const auto&, const auto&) { ++nData; },
- std::bind([] { BOOST_FAIL("Unexpected Nack"); }),
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [&] (auto&&...) { ++nData; },
+ [] (auto&&...) { BOOST_FAIL("Unexpected Nack"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
advanceClocks(40_ms);
@@ -148,8 +148,8 @@
{
face.expressInterest(*makeInterest("/Hello/World", true),
nullptr,
- std::bind([] { BOOST_FAIL("Unexpected Nack"); }),
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected Nack"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
advanceClocks(1_ms);
BOOST_CHECK_NO_THROW(do {
@@ -162,13 +162,12 @@
{
size_t nTimeouts = 0;
face.expressInterest(*makeInterest("/Hello/World", false, 50_ms),
- std::bind([] { BOOST_FAIL("Unexpected Data"); }),
- std::bind([] { BOOST_FAIL("Unexpected Nack"); }),
+ [] (auto&&...) { BOOST_FAIL("Unexpected Data"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected Nack"); },
[&nTimeouts] (const Interest& i) {
BOOST_CHECK_EQUAL(i.getName(), "/Hello/World");
++nTimeouts;
});
-
advanceClocks(200_ms, 5);
BOOST_CHECK_EQUAL(nTimeouts, 1);
@@ -180,8 +179,8 @@
BOOST_AUTO_TEST_CASE(EmptyTimeoutCallback)
{
face.expressInterest(*makeInterest("/Hello/World", false, 50_ms),
- std::bind([] { BOOST_FAIL("Unexpected Data"); }),
- std::bind([] { BOOST_FAIL("Unexpected Nack"); }),
+ [] (auto&&...) { BOOST_FAIL("Unexpected Data"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected Nack"); },
nullptr);
advanceClocks(40_ms);
@@ -195,16 +194,15 @@
size_t nNacks = 0;
auto interest = makeInterest("/Hello/World", false, 50_ms);
-
face.expressInterest(*interest,
- std::bind([] { BOOST_FAIL("Unexpected Data"); }),
+ [] (auto&&...) { BOOST_FAIL("Unexpected Data"); },
[&] (const Interest& i, const lp::Nack& n) {
BOOST_CHECK(i.getName().isPrefixOf(n.getInterest().getName()));
BOOST_CHECK_EQUAL(i.getName(), "/Hello/World");
BOOST_CHECK_EQUAL(n.getReason(), lp::NackReason::DUPLICATE);
++nNacks;
},
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
advanceClocks(40_ms);
@@ -222,15 +220,15 @@
auto interest = makeInterest("/Hello/World", false, 50_ms, 1);
face.expressInterest(*interest,
- std::bind([] { BOOST_FAIL("Unexpected Data"); }),
+ [] (auto&&...) { BOOST_FAIL("Unexpected Data"); },
[&] (const auto&, const auto&) { ++nNacks; },
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
interest->setNonce(2);
face.expressInterest(*interest,
- std::bind([] { BOOST_FAIL("Unexpected Data"); }),
+ [] (auto&&...) { BOOST_FAIL("Unexpected Data"); },
[&] (const auto&, const auto&) { ++nNacks; },
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
advanceClocks(40_ms);
@@ -245,9 +243,9 @@
BOOST_AUTO_TEST_CASE(EmptyNackCallback)
{
face.expressInterest(*makeInterest("/Hello/World"),
- std::bind([] { BOOST_FAIL("Unexpected Data"); }),
+ [] (auto&&...) { BOOST_FAIL("Unexpected Data"); },
nullptr,
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
advanceClocks(1_ms);
BOOST_CHECK_NO_THROW(do {
@@ -259,7 +257,7 @@
BOOST_AUTO_TEST_CASE(PutDataFromDataCallback) // Bug 4596
{
face.expressInterest(*makeInterest("/localhost/notification/1"),
- [&] (const auto&, const auto&) {
+ [&] (auto&&...) {
face.put(*makeData("/chronosync/sampleDigest/1"));
}, nullptr, nullptr);
advanceClocks(10_ms);
@@ -290,9 +288,9 @@
BOOST_AUTO_TEST_CASE(Handle)
{
auto hdl = face.expressInterest(*makeInterest("/Hello/World", true, 50_ms),
- std::bind([] { BOOST_FAIL("Unexpected data"); }),
- std::bind([] { BOOST_FAIL("Unexpected nack"); }),
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected data"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected nack"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
advanceClocks(1_ms);
hdl.cancel();
advanceClocks(1_ms);
@@ -302,9 +300,9 @@
// cancel after destructing face
auto face2 = make_unique<DummyClientFace>(m_io, m_keyChain);
auto hdl2 = face2->expressInterest(*makeInterest("/Hello/World", true, 50_ms),
- std::bind([] { BOOST_FAIL("Unexpected data"); }),
- std::bind([] { BOOST_FAIL("Unexpected nack"); }),
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected data"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected nack"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
advanceClocks(1_ms);
face2.reset();
advanceClocks(1_ms);
@@ -320,14 +318,14 @@
BOOST_AUTO_TEST_CASE(RemoveAllPendingInterests)
{
face.expressInterest(*makeInterest("/Hello/World/0", false, 50_ms),
- std::bind([] { BOOST_FAIL("Unexpected data"); }),
- std::bind([] { BOOST_FAIL("Unexpected nack"); }),
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected data"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected nack"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
face.expressInterest(*makeInterest("/Hello/World/1", false, 50_ms),
- std::bind([] { BOOST_FAIL("Unexpected data"); }),
- std::bind([] { BOOST_FAIL("Unexpected nack"); }),
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected data"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected nack"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
advanceClocks(10_ms);
@@ -370,18 +368,19 @@
bool hasInterest1 = false, hasData = false;
// first InterestFilter allows loopback and should receive Interest
- face.setInterestFilter("/", [&] (const InterestFilter&, const Interest&) {
+ face.setInterestFilter("/", [&] (auto&&...) {
hasInterest1 = true;
// do not respond with Data right away, so Face must send Interest to forwarder
});
+
// second InterestFilter disallows loopback and should not receive Interest
face.setInterestFilter(InterestFilter("/").allowLoopback(false),
- std::bind([] { BOOST_ERROR("Unexpected Interest on second InterestFilter"); }));
+ [] (auto&&...) { BOOST_ERROR("Unexpected Interest on second InterestFilter"); });
face.expressInterest(*makeInterest("/A", true),
- std::bind([&] { hasData = true; }),
- std::bind([] { BOOST_FAIL("Unexpected nack"); }),
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [&] (auto&&...) { hasData = true; },
+ [] (auto&&...) { BOOST_FAIL("Unexpected nack"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
advanceClocks(1_ms);
BOOST_CHECK_EQUAL(hasInterest1, true); // Interest looped back
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1); // Interest sent to forwarder
@@ -397,12 +396,12 @@
{
bool hasInterest1 = false;
// register two Interest destinations
- face.setInterestFilter("/", std::bind([&] {
+ face.setInterestFilter("/", [&] (auto&&...) {
hasInterest1 = true;
// sending Data right away from the first destination, don't care whether Interest goes to second destination
face.put(*makeData("/A/B"));
- }));
- face.setInterestFilter("/", std::bind([]{}));
+ });
+ face.setInterestFilter("/", [] (auto&&...) {});
advanceClocks(10_ms);
face.receive(*makeInterest("/A", true));
@@ -417,7 +416,8 @@
BOOST_AUTO_TEST_CASE(PutNack)
{
- face.setInterestFilter("/", std::bind([]{})); // register one Interest destination so that face can accept Nacks
+ // register one Interest destination so that face can accept Nacks
+ face.setInterestFilter("/", [] (auto&&...) {});
advanceClocks(10_ms);
BOOST_CHECK_EQUAL(face.sentNacks.size(), 0);
@@ -457,7 +457,7 @@
// sending Nack right away from the first destination, Interest should still go to second destination
face.put(makeNack(interest, lp::NackReason::CONGESTION));
});
- face.setInterestFilter("/", std::bind([&] { hasInterest2 = true; }));
+ face.setInterestFilter("/", [&] (auto&&...) { hasInterest2 = true; });
advanceClocks(10_ms);
auto interest = makeInterest("/A", false, std::nullopt, 14333271);
@@ -487,18 +487,19 @@
hasInterest1 = true;
face.put(makeNack(interest, lp::NackReason::CONGESTION));
});
+
// second InterestFilter disallows loopback and should not receive Interest
face.setInterestFilter(InterestFilter("/").allowLoopback(false),
- std::bind([] { BOOST_ERROR("Unexpected Interest on second InterestFilter"); }));
+ [] (auto&&...) { BOOST_ERROR("Unexpected Interest on second InterestFilter"); });
auto interest = makeInterest("/A", false, std::nullopt, 28395852);
face.expressInterest(*interest,
- std::bind([] { BOOST_FAIL("Unexpected data"); }),
+ [] (auto&&...) { BOOST_FAIL("Unexpected data"); },
[&] (const Interest&, const lp::Nack& nack) {
hasNack = true;
BOOST_CHECK_EQUAL(nack.getReason(), lp::NackReason::CONGESTION);
},
- std::bind([] { BOOST_FAIL("Unexpected timeout"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected timeout"); });
advanceClocks(1_ms);
BOOST_CHECK_EQUAL(hasInterest1, true); // Interest looped back
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1); // Interest sent to forwarder
@@ -553,7 +554,7 @@
// cancel after destructing face
auto face2 = make_unique<DummyClientFace>(m_io, m_keyChain);
hdl = face2->registerPrefix("/Hello/World/2", nullptr,
- std::bind([] { BOOST_FAIL("Unexpected registerPrefix failure"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected failure"); });
advanceClocks(1_ms);
face2.reset();
advanceClocks(1_ms);
@@ -563,7 +564,7 @@
// unregister after destructing face
auto face3 = make_unique<DummyClientFace>(m_io, m_keyChain);
hdl = face3->registerPrefix("/Hello/World/3", nullptr,
- std::bind([] { BOOST_FAIL("Unexpected registerPrefix failure"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected failure"); });
advanceClocks(1_ms);
face3.reset();
advanceClocks(1_ms);
@@ -579,9 +580,9 @@
size_t nInterests = 0;
size_t nRegs = 0;
auto hdl = face.setInterestFilter("/Hello/World",
- std::bind([&nInterests] { ++nInterests; }),
- std::bind([&nRegs] { ++nRegs; }),
- std::bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
+ [&] (auto&&...) { ++nInterests; },
+ [&] (auto&&...) { ++nRegs; },
+ [] (auto&&...) { BOOST_FAIL("Unexpected failure"); });
advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nRegs, 1);
BOOST_CHECK_EQUAL(nInterests, 0);
@@ -623,8 +624,8 @@
{
size_t nInterests = 0;
auto hdl = face.setInterestFilter("/Hello/World",
- std::bind([&nInterests] { ++nInterests; }),
- std::bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
+ [&] (auto&&...) { ++nInterests; },
+ [] (auto&&...) { BOOST_FAIL("Unexpected failure"); });
advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nInterests, 0);
@@ -654,9 +655,9 @@
// don't enable registration reply
size_t nRegFailed = 0;
face.setInterestFilter("/Hello/World",
- std::bind([] { BOOST_FAIL("Unexpected Interest"); }),
- std::bind([] { BOOST_FAIL("Unexpected success of setInterestFilter"); }),
- std::bind([&nRegFailed] { ++nRegFailed; }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected Interest"); },
+ [] (auto&&...) { BOOST_FAIL("Unexpected success"); },
+ [&] (auto&&...) { ++nRegFailed; });
advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nRegFailed, 0);
@@ -670,8 +671,8 @@
// don't enable registration reply
size_t nRegFailed = 0;
face.setInterestFilter("/Hello/World",
- std::bind([] { BOOST_FAIL("Unexpected Interest"); }),
- std::bind([&nRegFailed] { ++nRegFailed; }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected Interest"); },
+ [&] (auto&&...) { ++nRegFailed; });
advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nRegFailed, 0);
@@ -684,21 +685,21 @@
{
size_t nInInterests1 = 0;
face.setInterestFilter("/Hello/World",
- std::bind([&nInInterests1] { ++nInInterests1; }),
+ [&nInInterests1] (auto&&...) { ++nInInterests1; },
nullptr,
- std::bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected failure"); });
size_t nInInterests2 = 0;
face.setInterestFilter("/Hello",
- std::bind([&nInInterests2] { ++nInInterests2; }),
+ [&nInInterests2] (auto&&...) { ++nInInterests2; },
nullptr,
- std::bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected failure"); });
size_t nInInterests3 = 0;
face.setInterestFilter("/Los/Angeles/Lakers",
- std::bind([&nInInterests3] { ++nInInterests3; }),
+ [&nInInterests3] (auto&&...) { ++nInInterests3; },
nullptr,
- std::bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected failure"); });
advanceClocks(25_ms, 4);
@@ -714,9 +715,9 @@
{
size_t nInInterests = 0;
face.setInterestFilter(InterestFilter("/Hello/World", "<><b><c>?"),
- std::bind([&nInInterests] { ++nInInterests; }),
+ [&nInInterests] (auto&&...) { ++nInInterests; },
nullptr,
- std::bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected failure"); });
advanceClocks(25_ms, 4);
@@ -736,11 +737,14 @@
BOOST_AUTO_TEST_CASE(RegexFilterError)
{
face.setInterestFilter(InterestFilter("/Hello/World", "<><b><c>?"),
+ // Do NOT use 'auto' for this lambda. This is testing the (failure of)
+ // implicit conversion from InterestFilter to Name, therefore the type
+ // of the first parameter must be explicit.
[] (const Name&, const Interest&) {
- BOOST_FAIL("InterestFilter::Error should have been triggered");
+ BOOST_FAIL("InterestFilter::Error should have been raised");
},
nullptr,
- std::bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
+ [] (auto&&...) { BOOST_FAIL("Unexpected failure"); });
advanceClocks(25_ms, 4);
@@ -751,12 +755,12 @@
{
size_t nInInterests = 0;
face.setInterestFilter(InterestFilter("/Hello/World", "<><b><c>?"),
- std::bind([&nInInterests] { ++nInInterests; }));
+ [&] (auto&&...) { ++nInInterests; });
size_t nRegSuccesses = 0;
face.registerPrefix("/Hello/World",
- std::bind([&nRegSuccesses] { ++nRegSuccesses; }),
- std::bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
+ [&] (auto&&...) { ++nRegSuccesses; },
+ [] (auto&&...) { BOOST_FAIL("Unexpected failure"); });
advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nRegSuccesses, 1);
@@ -780,11 +784,11 @@
// Regular Face won't accept incoming packets until something is sent.
int hit = 0;
- face.setInterestFilter(Name("/"), std::bind([&hit] { ++hit; }));
- face.processEvents(time::milliseconds(-1));
+ face.setInterestFilter(Name("/"), [&hit] (auto&&...) { ++hit; });
+ face.processEvents(-1_ms);
face.receive(*makeInterest("/A"));
- face.processEvents(time::milliseconds(-1));
+ face.processEvents(-1_ms);
BOOST_CHECK_EQUAL(hit, 1);
}
@@ -792,7 +796,7 @@
BOOST_AUTO_TEST_CASE(Handle)
{
int hit = 0;
- InterestFilterHandle hdl = face.setInterestFilter(Name("/"), std::bind([&hit] { ++hit; }));
+ InterestFilterHandle hdl = face.setInterestFilter(Name("/"), [&hit] (auto&&...) { ++hit; });
face.processEvents(-1_ms);
face.receive(*makeInterest("/A"));
@@ -820,18 +824,18 @@
BOOST_AUTO_TEST_CASE(ProcessEvents)
{
- face.processEvents(time::milliseconds(-1)); // io_service::reset()/poll() inside
+ face.processEvents(-1_ms); // io_context::restart()/poll() inside
- size_t nRegSuccesses = 0;
+ int nRegSuccesses = 0;
face.registerPrefix("/Hello/World",
- std::bind([&nRegSuccesses] { ++nRegSuccesses; }),
- std::bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
+ [&] (auto&&...) { ++nRegSuccesses; },
+ [] (auto&&...) { BOOST_FAIL("Unexpected failure"); });
- // io_service::poll() without reset
- face.getIoService().poll();
+ // io_context::poll() without reset
+ face.getIoContext().poll();
BOOST_CHECK_EQUAL(nRegSuccesses, 0);
- face.processEvents(time::milliseconds(-1)); // io_service::reset()/poll() inside
+ face.processEvents(-1_ms); // io_context::restart()/poll() inside
BOOST_CHECK_EQUAL(nRegSuccesses, 1);
}
@@ -852,16 +856,14 @@
BOOST_FIXTURE_TEST_CASE(FaceTransport, IoKeyChainFixture)
{
- BOOST_CHECK(Face().getTransport() != nullptr);
-
- BOOST_CHECK(Face(shared_ptr<Transport>()).getTransport() != nullptr);
- BOOST_CHECK(Face(shared_ptr<Transport>(), m_io).getTransport() != nullptr);
- BOOST_CHECK(Face(shared_ptr<Transport>(), m_io, m_keyChain).getTransport() != nullptr);
+ BOOST_CHECK_NO_THROW(Face(shared_ptr<Transport>()));
+ BOOST_CHECK_NO_THROW(Face(shared_ptr<Transport>(), m_io));
+ BOOST_CHECK_NO_THROW(Face(shared_ptr<Transport>(), m_io, m_keyChain));
auto transport = make_shared<TcpTransport>("localhost", "6363"); // no real io operations will be scheduled
- BOOST_CHECK(Face(transport).getTransport() == transport);
- BOOST_CHECK(Face(transport, m_io).getTransport() == transport);
- BOOST_CHECK(Face(transport, m_io, m_keyChain).getTransport() == transport);
+ BOOST_CHECK(&Face(transport).getTransport() == transport.get());
+ BOOST_CHECK(&Face(transport, m_io).getTransport() == transport.get());
+ BOOST_CHECK(&Face(transport, m_io, m_keyChain).getTransport() == transport.get());
}
class WithEnv
@@ -914,8 +916,8 @@
BOOST_FIXTURE_TEST_CASE(NoConfig, WithEnvAndConfig) // fixture configures test HOME and PIB/TPM path
{
shared_ptr<Face> face;
- BOOST_REQUIRE_NO_THROW(face = make_shared<Face>());
- BOOST_CHECK(dynamic_pointer_cast<UnixTransport>(face->getTransport()) != nullptr);
+ BOOST_CHECK_NO_THROW(face = make_shared<Face>());
+ BOOST_CHECK(dynamic_cast<UnixTransport*>(&face->getTransport()) != nullptr);
}
BOOST_FIXTURE_TEST_CASE_TEMPLATE(Unix, T, ConfigOptions, T)
@@ -923,8 +925,8 @@
this->configure("unix://some/path");
shared_ptr<Face> face;
- BOOST_REQUIRE_NO_THROW(face = make_shared<Face>());
- BOOST_CHECK(dynamic_pointer_cast<UnixTransport>(face->getTransport()) != nullptr);
+ BOOST_CHECK_NO_THROW(face = make_shared<Face>());
+ BOOST_CHECK(dynamic_cast<UnixTransport*>(&face->getTransport()) != nullptr);
}
BOOST_FIXTURE_TEST_CASE_TEMPLATE(Tcp, T, ConfigOptions, T)
@@ -932,8 +934,8 @@
this->configure("tcp://127.0.0.1:6000");
shared_ptr<Face> face;
- BOOST_REQUIRE_NO_THROW(face = make_shared<Face>());
- BOOST_CHECK(dynamic_pointer_cast<TcpTransport>(face->getTransport()) != nullptr);
+ BOOST_CHECK_NO_THROW(face = make_shared<Face>());
+ BOOST_CHECK(dynamic_cast<TcpTransport*>(&face->getTransport()) != nullptr);
}
BOOST_FIXTURE_TEST_CASE_TEMPLATE(WrongTransport, T, ConfigOptions, T)
@@ -956,8 +958,8 @@
this->WithConfig::configure("unix://some/path");
shared_ptr<Face> face;
- BOOST_REQUIRE_NO_THROW(face = make_shared<Face>());
- BOOST_CHECK(dynamic_pointer_cast<TcpTransport>(face->getTransport()) != nullptr);
+ BOOST_CHECK_NO_THROW(face = make_shared<Face>());
+ BOOST_CHECK(dynamic_cast<TcpTransport*>(&face->getTransport()) != nullptr);
}
BOOST_FIXTURE_TEST_CASE(ExplicitTransport, WithEnvAndConfig)
@@ -967,8 +969,8 @@
auto transport = make_shared<UnixTransport>("unix://some/path");
shared_ptr<Face> face;
- BOOST_REQUIRE_NO_THROW(face = make_shared<Face>(transport));
- BOOST_CHECK(dynamic_pointer_cast<UnixTransport>(face->getTransport()) != nullptr);
+ BOOST_CHECK_NO_THROW(face = make_shared<Face>(transport));
+ BOOST_CHECK(dynamic_cast<UnixTransport*>(&face->getTransport()) != nullptr);
}
BOOST_AUTO_TEST_SUITE_END() // Transport
diff --git a/tests/unit/io-fixture.hpp b/tests/unit/io-fixture.hpp
index 191b889..762dd6c 100644
--- a/tests/unit/io-fixture.hpp
+++ b/tests/unit/io-fixture.hpp
@@ -24,7 +24,7 @@
#include "tests/unit/clock-fixture.hpp"
-#include <boost/asio/io_service.hpp>
+#include <boost/asio/io_context.hpp>
namespace ndn::tests {
@@ -41,7 +41,7 @@
}
protected:
- boost::asio::io_service m_io;
+ boost::asio::io_context m_io;
};
} // namespace ndn::tests
diff --git a/tests/unit/net/dns.t.cpp b/tests/unit/net/dns.t.cpp
index ac734dd..17c5438 100644
--- a/tests/unit/net/dns.t.cpp
+++ b/tests/unit/net/dns.t.cpp
@@ -24,20 +24,19 @@
#include "tests/boost-test.hpp"
#include "tests/unit/net/network-configuration-detector.hpp"
-#include <boost/asio/io_service.hpp>
+#include <boost/asio/io_context.hpp>
namespace ndn::tests {
using namespace ndn::dns;
-using boost::asio::ip::address_v4;
-using boost::asio::ip::address_v6;
+namespace ip = boost::asio::ip;
class DnsFixture
{
public:
void
- onSuccess(const IpAddress& resolvedAddress,
- const IpAddress& expectedAddress,
+ onSuccess(const boost::asio::ip::address& resolvedAddress,
+ const boost::asio::ip::address& expectedAddress,
bool isValid,
bool shouldCheckAddress = false)
{
@@ -66,105 +65,95 @@
protected:
int m_nFailures = 0;
int m_nSuccesses = 0;
- boost::asio::io_service m_ioService;
+ boost::asio::io_context m_ioCtx;
};
BOOST_AUTO_TEST_SUITE(Net)
BOOST_FIXTURE_TEST_SUITE(TestDns, DnsFixture)
-BOOST_AUTO_TEST_CASE(Asynchronous)
+BOOST_AUTO_TEST_CASE(Failure)
{
SKIP_IF_IP_UNAVAILABLE();
asyncResolve("nothost.nothost.nothost.arpa",
- std::bind(&DnsFixture::onSuccess, this, _1, IpAddress(address_v4()), false, false),
+ std::bind(&DnsFixture::onSuccess, this, _1, ip::address_v4(), false, false),
[this] (auto&&...) { onFailure(true); },
- m_ioService); // should fail
+ m_ioCtx); // should fail
- m_ioService.run();
+ m_ioCtx.run();
BOOST_CHECK_EQUAL(m_nFailures, 1);
BOOST_CHECK_EQUAL(m_nSuccesses, 0);
}
-BOOST_AUTO_TEST_CASE(AsynchronousV4)
+BOOST_AUTO_TEST_CASE(Ipv4)
{
SKIP_IF_IPV4_UNAVAILABLE();
asyncResolve("192.0.2.1",
- std::bind(&DnsFixture::onSuccess, this, _1,
- IpAddress(address_v4::from_string("192.0.2.1")), true, true),
+ std::bind(&DnsFixture::onSuccess, this, _1, ip::make_address_v4("192.0.2.1"), true, true),
[this] (auto&&...) { onFailure(false); },
- m_ioService);
+ m_ioCtx);
- m_ioService.run();
+ m_ioCtx.run();
BOOST_CHECK_EQUAL(m_nFailures, 0);
BOOST_CHECK_EQUAL(m_nSuccesses, 1);
}
-BOOST_AUTO_TEST_CASE(AsynchronousV6)
+BOOST_AUTO_TEST_CASE(Ipv6)
{
SKIP_IF_IPV6_UNAVAILABLE();
asyncResolve("ipv6.google.com", // only IPv6 address should be available
- std::bind(&DnsFixture::onSuccess, this, _1, IpAddress(address_v6()), true, false),
+ std::bind(&DnsFixture::onSuccess, this, _1, ip::address_v6(), true, false),
[this] (auto&&...) { onFailure(false); },
- m_ioService);
+ m_ioCtx);
asyncResolve("2001:db8:3f9:0:3025:ccc5:eeeb:86d3",
std::bind(&DnsFixture::onSuccess, this, _1,
- IpAddress(address_v6::from_string("2001:db8:3f9:0:3025:ccc5:eeeb:86d3")),
- true, true),
+ ip::make_address_v6("2001:db8:3f9:0:3025:ccc5:eeeb:86d3"), true, true),
[this] (auto&&...) { onFailure(false); },
- m_ioService);
+ m_ioCtx);
- m_ioService.run();
+ m_ioCtx.run();
BOOST_CHECK_EQUAL(m_nFailures, 0);
BOOST_CHECK_EQUAL(m_nSuccesses, 2);
}
-BOOST_AUTO_TEST_CASE(AsynchronousV4AndV6)
+BOOST_AUTO_TEST_CASE(WithAddressSelector)
{
SKIP_IF_IPV4_UNAVAILABLE();
SKIP_IF_IPV6_UNAVAILABLE();
asyncResolve("named-data.net",
- std::bind(&DnsFixture::onSuccess, this, _1, IpAddress(address_v4()), true, false),
+ std::bind(&DnsFixture::onSuccess, this, _1, ip::address_v4(), true, false),
[this] (auto&&...) { onFailure(false); },
- m_ioService, Ipv4Only());
+ m_ioCtx, Ipv4Only());
asyncResolve("a.root-servers.net",
- std::bind(&DnsFixture::onSuccess, this, _1, IpAddress(address_v4()), true, false),
+ std::bind(&DnsFixture::onSuccess, this, _1, ip::address_v4(), true, false),
[this] (auto&&...) { onFailure(false); },
- m_ioService, Ipv4Only()); // request IPv4 address
+ m_ioCtx, Ipv4Only()); // request IPv4 address
asyncResolve("a.root-servers.net",
- std::bind(&DnsFixture::onSuccess, this, _1, IpAddress(address_v6()), true, false),
+ std::bind(&DnsFixture::onSuccess, this, _1, ip::address_v6(), true, false),
[this] (auto&&...) { onFailure(false); },
- m_ioService, Ipv6Only()); // request IPv6 address
+ m_ioCtx, Ipv6Only()); // request IPv6 address
asyncResolve("ipv6.google.com", // only IPv6 address should be available
- std::bind(&DnsFixture::onSuccess, this, _1, IpAddress(address_v6()), true, false),
+ std::bind(&DnsFixture::onSuccess, this, _1, ip::address_v6(), true, false),
[this] (auto&&...) { onFailure(false); },
- m_ioService, Ipv6Only());
+ m_ioCtx, Ipv6Only());
asyncResolve("ipv6.google.com", // only IPv6 address should be available
- std::bind(&DnsFixture::onSuccess, this, _1, IpAddress(address_v6()), false, false),
+ std::bind(&DnsFixture::onSuccess, this, _1, ip::address_v6(), false, false),
[this] (auto&&...) { onFailure(true); },
- m_ioService, Ipv4Only()); // should fail
+ m_ioCtx, Ipv4Only()); // should fail
- m_ioService.run();
+ m_ioCtx.run();
BOOST_CHECK_EQUAL(m_nFailures, 1);
BOOST_CHECK_EQUAL(m_nSuccesses, 4);
}
-BOOST_AUTO_TEST_CASE(Synchronous)
-{
- SKIP_IF_IP_UNAVAILABLE();
-
- IpAddress address = syncResolve("named-data.net", m_ioService);
- BOOST_CHECK(address.is_v4() || address.is_v6());
-}
-
BOOST_AUTO_TEST_SUITE_END() // TestDns
BOOST_AUTO_TEST_SUITE_END() // Net
diff --git a/tests/unit/net/face-uri.t.cpp b/tests/unit/net/face-uri.t.cpp
index 78e712a..36883bf 100644
--- a/tests/unit/net/face-uri.t.cpp
+++ b/tests/unit/net/face-uri.t.cpp
@@ -94,7 +94,7 @@
shared_ptr<const net::NetworkInterface> m_netif;
private:
- boost::asio::io_service m_io;
+ boost::asio::io_context m_io;
};
BOOST_AUTO_TEST_CASE(ParseInternal)
@@ -147,11 +147,11 @@
namespace ip = boost::asio::ip;
- ip::udp::endpoint endpoint4(ip::address_v4::from_string("192.0.2.1"), 7777);
+ ip::udp::endpoint endpoint4(ip::make_address_v4("192.0.2.1"), 7777);
uri = FaceUri(endpoint4);
BOOST_CHECK_EQUAL(uri.toString(), "udp4://192.0.2.1:7777");
- ip::udp::endpoint endpoint6(ip::address_v6::from_string("2001:DB8::1"), 7777);
+ ip::udp::endpoint endpoint6(ip::make_address_v6("2001:DB8::1"), 7777);
uri = FaceUri(endpoint6);
BOOST_CHECK_EQUAL(uri.toString(), "udp6://[2001:db8::1]:7777");
@@ -285,14 +285,14 @@
namespace ip = boost::asio::ip;
- ip::tcp::endpoint endpoint4(ip::address_v4::from_string("192.0.2.1"), 7777);
+ ip::tcp::endpoint endpoint4(ip::make_address_v4("192.0.2.1"), 7777);
uri = FaceUri(endpoint4);
BOOST_CHECK_EQUAL(uri.toString(), "tcp4://192.0.2.1:7777");
uri = FaceUri(endpoint4, "wsclient");
BOOST_CHECK_EQUAL(uri.toString(), "wsclient://192.0.2.1:7777");
- ip::tcp::endpoint endpoint6(ip::address_v6::from_string("2001:DB8::1"), 7777);
+ ip::tcp::endpoint endpoint6(ip::make_address_v6("2001:DB8::1"), 7777);
uri = FaceUri(endpoint6);
BOOST_CHECK_EQUAL(uri.toString(), "tcp6://[2001:db8::1]:7777");
@@ -553,7 +553,7 @@
BOOST_AUTO_TEST_CASE(CanonizeEmptyCallback)
{
- boost::asio::io_service io;
+ boost::asio::io_context io;
// unsupported scheme
FaceUri("null://").canonize(nullptr, nullptr, io, 1_ms);
diff --git a/tests/unit/net/network-configuration-detector.cpp b/tests/unit/net/network-configuration-detector.cpp
index f8a8816..44cae39 100644
--- a/tests/unit/net/network-configuration-detector.cpp
+++ b/tests/unit/net/network-configuration-detector.cpp
@@ -21,11 +21,9 @@
#include "tests/unit/net/network-configuration-detector.hpp"
-#include <boost/asio/io_service.hpp>
+#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/address.hpp>
-#include <boost/asio/ip/basic_resolver.hpp>
#include <boost/asio/ip/udp.hpp>
-#include <boost/range/iterator_range_core.hpp>
namespace ndn::tests {
@@ -50,31 +48,23 @@
void
NetworkConfigurationDetector::detect()
{
- using BoostResolver = boost::asio::ip::basic_resolver<boost::asio::ip::udp>;
+ boost::asio::io_context io;
+ boost::asio::ip::udp::resolver resolver(io);
- boost::asio::io_service ioService;
- BoostResolver resolver(ioService);
+ boost::system::error_code ec;
+ // The specified hostname must have both A and AAAA records
+ auto results = resolver.resolve("a.root-servers.net", "", ec);
- // The specified hostname must contain both A and AAAA records
- BoostResolver::query query("a.root-servers.net", "");
-
- boost::system::error_code errorCode;
- BoostResolver::iterator begin = resolver.resolve(query, errorCode);
- if (errorCode) {
- s_isInitialized = true;
- return;
- }
- BoostResolver::iterator end;
-
- for (const auto& i : boost::make_iterator_range(begin, end)) {
- if (i.endpoint().address().is_v4()) {
- s_hasIpv4 = true;
- }
- else if (i.endpoint().address().is_v6()) {
- s_hasIpv6 = true;
+ if (!ec) {
+ for (const auto& i : results) {
+ if (i.endpoint().address().is_v4()) {
+ s_hasIpv4 = true;
+ }
+ else if (i.endpoint().address().is_v6()) {
+ s_hasIpv6 = true;
+ }
}
}
-
s_isInitialized = true;
}
diff --git a/tests/unit/net/network-monitor.t.cpp b/tests/unit/net/network-monitor.t.cpp
index 4515258..50c04c7 100644
--- a/tests/unit/net/network-monitor.t.cpp
+++ b/tests/unit/net/network-monitor.t.cpp
@@ -23,7 +23,8 @@
#include "tests/boost-test.hpp"
-#include <boost/asio/io_service.hpp>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/post.hpp>
namespace ndn::tests {
@@ -42,7 +43,7 @@
BOOST_AUTO_TEST_CASE(DestructWithoutRun)
{
- boost::asio::io_service io;
+ boost::asio::io_context io;
auto nm = make_unique<NetworkMonitor>(io);
nm.reset();
BOOST_CHECK(true); // if we got this far, the test passed
@@ -50,16 +51,16 @@
BOOST_AUTO_TEST_CASE(DestructWhileEnumerating)
{
- boost::asio::io_service io;
+ boost::asio::io_context io;
auto nm = make_unique<NetworkMonitor>(io);
NM_REQUIRE_CAP(ENUM);
nm->onInterfaceAdded.connect([&] (const shared_ptr<const NetworkInterface>&) {
- io.post([&] { nm.reset(); });
+ boost::asio::post(io, [&] { nm.reset(); });
});
nm->onEnumerationCompleted.connect([&] {
// make sure the test case terminates even if we have zero interfaces
- io.post([&] { nm.reset(); });
+ boost::asio::post(io, [&] { nm.reset(); });
});
io.run();
diff --git a/tests/unit/security/validator-fixture.cpp b/tests/unit/security/validator-fixture.cpp
index 41497bf..ff198a3 100644
--- a/tests/unit/security/validator-fixture.cpp
+++ b/tests/unit/security/validator-fixture.cpp
@@ -24,6 +24,8 @@
#include "ndn-cxx/security/additional-description.hpp"
#include "ndn-cxx/util/signal/scoped-connection.hpp"
+#include <boost/asio/post.hpp>
+
namespace ndn::tests {
using namespace ndn::security;
@@ -47,7 +49,7 @@
{
signal::ScopedConnection conn = face.onSendInterest.connect([this] (const Interest& interest) {
if (processInterest) {
- m_io.post([=] { processInterest(interest); });
+ boost::asio::post(m_io, [=] { processInterest(interest); });
}
});
advanceClocks(s_mockPeriod, s_mockTimes);
@@ -69,8 +71,7 @@
.appendVersion());
SignatureInfo info;
- auto now = time::system_clock::now();
- info.setValidityPeriod(ValidityPeriod(now, now + 90_days));
+ info.setValidityPeriod(ValidityPeriod::makeRelative(0_s, 90_days));
AdditionalDescription description;
description.set("type", "sub-certificate");
diff --git a/tests/unit/security/validator-null.t.cpp b/tests/unit/security/validator-null.t.cpp
index ebae900..05dd270 100644
--- a/tests/unit/security/validator-null.t.cpp
+++ b/tests/unit/security/validator-null.t.cpp
@@ -39,8 +39,8 @@
ValidatorNull validator;
validator.validate(data,
- std::bind([] { BOOST_CHECK_MESSAGE(true, "Validation should succeed"); }),
- std::bind([] { BOOST_CHECK_MESSAGE(false, "Validation should not have failed"); }));
+ [] (auto&&...) { BOOST_CHECK_MESSAGE(true, "Validation should succeed"); },
+ [] (auto&&...) { BOOST_CHECK_MESSAGE(false, "Validation should not have failed"); });
}
BOOST_AUTO_TEST_CASE(ValidateInterest)
@@ -51,8 +51,8 @@
ValidatorNull validator;
validator.validate(interest,
- std::bind([] { BOOST_CHECK_MESSAGE(true, "Validation should succeed"); }),
- std::bind([] { BOOST_CHECK_MESSAGE(false, "Validation should not have failed"); }));
+ [] (auto&&...) { BOOST_CHECK_MESSAGE(true, "Validation should succeed"); },
+ [] (auto&&...) { BOOST_CHECK_MESSAGE(false, "Validation should not have failed"); });
}
BOOST_AUTO_TEST_SUITE_END() // TestValidatorNull
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);
}