tests: refactor common test infrastructure and fixtures
Change-Id: I597c11130eefa2cc2846ee6655c85dc04f2f22ef
diff --git a/tests/unit/util/dummy-client-face.t.cpp b/tests/unit/util/dummy-client-face.t.cpp
index acd6297..b823be2 100644
--- a/tests/unit/util/dummy-client-face.t.cpp
+++ b/tests/unit/util/dummy-client-face.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2020 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -21,9 +21,8 @@
#include "ndn-cxx/util/dummy-client-face.hpp"
-#include "tests/boost-test.hpp"
-#include "tests/make-interest-data.hpp"
-#include "tests/unit/identity-management-time-fixture.hpp"
+#include "tests/test-common.hpp"
+#include "tests/unit/io-key-chain-fixture.hpp"
namespace ndn {
namespace util {
@@ -32,7 +31,7 @@
using namespace ndn::tests;
BOOST_AUTO_TEST_SUITE(Util)
-BOOST_FIXTURE_TEST_SUITE(TestDummyClientFace, ndn::tests::IdentityManagementTimeFixture)
+BOOST_FIXTURE_TEST_SUITE(TestDummyClientFace, IoKeyChainFixture)
BOOST_AUTO_TEST_CASE(ProcessEventsOverride)
{
@@ -42,15 +41,15 @@
BOOST_CHECK_EQUAL(timeout, 200_ms);
};
- DummyClientFace face(io, {false, false, override});
+ DummyClientFace face(m_io, {false, false, override});
face.processEvents(200_ms);
BOOST_CHECK(isOverrideInvoked);
}
BOOST_AUTO_TEST_CASE(BroadcastLink)
{
- DummyClientFace face1(io, m_keyChain, DummyClientFace::Options{true, true});
- DummyClientFace face2(io, m_keyChain, DummyClientFace::Options{true, true});
+ DummyClientFace face1(m_io, m_keyChain, DummyClientFace::Options{true, true});
+ DummyClientFace face2(m_io, m_keyChain, DummyClientFace::Options{true, true});
face1.linkTo(face2);
int nFace1Interest = 0;
@@ -97,14 +96,14 @@
BOOST_AUTO_TEST_CASE(BroadcastLinkDestroy)
{
- DummyClientFace face1(io, m_keyChain, DummyClientFace::Options{true, true});
- DummyClientFace face2(io, m_keyChain, DummyClientFace::Options{true, true});
+ DummyClientFace face1(m_io, m_keyChain, DummyClientFace::Options{true, true});
+ DummyClientFace face2(m_io, m_keyChain, DummyClientFace::Options{true, true});
face1.linkTo(face2);
face2.unlink();
BOOST_CHECK(face1.m_bcastLink == nullptr);
- DummyClientFace face3(io, m_keyChain, DummyClientFace::Options{true, true});
+ DummyClientFace face3(m_io, m_keyChain, DummyClientFace::Options{true, true});
face1.linkTo(face2);
face3.linkTo(face1);
face2.unlink();
@@ -113,10 +112,10 @@
BOOST_AUTO_TEST_CASE(AlreadyLinkException)
{
- DummyClientFace face1(io, m_keyChain, DummyClientFace::Options{true, true});
- DummyClientFace face2(io, m_keyChain, DummyClientFace::Options{true, true});
- DummyClientFace face3(io, m_keyChain, DummyClientFace::Options{true, true});
- DummyClientFace face4(io, m_keyChain, DummyClientFace::Options{true, true});
+ DummyClientFace face1(m_io, m_keyChain, DummyClientFace::Options{true, true});
+ DummyClientFace face2(m_io, m_keyChain, DummyClientFace::Options{true, true});
+ DummyClientFace face3(m_io, m_keyChain, DummyClientFace::Options{true, true});
+ DummyClientFace face4(m_io, m_keyChain, DummyClientFace::Options{true, true});
face1.linkTo(face2);
face3.linkTo(face4);
diff --git a/tests/unit/util/io.t.cpp b/tests/unit/util/io.t.cpp
index 9340279..1ebaf61 100644
--- a/tests/unit/util/io.t.cpp
+++ b/tests/unit/util/io.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2019 Regents of the University of California.
+ * Copyright (c) 2013-2020 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -22,7 +22,7 @@
#include "ndn-cxx/util/io.hpp"
#include "tests/boost-test.hpp"
-#include "tests/identity-management-fixture.hpp"
+#include "tests/key-chain-fixture.hpp"
#include <boost/filesystem.hpp>
#include <boost/mpl/vector.hpp>
@@ -100,7 +100,7 @@
{
protected:
FileIoFixture()
- : filepath(boost::filesystem::path(UNIT_TEST_CONFIG_PATH) / "TestIo")
+ : filepath(boost::filesystem::path(UNIT_TESTS_TMPDIR) / "TestIo")
, filename(filepath.string())
{
boost::filesystem::create_directories(filepath.parent_path());
@@ -327,23 +327,23 @@
BOOST_AUTO_TEST_SUITE_END() // FileIo
class IdCertFixture : public FileIoFixture
- , public IdentityManagementFixture
+ , public KeyChainFixture
{
};
BOOST_FIXTURE_TEST_CASE(IdCert, IdCertFixture)
{
- auto identity = addIdentity("/TestIo/IdCert", RsaKeyParams());
+ auto identity = m_keyChain.createIdentity("/TestIo/IdCert", RsaKeyParams());
const auto& cert = identity.getDefaultKey().getDefaultCertificate();
io::save(cert, filename);
- auto readCert = io::load<security::v2::Certificate>(filename);
+ auto readCert = io::load<security::Certificate>(filename);
BOOST_REQUIRE(readCert != nullptr);
BOOST_CHECK_EQUAL(cert.getName(), readCert->getName());
this->writeFile<std::string>("");
- readCert = io::load<security::v2::Certificate>(filename);
+ readCert = io::load<security::Certificate>(filename);
BOOST_REQUIRE(readCert == nullptr);
}
diff --git a/tests/unit/util/logging.t.cpp b/tests/unit/util/logging.t.cpp
index 8bbc638..24ae88b 100644
--- a/tests/unit/util/logging.t.cpp
+++ b/tests/unit/util/logging.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2019 Regents of the University of California.
+ * Copyright (c) 2013-2020 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -23,7 +23,7 @@
#include "ndn-cxx/util/logger.hpp"
#include "tests/boost-test.hpp"
-#include "tests/unit/unit-test-time-fixture.hpp"
+#include "tests/unit/clock-fixture.hpp"
#if BOOST_VERSION >= 105900
#include <boost/test/tools/output_test_stream.hpp>
@@ -169,14 +169,14 @@
const time::microseconds LOG_SYSTIME(1468108800311239LL);
const std::string LOG_SYSTIME_STR("1468108800.311239");
-class LoggingFixture : public ndn::tests::UnitTestTimeFixture
+class LoggingFixture : public ndn::tests::ClockFixture
{
protected:
LoggingFixture()
: m_oldEnabledLevel(Logging::get().getLevels())
, m_oldDestination(Logging::get().getDestination())
{
- this->systemClock->setNow(LOG_SYSTIME);
+ m_systemClock->setNow(LOG_SYSTIME);
Logging::get().resetLevels();
Logging::setDestination(os);
}
diff --git a/tests/unit/util/notification-stream.t.cpp b/tests/unit/util/notification-stream.t.cpp
index ada10c5..2df3014 100644
--- a/tests/unit/util/notification-stream.t.cpp
+++ b/tests/unit/util/notification-stream.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018 Regents of the University of California,
+ * Copyright (c) 2014-2020 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,7 +29,7 @@
#include "ndn-cxx/util/dummy-client-face.hpp"
#include "tests/boost-test.hpp"
-#include "tests/unit/identity-management-time-fixture.hpp"
+#include "tests/unit/io-key-chain-fixture.hpp"
#include "tests/unit/util/simple-notification.hpp"
namespace ndn {
@@ -37,13 +37,14 @@
namespace tests {
BOOST_AUTO_TEST_SUITE(Util)
-BOOST_FIXTURE_TEST_SUITE(TestNotificationStream, ndn::tests::IdentityManagementTimeFixture)
+BOOST_FIXTURE_TEST_SUITE(TestNotificationStream, ndn::tests::IoKeyChainFixture)
BOOST_AUTO_TEST_CASE(Post)
{
- DummyClientFace face(io, m_keyChain);
- util::NotificationStream<SimpleNotification> notificationStream(face,
- "/localhost/nfd/NotificationStreamTest", m_keyChain);
+ DummyClientFace face(m_io, m_keyChain);
+ NotificationStream<SimpleNotification> notificationStream(face,
+ "/localhost/nfd/NotificationStreamTest",
+ m_keyChain);
SimpleNotification event1("msg1");
notificationStream.postNotification(event1);
diff --git a/tests/unit/util/notification-subscriber.t.cpp b/tests/unit/util/notification-subscriber.t.cpp
index e3b7aa9..d8f9dfd 100644
--- a/tests/unit/util/notification-subscriber.t.cpp
+++ b/tests/unit/util/notification-subscriber.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019 Regents of the University of California,
+ * Copyright (c) 2014-2020 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,9 +28,8 @@
#include "ndn-cxx/util/notification-subscriber.hpp"
#include "ndn-cxx/util/dummy-client-face.hpp"
-#include "tests/boost-test.hpp"
-#include "tests/make-interest-data.hpp"
-#include "tests/unit/identity-management-time-fixture.hpp"
+#include "tests/test-common.hpp"
+#include "tests/unit/io-key-chain-fixture.hpp"
#include "tests/unit/util/simple-notification.hpp"
namespace ndn {
@@ -39,12 +38,12 @@
using namespace ndn::tests;
-class NotificationSubscriberFixture : public IdentityManagementTimeFixture
+class NotificationSubscriberFixture : public IoKeyChainFixture
{
public:
NotificationSubscriberFixture()
- : streamPrefix("ndn:/NotificationSubscriberTest")
- , subscriberFace(io, m_keyChain)
+ : streamPrefix("/NotificationSubscriberTest")
+ , subscriberFace(m_io, m_keyChain)
, subscriber(subscriberFace, streamPrefix, 1_s)
, nextSendNotificationNo(0)
{
diff --git a/tests/unit/util/scheduler.t.cpp b/tests/unit/util/scheduler.t.cpp
index 021c1f0..1bd3860 100644
--- a/tests/unit/util/scheduler.t.cpp
+++ b/tests/unit/util/scheduler.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2019 Regents of the University of California.
+ * Copyright (c) 2013-2020 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -22,7 +22,7 @@
#include "ndn-cxx/util/scheduler.hpp"
#include "tests/boost-test.hpp"
-#include "tests/unit/unit-test-time-fixture.hpp"
+#include "tests/unit/io-fixture.hpp"
#include <boost/lexical_cast.hpp>
@@ -30,16 +30,10 @@
namespace scheduler {
namespace tests {
-class SchedulerFixture : public ndn::tests::UnitTestTimeFixture
+class SchedulerFixture : public ndn::tests::IoFixture
{
-public:
- SchedulerFixture()
- : scheduler(io)
- {
- }
-
-public:
- Scheduler scheduler;
+protected:
+ Scheduler scheduler{m_io};
};
BOOST_AUTO_TEST_SUITE(Util)
@@ -201,9 +195,8 @@
BOOST_AUTO_TEST_CASE(CancelAllWithScopedEventId) // Bug 3691
{
- Scheduler sched(io);
- ScopedEventId eid = sched.schedule(10_ms, []{});
- sched.cancelAllEvents();
+ ScopedEventId eid = scheduler.schedule(10_ms, []{});
+ scheduler.cancelAllEvents();
eid.cancel(); // should not crash
// avoid "test case [...] did not check any assertions" message from Boost.Test
diff --git a/tests/unit/util/segment-fetcher.t.cpp b/tests/unit/util/segment-fetcher.t.cpp
index 7f63db8..c58c1f9 100644
--- a/tests/unit/util/segment-fetcher.t.cpp
+++ b/tests/unit/util/segment-fetcher.t.cpp
@@ -25,10 +25,9 @@
#include "ndn-cxx/lp/nack.hpp"
#include "ndn-cxx/util/dummy-client-face.hpp"
-#include "tests/boost-test.hpp"
-#include "tests/make-interest-data.hpp"
+#include "tests/test-common.hpp"
#include "tests/unit/dummy-validator.hpp"
-#include "tests/unit/identity-management-time-fixture.hpp"
+#include "tests/unit/io-key-chain-fixture.hpp"
#include <set>
@@ -38,27 +37,20 @@
using namespace ndn::tests;
-class Fixture : public IdentityManagementTimeFixture
+class SegmentFetcherFixture : public IoKeyChainFixture
{
public:
- Fixture()
- : face(io, m_keyChain)
- {
- }
-
static shared_ptr<Data>
makeDataSegment(const Name& baseName, uint64_t segment, bool isFinal)
{
const uint8_t buffer[] = "Hello, world!";
-
- auto data = make_shared<Data>(Name(baseName).appendSegment(segment));
- data->setFreshnessPeriod(1_s);
+ auto data = makeData(Name(baseName).appendSegment(segment));
data->setContent(buffer, sizeof(buffer));
+ data->setFreshnessPeriod(1_s);
if (isFinal) {
data->setFinalBlock(data->getName()[-1]);
}
-
- return signData(data);
+ return data;
}
void
@@ -90,21 +82,20 @@
}
void
- nackLastInterest(lp::NackReason nackReason)
+ nackLastInterest(lp::NackReason reason)
{
const Interest& lastInterest = face.sentInterests.back();
- lp::Nack nack = makeNack(lastInterest, nackReason);
- face.receive(nack);
+ face.receive(makeNack(lastInterest, reason));
advanceClocks(10_ms);
}
void
connectSignals(const shared_ptr<SegmentFetcher>& fetcher)
{
- fetcher->onInOrderData.connect(bind(&Fixture::onInOrderData, this, _1));
- fetcher->onInOrderComplete.connect(bind(&Fixture::onInOrderComplete, this));
- fetcher->onComplete.connect(bind(&Fixture::onComplete, this, _1));
- fetcher->onError.connect(bind(&Fixture::onError, this, _1));
+ fetcher->onInOrderData.connect(bind(&SegmentFetcherFixture::onInOrderData, this, _1));
+ fetcher->onInOrderComplete.connect(bind(&SegmentFetcherFixture::onInOrderComplete, this));
+ fetcher->onComplete.connect(bind(&SegmentFetcherFixture::onComplete, this, _1));
+ fetcher->onError.connect(bind(&SegmentFetcherFixture::onError, this, _1));
fetcher->afterSegmentReceived.connect([this] (const auto&) { ++this->nAfterSegmentReceived; });
fetcher->afterSegmentValidated.connect([this] (const auto &) { ++this->nAfterSegmentValidated; });
@@ -133,7 +124,7 @@
uniqSegmentsSent.insert(interest.getName().get(-1).toSegment());
if (uniqSegmentsSent.size() == nSegments) {
- io.stop();
+ m_io.stop();
}
}
else {
@@ -154,7 +145,7 @@
}
public:
- DummyClientFace face;
+ DummyClientFace face{m_io, m_keyChain};
std::set<uint64_t> uniqSegmentsSent;
int nErrors = 0;
@@ -178,7 +169,7 @@
};
BOOST_AUTO_TEST_SUITE(Util)
-BOOST_FIXTURE_TEST_SUITE(TestSegmentFetcher, Fixture)
+BOOST_FIXTURE_TEST_SUITE(TestSegmentFetcher, SegmentFetcherFixture)
BOOST_AUTO_TEST_CASE(InvalidOptions)
{
@@ -318,7 +309,7 @@
shared_ptr<SegmentFetcher> fetcher = SegmentFetcher::start(face, Interest("/hello/world"),
acceptValidator);
- face.onSendInterest.connect(bind(&Fixture::onInterest, this, _1));
+ face.onSendInterest.connect(bind(&SegmentFetcherFixture::onInterest, this, _1));
connectSignals(fetcher);
face.processEvents(1_s);
@@ -341,7 +332,7 @@
sendNackInsteadOfDropping = false;
auto fetcher = SegmentFetcher::start(face, Interest("/hello/world"), acceptValidator, options);
- face.onSendInterest.connect(bind(&Fixture::onInterest, this, _1));
+ face.onSendInterest.connect(bind(&SegmentFetcherFixture::onInterest, this, _1));
connectSignals(fetcher);
face.processEvents(1_s);
@@ -366,7 +357,7 @@
shared_ptr<SegmentFetcher> fetcher = SegmentFetcher::start(face, Interest("/hello/world"),
acceptValidator);
- face.onSendInterest.connect(bind(&Fixture::onInterest, this, _1));
+ face.onSendInterest.connect(bind(&SegmentFetcherFixture::onInterest, this, _1));
connectSignals(fetcher);
face.processEvents(1_s);
@@ -390,7 +381,7 @@
defaultSegmentToSend = 47;
auto fetcher = SegmentFetcher::start(face, Interest("/hello/world"), acceptValidator, options);
- face.onSendInterest.connect(bind(&Fixture::onInterest, this, _1));
+ face.onSendInterest.connect(bind(&SegmentFetcherFixture::onInterest, this, _1));
connectSignals(fetcher);
face.processEvents(1_s);
@@ -635,7 +626,7 @@
shared_ptr<SegmentFetcher> fetcher = SegmentFetcher::start(face, Interest("/hello/world"),
acceptValidator);
- face.onSendInterest.connect(bind(&Fixture::onInterest, this, _1));
+ face.onSendInterest.connect(bind(&SegmentFetcherFixture::onInterest, this, _1));
connectSignals(fetcher);
face.processEvents(1_s);
@@ -660,7 +651,7 @@
shared_ptr<SegmentFetcher> fetcher = SegmentFetcher::start(face, Interest("/hello/world"),
acceptValidator);
- face.onSendInterest.connect(bind(&Fixture::onInterest, this, _1));
+ face.onSendInterest.connect(bind(&SegmentFetcherFixture::onInterest, this, _1));
connectSignals(fetcher);
face.processEvents(1_s);
@@ -680,7 +671,7 @@
segmentsToDropOrNack.push(0);
sendNackInsteadOfDropping = true;
nackReason = lp::NackReason::NO_ROUTE;
- face.onSendInterest.connect(bind(&Fixture::onInterest, this, _1));
+ face.onSendInterest.connect(bind(&SegmentFetcherFixture::onInterest, this, _1));
shared_ptr<SegmentFetcher> fetcher = SegmentFetcher::start(face, Interest("/hello/world"),
acceptValidator);
diff --git a/tests/unit/util/sqlite3-statement.t.cpp b/tests/unit/util/sqlite3-statement.t.cpp
index c5ee8b6..a78b077 100644
--- a/tests/unit/util/sqlite3-statement.t.cpp
+++ b/tests/unit/util/sqlite3-statement.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2020 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -31,13 +31,13 @@
namespace util {
namespace tests {
-class Sqlite3StatementTestFixture
+class Sqlite3DbFixture
{
public:
- Sqlite3StatementTestFixture()
- : m_path(boost::filesystem::path(UNIT_TEST_CONFIG_PATH))
+ Sqlite3DbFixture()
{
boost::filesystem::create_directories(m_path);
+
int result = sqlite3_open_v2((m_path / "sqlite3-statement.db").string().c_str(), &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
#ifdef NDN_CXX_DISABLE_SQLITE3_FS_LOCKING
@@ -52,21 +52,21 @@
}
}
- ~Sqlite3StatementTestFixture()
+ ~Sqlite3DbFixture()
{
sqlite3_close(db);
boost::filesystem::remove_all(m_path);
}
-private:
- boost::filesystem::path m_path;
+protected:
+ sqlite3* db = nullptr;
-public:
- sqlite3* db;
+private:
+ const boost::filesystem::path m_path{UNIT_TESTS_TMPDIR};
};
BOOST_AUTO_TEST_SUITE(Util)
-BOOST_FIXTURE_TEST_SUITE(TestSqlite3Statement, Sqlite3StatementTestFixture)
+BOOST_FIXTURE_TEST_SUITE(TestSqlite3Statement, Sqlite3DbFixture)
BOOST_AUTO_TEST_CASE(Basic)
{
diff --git a/tests/unit/util/time-unit-test-clock.t.cpp b/tests/unit/util/time-unit-test-clock.t.cpp
index b65c9f9..f1be623 100644
--- a/tests/unit/util/time-unit-test-clock.t.cpp
+++ b/tests/unit/util/time-unit-test-clock.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2019 Regents of the University of California.
+ * Copyright (c) 2013-2020 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -23,7 +23,7 @@
#include "ndn-cxx/util/scheduler.hpp"
#include "tests/boost-test.hpp"
-#include "tests/unit/unit-test-time-fixture.hpp"
+#include "tests/unit/io-fixture.hpp"
#include <boost/lexical_cast.hpp>
#include <thread>
@@ -32,7 +32,7 @@
namespace tests {
BOOST_AUTO_TEST_SUITE(Util)
-BOOST_FIXTURE_TEST_SUITE(TestTimeUnitTestClock, UnitTestTimeFixture)
+BOOST_FIXTURE_TEST_SUITE(TestTimeUnitTestClock, ClockFixture)
BOOST_AUTO_TEST_CASE(SystemClock)
{
@@ -43,11 +43,11 @@
BOOST_CHECK_EQUAL(time::system_clock::now().time_since_epoch(),
time::UnitTestClockTraits<time::system_clock>::getDefaultStartTime());
- steadyClock->advance(1_day);
+ m_steadyClock->advance(1_day);
BOOST_CHECK_EQUAL(time::system_clock::now().time_since_epoch(),
time::UnitTestClockTraits<time::system_clock>::getDefaultStartTime());
- systemClock->advance(1_day);
+ m_systemClock->advance(1_day);
BOOST_CHECK_GT(time::system_clock::now().time_since_epoch(),
time::UnitTestClockTraits<time::system_clock>::getDefaultStartTime());
@@ -55,7 +55,7 @@
time::fromUnixTimestamp(time::milliseconds(1390966967032LL));
BOOST_CHECK_GT(time::system_clock::now(), referenceTime);
- systemClock->setNow(referenceTime.time_since_epoch());
+ m_systemClock->setNow(referenceTime.time_since_epoch());
BOOST_CHECK_EQUAL(time::system_clock::now(), referenceTime);
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(time::system_clock::now()),
@@ -98,36 +98,36 @@
BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(),
time::steady_clock::duration::zero());
- systemClock->advance(36500_days);
+ m_systemClock->advance(36500_days);
BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(),
time::steady_clock::duration::zero());
- steadyClock->advance(100_ns);
+ m_steadyClock->advance(100_ns);
BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), 100_ns);
- steadyClock->advance(100_us);
+ m_steadyClock->advance(100_us);
BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), 100100_ns);
- steadyClock->setNow(1_ms);
+ m_steadyClock->setNow(1_ms);
BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), 1000000_ns);
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(time::steady_clock::now()),
"1000000 nanoseconds since unit test beginning");
}
-BOOST_AUTO_TEST_CASE(Scheduler)
+BOOST_FIXTURE_TEST_CASE(Scheduler, IoFixture)
{
- ndn::Scheduler scheduler(io);
+ ndn::Scheduler scheduler(m_io);
bool hasFired = false;
scheduler.schedule(100_s, [&] { hasFired = true; });
- io.poll();
+ m_io.poll();
BOOST_CHECK_EQUAL(hasFired, false);
- steadyClock->advance(100_s);
+ m_steadyClock->advance(100_s);
- io.poll();
+ m_io.poll();
BOOST_CHECK_EQUAL(hasFired, true);
}