util: add literal operators for duration types
Change-Id: I007fa61c80e535c6e4b12e85a32eeeee62fecc3c
Refs: #4468
diff --git a/tests/identity-management-fixture.cpp b/tests/identity-management-fixture.cpp
index ee80dd1..79d5eb2 100644
--- a/tests/identity-management-fixture.cpp
+++ b/tests/identity-management-fixture.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -87,8 +87,8 @@
request.setName(request.getKeyName().append("parent").appendVersion());
SignatureInfo info;
- info.setValidityPeriod(security::ValidityPeriod(time::system_clock::now(),
- time::system_clock::now() + time::days(7300)));
+ auto now = time::system_clock::now();
+ info.setValidityPeriod(security::ValidityPeriod(now, now + 7300_days));
v2::AdditionalDescription description;
description.set("type", "sub-certificate");
@@ -112,15 +112,15 @@
// set metainfo
certificate.setContentType(tlv::ContentType_Key);
- certificate.setFreshnessPeriod(time::hours(1));
+ certificate.setFreshnessPeriod(1_h);
// set content
certificate.setContent(key.getPublicKey().data(), key.getPublicKey().size());
// set signature-info
SignatureInfo info;
- info.setValidityPeriod(security::ValidityPeriod(time::system_clock::now(),
- time::system_clock::now() + time::days(10)));
+ auto now = time::system_clock::now();
+ info.setValidityPeriod(security::ValidityPeriod(now, now + 10_days));
m_keyChain.sign(certificate, signingByKey(key).setSignatureInfo(info));
return certificate;
diff --git a/tests/integrated/face.cpp b/tests/integrated/face.cpp
index a8492f1..2884ec6 100644
--- a/tests/integrated/face.cpp
+++ b/tests/integrated/face.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -156,7 +156,7 @@
std::this_thread::sleep_for(std::chrono::milliseconds(200)); // wait for FIB update to take effect
int nTimeouts = 0;
- this->face.expressInterest(Interest("/localhost/non-existent-should-timeout", time::seconds(1)),
+ this->face.expressInterest(Interest("/localhost/non-existent-should-timeout", 1_s),
[] (const Interest&, const Data&) { BOOST_ERROR("unexpected Data"); },
[] (const Interest&, const lp::Nack&) { BOOST_ERROR("unexpected Nack"); },
[&] (const Interest&) { ++nTimeouts; });
@@ -179,26 +179,26 @@
BOOST_FIXTURE_TEST_CASE_TEMPLATE(RegisterUnregisterPrefix, TransportType, Transports, FaceFixture<TransportType>)
{
- this->terminateAfter(time::seconds(4));
+ this->terminateAfter(4_s);
int nRegSuccess = 0, nUnregSuccess = 0;
auto id = this->face.registerPrefix("/Hello/World",
[&] (const Name&) { ++nRegSuccess; },
[] (const Name&, const std::string& msg) { BOOST_ERROR("unexpected register prefix failure: " << msg); });
- this->sched.scheduleEvent(time::seconds(1), [&nRegSuccess] {
+ this->sched.scheduleEvent(1_s, [&nRegSuccess] {
BOOST_CHECK_EQUAL(nRegSuccess, 1);
std::string output = executeCommand("nfdc route list | grep /Hello/World");
BOOST_CHECK(!output.empty());
});
- this->sched.scheduleEvent(time::seconds(2), [this, id, &nUnregSuccess] {
+ this->sched.scheduleEvent(2_s, [this, id, &nUnregSuccess] {
this->face.unregisterPrefix(id,
[&] { ++nUnregSuccess; },
[] (const std::string& msg) { BOOST_ERROR("unexpected unregister prefix failure: " << msg); });
});
- this->sched.scheduleEvent(time::seconds(3), [&nUnregSuccess] {
+ this->sched.scheduleEvent(3_s, [&nUnregSuccess] {
BOOST_CHECK_EQUAL(nUnregSuccess, 1);
// Boost.Test would fail if a child process exits with non-zero. http://stackoverflow.com/q/5325202
@@ -211,7 +211,7 @@
BOOST_FIXTURE_TEST_CASE_TEMPLATE(RegularFilter, TransportType, Transports, FaceFixture<TransportType>)
{
- this->terminateAfter(time::seconds(2));
+ this->terminateAfter(2_s);
int nInterests1 = 0, nRegSuccess1 = 0, nRegSuccess2 = 0;
this->face.setInterestFilter("/Hello/World",
@@ -223,13 +223,13 @@
[&] (const Name&) { ++nRegSuccess2; },
[] (const Name&, const std::string& msg) { BOOST_ERROR("unexpected register prefix failure: " << msg); });
- this->sched.scheduleEvent(time::milliseconds(500), [] {
+ this->sched.scheduleEvent(500_ms, [] {
std::string output = executeCommand("nfdc route list | grep /Hello/World");
BOOST_CHECK(!output.empty());
});
char interestOutcome;
- this->sendInterest(time::seconds(1), Interest("/Hello/World/regular", time::milliseconds(50)), interestOutcome);
+ this->sendInterest(1_s, Interest("/Hello/World/regular", 50_ms), interestOutcome);
this->face.processEvents();
BOOST_CHECK_EQUAL(interestOutcome, 'T');
@@ -240,7 +240,7 @@
BOOST_FIXTURE_TEST_CASE_TEMPLATE(RegexFilter, TransportType, Transports, FaceFixture<TransportType>)
{
- this->terminateAfter(time::seconds(2));
+ this->terminateAfter(2_s);
int nRegSuccess = 0;
std::set<Name> receivedInterests;
@@ -249,15 +249,15 @@
[&] (const Name&) { ++nRegSuccess; },
[] (const Name&, const std::string& msg) { BOOST_ERROR("unexpected register prefix failure: " << msg); });
- this->sched.scheduleEvent(time::milliseconds(700), [] {
+ this->sched.scheduleEvent(700_ms, [] {
std::string output = executeCommand("nfdc route list | grep /Hello/World");
BOOST_CHECK(!output.empty());
});
- this->sendInterest(time::milliseconds(200), Interest("/Hello/World/a", time::milliseconds(50)));
- this->sendInterest(time::milliseconds(300), Interest("/Hello/World/a/b", time::milliseconds(50)));
- this->sendInterest(time::milliseconds(400), Interest("/Hello/World/a/b/c", time::milliseconds(50)));
- this->sendInterest(time::milliseconds(500), Interest("/Hello/World/a/b/d", time::milliseconds(50)));
+ this->sendInterest(200_ms, Interest("/Hello/World/a", 50_ms));
+ this->sendInterest(300_ms, Interest("/Hello/World/a/b", 50_ms));
+ this->sendInterest(400_ms, Interest("/Hello/World/a/b/c", 50_ms));
+ this->sendInterest(500_ms, Interest("/Hello/World/a/b/d", 50_ms));
this->face.processEvents();
BOOST_CHECK_EQUAL(nRegSuccess, 1);
@@ -268,29 +268,29 @@
BOOST_FIXTURE_TEST_CASE_TEMPLATE(RegexFilterNoRegister, TransportType, Transports, FaceFixture<TransportType>)
{
- this->terminateAfter(time::seconds(2));
+ this->terminateAfter(2_s);
// no Interest shall arrive because prefix isn't registered in forwarder
this->face.setInterestFilter(InterestFilter("/Hello/World", "<><b><c>?"),
[&] (const InterestFilter&, const Interest& interest) { BOOST_ERROR("unexpected Interest"); });
- this->sched.scheduleEvent(time::milliseconds(700), [] {
+ this->sched.scheduleEvent(700_ms, [] {
// Boost.Test would fail if a child process exits with non-zero. http://stackoverflow.com/q/5325202
std::string output = executeCommand("nfdc route list | grep /Hello/World || true");
BOOST_CHECK(output.empty());
});
- this->sendInterest(time::milliseconds(200), Interest("/Hello/World/a", time::milliseconds(50)));
- this->sendInterest(time::milliseconds(300), Interest("/Hello/World/a/b", time::milliseconds(50)));
- this->sendInterest(time::milliseconds(400), Interest("/Hello/World/a/b/c", time::milliseconds(50)));
- this->sendInterest(time::milliseconds(500), Interest("/Hello/World/a/b/d", time::milliseconds(50)));
+ this->sendInterest(200_ms, Interest("/Hello/World/a", 50_ms));
+ this->sendInterest(300_ms, Interest("/Hello/World/a/b", 50_ms));
+ this->sendInterest(400_ms, Interest("/Hello/World/a/b/c", 50_ms));
+ this->sendInterest(500_ms, Interest("/Hello/World/a/b/d", 50_ms));
this->face.processEvents();
}
BOOST_FIXTURE_TEST_CASE_TEMPLATE(PutDataNack, TransportType, Transports, FaceFixture<TransportType>)
{
- this->terminateAfter(time::seconds(2));
+ this->terminateAfter(2_s);
this->face.setInterestFilter("/Hello/World",
[&] (const InterestFilter&, const Interest& interest) {
@@ -305,8 +305,8 @@
[] (const Name&, const std::string& msg) { BOOST_ERROR("unexpected register prefix failure: " << msg); });
char outcome1, outcome2;
- this->sendInterest(time::milliseconds(700), Interest("/Hello/World/data", time::milliseconds(50)), outcome1);
- this->sendInterest(time::milliseconds(800), Interest("/Hello/World/nack", time::milliseconds(50)), outcome2);
+ this->sendInterest(700_ms, Interest("/Hello/World/data", 50_ms), outcome1);
+ this->sendInterest(800_ms, Interest("/Hello/World/nack", 50_ms), outcome2);
this->face.processEvents();
BOOST_CHECK_EQUAL(outcome1, 'D');
@@ -315,7 +315,7 @@
BOOST_FIXTURE_TEST_CASE_TEMPLATE(OversizedData, TransportType, Transports, FaceFixture<TransportType>)
{
- this->terminateAfter(time::seconds(2));
+ this->terminateAfter(2_s);
this->face.setInterestFilter("/Hello/World",
[&] (const InterestFilter&, const Interest& interest) {
@@ -324,7 +324,7 @@
nullptr,
[] (const Name&, const std::string& msg) { BOOST_ERROR("unexpected register prefix failure: " << msg); });
- this->sendInterest(time::seconds(1), Interest("/Hello/World/oversized", time::milliseconds(50)));
+ this->sendInterest(1_s, Interest("/Hello/World/oversized", 50_ms));
BOOST_CHECK_THROW(this->face.processEvents(), Face::OversizedPacketError);
}
@@ -336,21 +336,21 @@
BOOST_AUTO_TEST_CASE(ShutdownWhileSendInProgress) // Bug #3136
{
this->face.expressInterest(Interest("/Hello/World"), nullptr, nullptr, nullptr);
- this->face.processEvents(time::seconds(1));
+ this->face.processEvents(1_s);
this->face.expressInterest(Interest("/Bye/World/1"), nullptr, nullptr, nullptr);
this->face.expressInterest(Interest("/Bye/World/2"), nullptr, nullptr, nullptr);
this->face.expressInterest(Interest("/Bye/World/3"), nullptr, nullptr, nullptr);
this->face.shutdown();
- this->face.processEvents(time::seconds(1)); // should not segfault
+ this->face.processEvents(1_s); // should not segfault
BOOST_CHECK(true);
}
BOOST_AUTO_TEST_CASE(LargeDelayBetweenFaceConstructorAndProcessEvents) // Bug #2742
{
std::this_thread::sleep_for(std::chrono::seconds(5)); // simulate setup workload
- this->face.processEvents(time::seconds(1)); // should not throw
+ this->face.processEvents(1_s); // should not throw
BOOST_CHECK(true);
}
diff --git a/tests/integrated/scheduler-benchmark.cpp b/tests/integrated/scheduler-benchmark.cpp
index 5cc191e..b861f04 100644
--- a/tests/integrated/scheduler-benchmark.cpp
+++ b/tests/integrated/scheduler-benchmark.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -48,7 +48,7 @@
auto d1 = timedExecute([&] {
for (size_t i = 0; i < nEvents; ++i) {
- eventIds[i] = sched.scheduleEvent(time::seconds(1), []{});
+ eventIds[i] = sched.scheduleEvent(1_s, []{});
}
});
@@ -71,11 +71,11 @@
size_t nExpired = 0;
// Events should expire at t1, but execution finishes at t2. The difference is the overhead.
- time::steady_clock::TimePoint t1 = time::steady_clock::now() + time::seconds(5);
+ time::steady_clock::TimePoint t1 = time::steady_clock::now() + 5_s;
time::steady_clock::TimePoint t2;
// +1ms ensures this extra event is executed last. In case the overhead is less than 1ms,
// it will be reported as 1ms.
- sched.scheduleEvent(t1 - time::steady_clock::now() + time::milliseconds(1), [&] {
+ sched.scheduleEvent(t1 - time::steady_clock::now() + 1_ms, [&] {
t2 = time::steady_clock::now();
BOOST_REQUIRE_EQUAL(nExpired, nEvents);
});
diff --git a/tests/unit-tests/data.t.cpp b/tests/unit-tests/data.t.cpp
index 91d46f9..e2054a5 100644
--- a/tests/unit-tests/data.t.cpp
+++ b/tests/unit-tests/data.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -161,7 +161,7 @@
Data d(Name("/local/ndn/prefix"));
d.setContentType(tlv::ContentType_Blob);
- d.setFreshnessPeriod(time::seconds(10));
+ d.setFreshnessPeriod(10_s);
d.setContent(CONTENT1, sizeof(CONTENT1));
Block signatureInfo(tlv::SignatureInfo);
@@ -212,7 +212,7 @@
BOOST_CHECK_EQUAL(d.getName().toUri(), "/local/ndn/prefix");
BOOST_CHECK_EQUAL(d.getContentType(), static_cast<uint32_t>(tlv::ContentType_Blob));
- BOOST_CHECK_EQUAL(d.getFreshnessPeriod(), time::seconds(10));
+ BOOST_CHECK_EQUAL(d.getFreshnessPeriod(), 10_s);
BOOST_CHECK_EQUAL(std::string(reinterpret_cast<const char*>(d.getContent().value()),
d.getContent().value_size()), "SUCCESS!");
BOOST_CHECK_EQUAL(d.getSignature().getType(), tlv::SignatureSha256WithRsa);
@@ -229,7 +229,7 @@
{
Data d(Name("/local/ndn/prefix"));
d.setContentType(tlv::ContentType_Blob);
- d.setFreshnessPeriod(time::seconds(10));
+ d.setFreshnessPeriod(10_s);
d.setContent(CONTENT1, sizeof(CONTENT1));
BOOST_CHECK_THROW(d.getFullName(), Data::Error); // FullName is unavailable without signing
@@ -245,7 +245,7 @@
// FullName should be cached, so value() pointer points to same memory location
BOOST_CHECK_EQUAL(fullName.get(-1).value(), d.getFullName().get(-1).value());
- d.setFreshnessPeriod(time::seconds(100)); // invalidates FullName
+ d.setFreshnessPeriod(100_s); // invalidates FullName
BOOST_CHECK_THROW(d.getFullName(), Data::Error);
Data d1(Block(DATA1, sizeof(DATA1)));
@@ -258,8 +258,6 @@
BOOST_AUTO_TEST_CASE(Equality)
{
- using namespace time;
-
Data a;
Data b;
BOOST_CHECK_EQUAL(a == b, true);
@@ -277,11 +275,11 @@
BOOST_CHECK_EQUAL(a == b, true);
BOOST_CHECK_EQUAL(a != b, false);
- a.setFreshnessPeriod(seconds(10));
+ a.setFreshnessPeriod(10_s);
BOOST_CHECK_EQUAL(a == b, false);
BOOST_CHECK_EQUAL(a != b, true);
- b.setFreshnessPeriod(seconds(10));
+ b.setFreshnessPeriod(10_s);
BOOST_CHECK_EQUAL(a == b, true);
BOOST_CHECK_EQUAL(a != b, false);
diff --git a/tests/unit-tests/face.t.cpp b/tests/unit-tests/face.t.cpp
index 3c903e9..e731c68 100644
--- a/tests/unit-tests/face.t.cpp
+++ b/tests/unit-tests/face.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -65,7 +65,7 @@
BOOST_AUTO_TEST_CASE(ExpressInterestData)
{
size_t nData = 0;
- face.expressInterest(Interest("/Hello/World", time::milliseconds(50)),
+ face.expressInterest(Interest("/Hello/World", 50_ms),
[&] (const Interest& i, const Data& d) {
BOOST_CHECK(i.getName().isPrefixOf(d.getName()));
BOOST_CHECK_EQUAL(i.getName(), "/Hello/World");
@@ -74,23 +74,23 @@
bind([] { BOOST_FAIL("Unexpected Nack"); }),
bind([] { BOOST_FAIL("Unexpected timeout"); }));
- advanceClocks(time::milliseconds(40));
+ advanceClocks(40_ms);
face.receive(*makeData("/Bye/World/a"));
face.receive(*makeData("/Hello/World/a"));
- advanceClocks(time::milliseconds(50), 2);
+ advanceClocks(50_ms, 2);
BOOST_CHECK_EQUAL(nData, 1);
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
BOOST_CHECK_EQUAL(face.sentData.size(), 0);
size_t nTimeouts = 0;
- face.expressInterest(Interest("/Hello/World/a/2", time::milliseconds(50)),
+ face.expressInterest(Interest("/Hello/World/a/2", 50_ms),
bind([]{}),
bind([]{}),
bind([&nTimeouts] { ++nTimeouts; }));
- advanceClocks(time::milliseconds(200), 5);
+ advanceClocks(200_ms, 5);
BOOST_CHECK_EQUAL(nTimeouts, 1);
}
@@ -98,25 +98,25 @@
{
size_t nData = 0;
- face.expressInterest(Interest("/Hello/World", time::milliseconds(50)),
+ face.expressInterest(Interest("/Hello/World", 50_ms),
[&] (const Interest& i, const Data& d) {
++nData;
},
bind([] { BOOST_FAIL("Unexpected Nack"); }),
bind([] { BOOST_FAIL("Unexpected timeout"); }));
- face.expressInterest(Interest("/Hello/World/a", time::milliseconds(50)),
+ face.expressInterest(Interest("/Hello/World/a", 50_ms),
[&] (const Interest& i, const Data& d) {
++nData;
},
bind([] { BOOST_FAIL("Unexpected Nack"); }),
bind([] { BOOST_FAIL("Unexpected timeout"); }));
- advanceClocks(time::milliseconds(40));
+ advanceClocks(40_ms);
face.receive(*makeData("/Hello/World/a/b"));
- advanceClocks(time::milliseconds(50), 2);
+ advanceClocks(50_ms, 2);
BOOST_CHECK_EQUAL(nData, 2);
BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
@@ -129,18 +129,18 @@
nullptr,
bind([] { BOOST_FAIL("Unexpected Nack"); }),
bind([] { BOOST_FAIL("Unexpected timeout"); }));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_NO_THROW(do {
face.receive(*makeData("/Hello/World/a"));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
} while (false));
}
BOOST_AUTO_TEST_CASE(ExpressInterestTimeout)
{
size_t nTimeouts = 0;
- face.expressInterest(Interest("/Hello/World", time::milliseconds(50)),
+ face.expressInterest(Interest("/Hello/World", 50_ms),
bind([] { BOOST_FAIL("Unexpected Data"); }),
bind([] { BOOST_FAIL("Unexpected Nack"); }),
[&nTimeouts] (const Interest& i) {
@@ -148,7 +148,7 @@
++nTimeouts;
});
- advanceClocks(time::milliseconds(200), 5);
+ advanceClocks(200_ms, 5);
BOOST_CHECK_EQUAL(nTimeouts, 1);
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
@@ -158,14 +158,14 @@
BOOST_AUTO_TEST_CASE(ExpressInterestEmptyTimeoutCallback)
{
- face.expressInterest(Interest("/Hello/World", time::milliseconds(50)),
+ face.expressInterest(Interest("/Hello/World", 50_ms),
bind([] { BOOST_FAIL("Unexpected Data"); }),
bind([] { BOOST_FAIL("Unexpected Nack"); }),
nullptr);
- advanceClocks(time::milliseconds(40));
+ advanceClocks(40_ms);
BOOST_CHECK_NO_THROW(do {
- advanceClocks(time::milliseconds(6), 2);
+ advanceClocks(6_ms, 2);
} while (false));
}
@@ -173,7 +173,7 @@
{
size_t nNacks = 0;
- Interest interest("/Hello/World", time::milliseconds(50));
+ Interest interest("/Hello/World", 50_ms);
face.expressInterest(interest,
bind([] { BOOST_FAIL("Unexpected Data"); }),
@@ -185,11 +185,11 @@
},
bind([] { BOOST_FAIL("Unexpected timeout"); }));
- advanceClocks(time::milliseconds(40));
+ advanceClocks(40_ms);
face.receive(makeNack(face.sentInterests.at(0), lp::NackReason::DUPLICATE));
- advanceClocks(time::milliseconds(50), 2);
+ advanceClocks(50_ms, 2);
BOOST_CHECK_EQUAL(nNacks, 1);
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
@@ -199,7 +199,7 @@
{
size_t nNacks = 0;
- Interest interest("/Hello/World", time::milliseconds(50));
+ Interest interest("/Hello/World", 50_ms);
interest.setNonce(1);
face.expressInterest(interest,
@@ -217,11 +217,11 @@
},
bind([] { BOOST_FAIL("Unexpected timeout"); }));
- advanceClocks(time::milliseconds(40));
+ advanceClocks(40_ms);
face.receive(makeNack(face.sentInterests.at(1), lp::NackReason::DUPLICATE));
- advanceClocks(time::milliseconds(50), 2);
+ advanceClocks(50_ms, 2);
BOOST_CHECK_EQUAL(nNacks, 2);
BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
@@ -233,28 +233,28 @@
bind([] { BOOST_FAIL("Unexpected Data"); }),
nullptr,
bind([] { BOOST_FAIL("Unexpected timeout"); }));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_NO_THROW(do {
face.receive(makeNack(face.sentInterests.at(0), lp::NackReason::DUPLICATE));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
} while (false));
}
BOOST_AUTO_TEST_CASE(RemovePendingInterest)
{
const PendingInterestId* interestId =
- face.expressInterest(Interest("/Hello/World", time::milliseconds(50)),
+ face.expressInterest(Interest("/Hello/World", 50_ms),
bind([] { BOOST_FAIL("Unexpected data"); }),
bind([] { BOOST_FAIL("Unexpected nack"); }),
bind([] { BOOST_FAIL("Unexpected timeout"); }));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.removePendingInterest(interestId);
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeData("/Hello/World/%21"));
- advanceClocks(time::milliseconds(200), 5);
+ advanceClocks(200_ms, 5);
// avoid "test case [...] did not check any assertions" message from Boost.Test
BOOST_CHECK(true);
@@ -262,38 +262,38 @@
BOOST_AUTO_TEST_CASE(RemoveAllPendingInterests)
{
- face.expressInterest(Interest("/Hello/World/0", time::milliseconds(50)),
+ face.expressInterest(Interest("/Hello/World/0", 50_ms),
bind([] { BOOST_FAIL("Unexpected data"); }),
bind([] { BOOST_FAIL("Unexpected nack"); }),
bind([] { BOOST_FAIL("Unexpected timeout"); }));
- face.expressInterest(Interest("/Hello/World/1", time::milliseconds(50)),
+ face.expressInterest(Interest("/Hello/World/1", 50_ms),
bind([] { BOOST_FAIL("Unexpected data"); }),
bind([] { BOOST_FAIL("Unexpected nack"); }),
bind([] { BOOST_FAIL("Unexpected timeout"); }));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.removeAllPendingInterests();
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_CHECK_EQUAL(face.getNPendingInterests(), 0);
face.receive(*makeData("/Hello/World/0"));
face.receive(*makeData("/Hello/World/1"));
- advanceClocks(time::milliseconds(200), 5);
+ advanceClocks(200_ms, 5);
}
BOOST_AUTO_TEST_CASE(DestructionWithoutCancellingPendingInterests) // Bug #2518
{
{
DummyClientFace face2(io, m_keyChain);
- face2.expressInterest(Interest("/Hello/World", time::milliseconds(50)),
+ face2.expressInterest(Interest("/Hello/World", 50_ms),
nullptr, nullptr, nullptr);
- advanceClocks(time::milliseconds(50), 2);
+ advanceClocks(50_ms, 2);
}
- advanceClocks(time::milliseconds(50), 2); // should not crash
+ advanceClocks(50_ms, 2); // should not crash
// avoid "test case [...] did not check any assertions" message from Boost.Test
BOOST_CHECK(true);
@@ -317,7 +317,7 @@
data.setTag(make_shared<lp::CongestionMarkTag>(1));
face.put(data);
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_REQUIRE_EQUAL(face.sentData.size(), 2);
BOOST_CHECK(face.sentData[0].getTag<lp::CachePolicyTag>() == nullptr);
BOOST_CHECK(face.sentData[0].getTag<lp::CongestionMarkTag>() == nullptr);
@@ -342,13 +342,13 @@
bind([&] { hasData = true; }),
bind([] { BOOST_FAIL("Unexpected nack"); }),
bind([] { BOOST_FAIL("Unexpected timeout"); }));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(hasInterest1, true); // Interest looped back
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1); // Interest sent to forwarder
BOOST_CHECK_EQUAL(hasData, false); // waiting for Data
face.put(*makeData("/A/B")); // first InterestFilter responds with Data
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(hasData, true);
BOOST_CHECK_EQUAL(face.sentData.size(), 0); // do not spill Data to forwarder
}
@@ -363,10 +363,10 @@
face.put(*makeData("/A/B"));
}));
face.setInterestFilter("/", bind([]{}));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeInterest("/A"));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_CHECK(hasInterest1);
BOOST_CHECK_EQUAL(face.sentData.size(), 1);
BOOST_CHECK_EQUAL(face.sentData.at(0).getName(), "/A/B");
@@ -378,20 +378,20 @@
BOOST_AUTO_TEST_CASE(PutNack)
{
face.setInterestFilter("/", bind([]{})); // register one Interest destination so that face can accept Nacks
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_CHECK_EQUAL(face.sentNacks.size(), 0);
face.put(makeNack("/unsolicited", 18645250, lp::NackReason::NO_ROUTE));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_CHECK_EQUAL(face.sentNacks.size(), 0); // unsolicited Nack would not be sent
face.receive(*makeInterest("/Hello/World", 14247162));
face.receive(*makeInterest("/another/prefix", 92203002));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.put(makeNack("/Hello/World", 14247162, lp::NackReason::DUPLICATE));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_REQUIRE_EQUAL(face.sentNacks.size(), 1);
BOOST_CHECK_EQUAL(face.sentNacks[0].getReason(), lp::NackReason::DUPLICATE);
BOOST_CHECK(face.sentNacks[0].getTag<lp::CongestionMarkTag>() == nullptr);
@@ -399,7 +399,7 @@
auto nack = makeNack("/another/prefix", 92203002, lp::NackReason::NO_ROUTE);
nack.setTag(make_shared<lp::CongestionMarkTag>(1));
face.put(nack);
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_REQUIRE_EQUAL(face.sentNacks.size(), 2);
BOOST_CHECK_EQUAL(face.sentNacks[1].getReason(), lp::NackReason::NO_ROUTE);
BOOST_CHECK(face.sentNacks[1].getTag<lp::CongestionMarkTag>() != nullptr);
@@ -415,10 +415,10 @@
face.put(makeNack(interest, lp::NackReason::CONGESTION));
});
face.setInterestFilter("/", bind([&] { hasInterest2 = true; }));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeInterest("/A", 14333271));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_CHECK(hasInterest1);
BOOST_CHECK(hasInterest2);
@@ -426,7 +426,7 @@
BOOST_CHECK_EQUAL(face.sentNacks.size(), 0);
face.put(makeNack("/A", 14333271, lp::NackReason::NO_ROUTE)); // Nack from second destination
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_CHECK_EQUAL(face.sentNacks.size(), 1); // sending Nack after both destinations Nacked
BOOST_CHECK_EQUAL(face.sentNacks.at(0).getReason(), lp::NackReason::CONGESTION); // least severe reason
@@ -454,13 +454,13 @@
BOOST_CHECK_EQUAL(nack.getReason(), lp::NackReason::CONGESTION);
},
bind([] { BOOST_FAIL("Unexpected timeout"); }));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(hasInterest1, true); // Interest looped back
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1); // Interest sent to forwarder
BOOST_CHECK_EQUAL(hasNack, false); // waiting for Nack from forwarder
face.receive(makeNack("/A", 28395852, lp::NackReason::NO_ROUTE));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(hasNack, true);
}
@@ -473,46 +473,46 @@
bind([&nInterests] { ++nInterests; }),
bind([&nRegs] { ++nRegs; }),
bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nRegs, 1);
BOOST_CHECK_EQUAL(nInterests, 0);
face.receive(Interest("/Hello/World/%21"));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nRegs, 1);
BOOST_CHECK_EQUAL(nInterests, 1);
face.receive(Interest("/Bye/World/%21"));
- advanceClocks(time::milliseconds(10000), 10);
+ advanceClocks(10000_ms, 10);
BOOST_CHECK_EQUAL(nInterests, 1);
face.receive(Interest("/Hello/World/%21/2"));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nInterests, 2);
// removing filter
face.unsetInterestFilter(regPrefixId);
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
face.receive(Interest("/Hello/World/%21/3"));
BOOST_CHECK_EQUAL(nInterests, 2);
face.unsetInterestFilter(static_cast<const RegisteredPrefixId*>(nullptr));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
face.unsetInterestFilter(static_cast<const InterestFilterId*>(nullptr));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
}
BOOST_AUTO_TEST_CASE(SetInterestFilterEmptyInterestCallback)
{
face.setInterestFilter("/A", nullptr);
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_NO_THROW(do {
face.receive(*makeInterest("/A/1"));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
} while (false));
}
@@ -523,34 +523,34 @@
face.setInterestFilter("/Hello/World",
bind([&nInterests] { ++nInterests; }),
bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nInterests, 0);
face.receive(Interest("/Hello/World/%21"));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nInterests, 1);
face.receive(Interest("/Bye/World/%21"));
- advanceClocks(time::milliseconds(10000), 10);
+ advanceClocks(10000_ms, 10);
BOOST_CHECK_EQUAL(nInterests, 1);
face.receive(Interest("/Hello/World/%21/2"));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nInterests, 2);
// removing filter
face.unsetInterestFilter(regPrefixId);
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
face.receive(Interest("/Hello/World/%21/3"));
BOOST_CHECK_EQUAL(nInterests, 2);
face.unsetInterestFilter(static_cast<const RegisteredPrefixId*>(nullptr));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
face.unsetInterestFilter(static_cast<const InterestFilterId*>(nullptr));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
}
BOOST_FIXTURE_TEST_CASE(SetInterestFilterFail, FacesNoRegistrationReplyFixture)
@@ -562,10 +562,10 @@
bind([] { BOOST_FAIL("Unexpected success of setInterestFilter"); }),
bind([&nRegFailed] { ++nRegFailed; }));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nRegFailed, 0);
- advanceClocks(time::milliseconds(2000), 5);
+ advanceClocks(2000_ms, 5);
BOOST_CHECK_EQUAL(nRegFailed, 1);
}
@@ -577,10 +577,10 @@
bind([] { BOOST_FAIL("Unexpected Interest"); }),
bind([&nRegFailed] { ++nRegFailed; }));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nRegFailed, 0);
- advanceClocks(time::milliseconds(2000), 5);
+ advanceClocks(2000_ms, 5);
BOOST_CHECK_EQUAL(nRegFailed, 1);
}
@@ -592,7 +592,7 @@
bind([&nRegSuccesses] { ++nRegSuccesses; }),
bind([] { BOOST_FAIL("Unexpected registerPrefix failure"); }));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nRegSuccesses, 1);
size_t nUnregSuccesses = 0;
@@ -600,7 +600,7 @@
bind([&nUnregSuccesses] { ++nUnregSuccesses; }),
bind([] { BOOST_FAIL("Unexpected unregisterPrefix failure"); }));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nUnregSuccesses, 1);
}
@@ -612,7 +612,7 @@
bind([] { BOOST_FAIL("Unexpected registerPrefix success"); }),
bind([&nRegFailures] { ++nRegFailures; }));
- advanceClocks(time::milliseconds(5000), 20);
+ advanceClocks(5000_ms, 20);
BOOST_CHECK_EQUAL(nRegFailures, 1);
}
@@ -636,10 +636,10 @@
nullptr,
bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
face.receive(Interest("/Hello/World/%21"));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nInInterests1, 1);
BOOST_CHECK_EQUAL(nInInterests2, 1);
@@ -655,7 +655,7 @@
nullptr,
bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
BOOST_REQUIRE_THROW(face.receive(Interest("/Hello/World/XXX/b/c")), InterestFilter::Error);
}
@@ -668,7 +668,7 @@
nullptr,
bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
face.receive(Interest("/Hello/World/a")); // shouldn't match
BOOST_CHECK_EQUAL(nInInterests, 0);
@@ -694,7 +694,7 @@
bind([&nRegSuccesses] { ++nRegSuccesses; }),
bind([] { BOOST_FAIL("Unexpected setInterestFilter failure"); }));
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
BOOST_CHECK_EQUAL(nRegSuccesses, 1);
face.receive(Interest("/Hello/World/a")); // shouldn't match
diff --git a/tests/unit-tests/ims/in-memory-storage-persistent.t.cpp b/tests/unit-tests/ims/in-memory-storage-persistent.t.cpp
index 9be6430..1ae637d 100644
--- a/tests/unit-tests/ims/in-memory-storage-persistent.t.cpp
+++ b/tests/unit-tests/ims/in-memory-storage-persistent.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -48,7 +48,7 @@
convert << i;
Name name("/" + convert.str());
shared_ptr<Data> data = makeData(name);
- data->setFreshnessPeriod(time::milliseconds(5000));
+ data->setFreshnessPeriod(5000_ms);
signData(data);
ims.insert(*data);
}
diff --git a/tests/unit-tests/ims/in-memory-storage.t.cpp b/tests/unit-tests/ims/in-memory-storage.t.cpp
index b493001..5a731b1 100644
--- a/tests/unit-tests/ims/in-memory-storage.t.cpp
+++ b/tests/unit-tests/ims/in-memory-storage.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -66,14 +66,14 @@
uint32_t content1 = 1;
shared_ptr<Data> data1 = makeData(name);
- data1->setFreshnessPeriod(time::milliseconds(99999));
+ data1->setFreshnessPeriod(99999_ms);
data1->setContent(reinterpret_cast<const uint8_t*>(&content1), sizeof(content1));
signData(data1);
ims.insert(*data1);
uint32_t content2 = 2;
shared_ptr<Data> data2 = makeData(name);
- data2->setFreshnessPeriod(time::milliseconds(99999));
+ data2->setFreshnessPeriod(99999_ms);
data2->setContent(reinterpret_cast<const uint8_t*>(&content2), sizeof(content2));
signData(data2);
ims.insert(*data2);
@@ -212,14 +212,14 @@
uint32_t content1 = 1;
shared_ptr<Data> data1 = makeData(name);
- data1->setFreshnessPeriod(time::milliseconds(99999));
+ data1->setFreshnessPeriod(99999_ms);
data1->setContent(reinterpret_cast<const uint8_t*>(&content1), sizeof(content1));
signData(data1);
ims.insert(*data1);
uint32_t content2 = 2;
shared_ptr<Data> data2 = makeData(name);
- data2->setFreshnessPeriod(time::milliseconds(99999));
+ data2->setFreshnessPeriod(99999_ms);
data2->setContent(reinterpret_cast<const uint8_t*>(&content2), sizeof(content2));
signData(data2);
ims.insert(*data2);
@@ -659,7 +659,7 @@
convert << i;
Name name("/" + convert.str());
shared_ptr<Data> data = makeData(name);
- data->setFreshnessPeriod(time::milliseconds(5000));
+ data->setFreshnessPeriod(5000_ms);
signData(data);
ims.insert(*data);
}
@@ -706,7 +706,7 @@
const time::milliseconds& freshWindow = InMemoryStorage::INFINITE_WINDOW)
{
shared_ptr<Data> data = makeData(name);
- data->setFreshnessPeriod(time::milliseconds(99999));
+ data->setFreshnessPeriod(99999_ms);
data->setContent(reinterpret_cast<const uint8_t*>(&id), sizeof(id));
signData(data);
@@ -978,10 +978,10 @@
BOOST_AUTO_TEST_CASE(MustBeFresh)
{
- Name data1Name = insert(1, "ndn:/A/1", time::milliseconds(500));
- insert(2, "ndn:/A/2", time::milliseconds(2500));
- insert(3, "ndn:/A/3", time::milliseconds(3500));
- insert(4, "ndn:/A/4", time::milliseconds(1500));
+ Name data1Name = insert(1, "ndn:/A/1", 500_ms);
+ insert(2, "ndn:/A/2", 2500_ms);
+ insert(3, "ndn:/A/3", 3500_ms);
+ insert(4, "ndn:/A/4", 1500_ms);
// @0s, all Data are fresh
startInterest("ndn:/A/1")
@@ -1002,7 +1002,7 @@
.setChildSelector(1);
BOOST_CHECK_EQUAL(find(), 4);
- advanceClocks(time::milliseconds(1000));
+ advanceClocks(1000_ms);
// @1s, /A/1 is stale
startInterest("ndn:/A/1")
.setMustBeFresh(true);
@@ -1025,7 +1025,7 @@
.setChildSelector(0);
BOOST_CHECK_EQUAL(find(), 1);
- advanceClocks(time::milliseconds(1000));
+ advanceClocks(1000_ms);
// @2s, /A/1 and /A/4 are stale
startInterest("ndn:/A")
.setMustBeFresh(true)
@@ -1036,7 +1036,7 @@
.setChildSelector(1);
BOOST_CHECK_EQUAL(find(), 4);
- advanceClocks(time::milliseconds(2000));
+ advanceClocks(2000_ms);
// @4s, all Data are stale
startInterest("ndn:/A")
.setMustBeFresh(true)
diff --git a/tests/unit-tests/interest-filter.t.cpp b/tests/unit-tests/interest-filter.t.cpp
index 8277c23..157fa05 100644
--- a/tests/unit-tests/interest-filter.t.cpp
+++ b/tests/unit-tests/interest-filter.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -57,7 +57,7 @@
util::DummyClientFace face;
face.setInterestFilter(InterestFilter("/Hello/World", "<><b><c>?"),
[] (const Name&, const Interest&) { BOOST_ERROR("unexpected Interest"); });
- face.processEvents(time::milliseconds(1));
+ face.processEvents(1_ms);
BOOST_CHECK_THROW(face.receive(Interest("/Hello/World/a/b/c")), InterestFilter::Error);
}
diff --git a/tests/unit-tests/interest.t.cpp b/tests/unit-tests/interest.t.cpp
index 7c5d0f0..c1dc23d 100644
--- a/tests/unit-tests/interest.t.cpp
+++ b/tests/unit-tests/interest.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -93,7 +93,7 @@
i1.setName("/local/ndn/prefix");
i1.setMinSuffixComponents(1);
i1.setNonce(1);
- i1.setInterestLifetime(time::milliseconds(1000));
+ i1.setInterestLifetime(1000_ms);
i1.setForwardingHint({{1, "/A"}});
Block wire1 = i1.wireEncode();
BOOST_CHECK_EQUAL_COLLECTIONS(wire1.begin(), wire1.end(), WIRE, WIRE + sizeof(WIRE));
@@ -102,7 +102,7 @@
BOOST_CHECK_EQUAL(i2.getName(), "/local/ndn/prefix");
BOOST_CHECK_EQUAL(i2.getMinSuffixComponents(), 1);
BOOST_CHECK_EQUAL(i2.getNonce(), 1);
- BOOST_CHECK_EQUAL(i2.getInterestLifetime(), time::milliseconds(1000));
+ BOOST_CHECK_EQUAL(i2.getInterestLifetime(), 1000_ms);
BOOST_CHECK_EQUAL(i2.getForwardingHint(), DelegationList({{1, "/A"}}));
BOOST_CHECK_EQUAL(i1, i2);
@@ -114,11 +114,11 @@
i1.setName("/test");
i1.setMinSuffixComponents(100);
i1.setNonce(10);
- i1.setInterestLifetime(time::seconds(10));
+ i1.setInterestLifetime(10_s);
Interest i2(i1.wireEncode());
BOOST_CHECK_EQUAL(i2.getName().toUri(), "/test");
- BOOST_CHECK_EQUAL(i2.getInterestLifetime(), time::seconds(10));
+ BOOST_CHECK_EQUAL(i2.getInterestLifetime(), 10_s);
BOOST_CHECK_EQUAL(i2.getMinSuffixComponents(), 100);
BOOST_CHECK_EQUAL(i2.getNonce(), 10);
@@ -254,7 +254,7 @@
.setPublisherPublicKeyLocator(KeyLocator("/B"))
.setExclude(Exclude().excludeAfter(name::Component("J")))
.setNonce(10)
- .setInterestLifetime(time::seconds(5))
+ .setInterestLifetime(5_s)
.setForwardingHint({{1, "/H"}});
Interest other;
@@ -272,7 +272,7 @@
other.setNonce(200);
BOOST_CHECK_EQUAL(interest.matchesInterest(other), true);
- other.setInterestLifetime(time::hours(5));
+ other.setInterestLifetime(5_h);
BOOST_CHECK_EQUAL(interest.matchesInterest(other), true);
}
@@ -334,17 +334,17 @@
BOOST_AUTO_TEST_CASE(SetInterestLifetime)
{
BOOST_CHECK_THROW(Interest("/A", time::milliseconds(-1)), std::invalid_argument);
- BOOST_CHECK_NO_THROW(Interest("/A", time::milliseconds(0)));
+ BOOST_CHECK_NO_THROW(Interest("/A", 0_ms));
Interest i("/local/ndn/prefix");
i.setNonce(1);
BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME);
BOOST_CHECK_THROW(i.setInterestLifetime(time::milliseconds(-1)), std::invalid_argument);
BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME);
- i.setInterestLifetime(time::milliseconds(0));
- BOOST_CHECK_EQUAL(i.getInterestLifetime(), time::milliseconds(0));
- i.setInterestLifetime(time::milliseconds(1));
- BOOST_CHECK_EQUAL(i.getInterestLifetime(), time::milliseconds(1));
+ i.setInterestLifetime(0_ms);
+ BOOST_CHECK_EQUAL(i.getInterestLifetime(), 0_ms);
+ i.setInterestLifetime(1_ms);
+ BOOST_CHECK_EQUAL(i.getInterestLifetime(), 1_ms);
}
BOOST_AUTO_TEST_CASE(ModifyForwardingHint)
@@ -405,11 +405,11 @@
BOOST_CHECK_EQUAL(a != b, false);
// compare InterestLifetime
- a.setInterestLifetime(time::seconds(10));
+ a.setInterestLifetime(10_s);
BOOST_CHECK_EQUAL(a == b, false);
BOOST_CHECK_EQUAL(a != b, true);
- b.setInterestLifetime(time::seconds(10));
+ b.setInterestLifetime(10_s);
BOOST_CHECK_EQUAL(a == b, true);
BOOST_CHECK_EQUAL(a != b, false);
diff --git a/tests/unit-tests/meta-info.t.cpp b/tests/unit-tests/meta-info.t.cpp
index bbd3fef..43935e3 100644
--- a/tests/unit-tests/meta-info.t.cpp
+++ b/tests/unit-tests/meta-info.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -41,7 +41,7 @@
{
MetaInfo meta;
meta.setType(tlv::ContentType_Blob);
- meta.setFreshnessPeriod(time::seconds(10));
+ meta.setFreshnessPeriod(10_s);
BOOST_REQUIRE_NO_THROW(meta.wireEncode());
BOOST_REQUIRE_EQUAL_COLLECTIONS(MetaInfo1, MetaInfo1+sizeof(MetaInfo1),
@@ -62,38 +62,36 @@
{
MetaInfo meta(Block(MetaInfo1, sizeof(MetaInfo1)));
BOOST_CHECK_EQUAL(meta.getType(), static_cast<uint32_t>(tlv::ContentType_Blob));
- BOOST_CHECK_EQUAL(meta.getFreshnessPeriod(), time::seconds(10));
+ BOOST_CHECK_EQUAL(meta.getFreshnessPeriod(), 10_s);
BOOST_CHECK_EQUAL(meta.getFinalBlockId(), name::Component());
meta.wireDecode(Block(MetaInfo2, sizeof(MetaInfo2)));
BOOST_CHECK_EQUAL(meta.getType(), static_cast<uint32_t>(tlv::ContentType_Blob));
- BOOST_CHECK_EQUAL(meta.getFreshnessPeriod(), time::seconds(10));
+ BOOST_CHECK_EQUAL(meta.getFreshnessPeriod(), 10_s);
BOOST_CHECK_EQUAL(meta.getFinalBlockId(), name::Component("hello,world!"));
meta.wireDecode(Block(MetaInfo3, sizeof(MetaInfo3)));
BOOST_CHECK_EQUAL(meta.getType(), static_cast<uint32_t>(tlv::ContentType_Link));
- BOOST_CHECK_EQUAL(meta.getFreshnessPeriod(), time::seconds(10));
+ BOOST_CHECK_EQUAL(meta.getFreshnessPeriod(), 10_s);
BOOST_CHECK_EQUAL(meta.getFinalBlockId(), name::Component("hello,world!"));
}
BOOST_AUTO_TEST_CASE(EqualityChecks)
{
- using namespace time;
-
MetaInfo a;
MetaInfo b;
BOOST_CHECK_EQUAL(a == b, true);
BOOST_CHECK_EQUAL(a != b, false);
- a.setFreshnessPeriod(seconds(10));
+ a.setFreshnessPeriod(10_s);
BOOST_CHECK_EQUAL(a == b, false);
BOOST_CHECK_EQUAL(a != b, true);
- b.setFreshnessPeriod(milliseconds(90000));
+ b.setFreshnessPeriod(90_s);
BOOST_CHECK_EQUAL(a == b, false);
BOOST_CHECK_EQUAL(a != b, true);
- b.setFreshnessPeriod(milliseconds(10000));
+ b.setFreshnessPeriod(10_s);
BOOST_CHECK_EQUAL(a == b, true);
BOOST_CHECK_EQUAL(a != b, false);
@@ -110,7 +108,7 @@
{
MetaInfo info1;
info1.setType(196);
- info1.setFreshnessPeriod(time::milliseconds(3600));
+ info1.setFreshnessPeriod(3600_ms);
info1.setFinalBlockId(name::Component("/att/final"));
uint32_t ints[5] = {128, 129, 130, 131, 132};
@@ -210,7 +208,7 @@
BOOST_CHECK_EQUAL_COLLECTIONS(info.wireEncode().begin(), info.wireEncode().end(),
expectedDefault, expectedDefault + sizeof(expectedDefault));
- info.setFreshnessPeriod(time::milliseconds(1000));
+ info.setFreshnessPeriod(1000_ms);
BOOST_CHECK_EQUAL_COLLECTIONS(info.wireEncode().begin(), info.wireEncode().end(),
expected1000ms, expected1000ms + sizeof(expected1000ms));
@@ -232,12 +230,12 @@
Block input2000msBlock(input2000ms, sizeof(input2000ms));
BOOST_CHECK_NO_THROW(info.wireDecode(input2000msBlock));
- BOOST_CHECK_EQUAL(info.getFreshnessPeriod(), time::milliseconds(2000));
+ BOOST_CHECK_EQUAL(info.getFreshnessPeriod(), 2000_ms);
- BOOST_CHECK_NO_THROW(info.setFreshnessPeriod(time::milliseconds(10000)));
- BOOST_CHECK_EQUAL(info.getFreshnessPeriod(), time::milliseconds(10000));
+ BOOST_CHECK_NO_THROW(info.setFreshnessPeriod(10000_ms));
+ BOOST_CHECK_EQUAL(info.getFreshnessPeriod(), 10000_ms);
BOOST_CHECK_THROW(info.setFreshnessPeriod(time::milliseconds(-1)), std::invalid_argument);
- BOOST_CHECK_EQUAL(info.getFreshnessPeriod(), time::milliseconds(10000));
+ BOOST_CHECK_EQUAL(info.getFreshnessPeriod(), 10000_ms);
}
BOOST_AUTO_TEST_SUITE_END() // TestMetaInfo
diff --git a/tests/unit-tests/mgmt/dispatcher.t.cpp b/tests/unit-tests/mgmt/dispatcher.t.cpp
index 535e8bd..9f8d34d 100644
--- a/tests/unit-tests/mgmt/dispatcher.t.cpp
+++ b/tests/unit-tests/mgmt/dispatcher.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -158,49 +158,49 @@
bind([&nCallbackCalled] { ++nCallbackCalled["test/2"]; }));
face.receive(*makeInterest("/root/1/test/1/%80%00"));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(nCallbackCalled["test/1"], 0);
BOOST_CHECK_EQUAL(nCallbackCalled["test/2"], 0);
dispatcher.addTopPrefix("/root/1");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
face.receive(*makeInterest("/root/1/test/1/%80%00"));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(nCallbackCalled["test/1"], 1);
BOOST_CHECK_EQUAL(nCallbackCalled["test/2"], 0);
face.receive(*makeInterest("/root/1/test/2/%80%00"));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(nCallbackCalled["test/1"], 1);
BOOST_CHECK_EQUAL(nCallbackCalled["test/2"], 1);
face.receive(*makeInterest("/root/2/test/1/%80%00"));
face.receive(*makeInterest("/root/2/test/2/%80%00"));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(nCallbackCalled["test/1"], 1);
BOOST_CHECK_EQUAL(nCallbackCalled["test/2"], 1);
dispatcher.addTopPrefix("/root/2");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
face.receive(*makeInterest("/root/1/test/1/%80%00"));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(nCallbackCalled["test/1"], 2);
face.receive(*makeInterest("/root/2/test/1/%80%00"));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(nCallbackCalled["test/1"], 3);
dispatcher.removeTopPrefix("/root/1");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
face.receive(*makeInterest("/root/1/test/1/%80%00"));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(nCallbackCalled["test/1"], 3);
face.receive(*makeInterest("/root/2/test/1/%80%00"));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(nCallbackCalled["test/1"], 4);
}
@@ -214,7 +214,7 @@
bind([&nCallbackCalled] { ++nCallbackCalled; }));
dispatcher.addTopPrefix("/root");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
face.sentData.clear();
face.receive(*makeInterest("/root/test/%80%00")); // returns 403
@@ -222,7 +222,7 @@
face.receive(*makeInterest("/root/test/%80%00/silent")); // silently ignored
face.receive(*makeInterest("/root/test/.../invalid")); // silently ignored (wrong format)
face.receive(*makeInterest("/root/test/.../valid")); // silently ignored (wrong format)
- advanceClocks(time::milliseconds(1), 20);
+ advanceClocks(1_ms, 20);
BOOST_CHECK_EQUAL(nCallbackCalled, 0);
BOOST_CHECK_EQUAL(face.sentData.size(), 2);
@@ -232,7 +232,7 @@
BOOST_CHECK_EQUAL(ControlResponse(face.sentData[1].getContent().blockFromValue()).getCode(), 403);
face.receive(*makeInterest("/root/test/%80%00/valid"));
- advanceClocks(time::milliseconds(1), 10);
+ advanceClocks(1_ms, 10);
BOOST_CHECK_EQUAL(nCallbackCalled, 1);
}
@@ -290,15 +290,15 @@
bind([&nCallbackCalled] { ++nCallbackCalled; }));
dispatcher.addTopPrefix("/root");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
face.receive(*makeInterest("/root/test/%80%00"));
BOOST_CHECK_EQUAL(nCallbackCalled, 0);
BOOST_REQUIRE(authorizationAccept != nullptr);
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
authorizationAccept("");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(nCallbackCalled, 1);
}
@@ -345,13 +345,13 @@
});
dispatcher.addTopPrefix("/root");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
face.sentData.clear();
face.receive(*makeInterest("/root/test/small/%80%00")); // returns 403
face.receive(*makeInterest("/root/test/small/%80%00/invalid")); // returns 403
face.receive(*makeInterest("/root/test/small/%80%00/silent")); // silently ignored
- advanceClocks(time::milliseconds(1), 20);
+ advanceClocks(1_ms, 20);
BOOST_CHECK_EQUAL(face.sentData.size(), 2);
BOOST_CHECK(face.sentData[0].getContentType() == tlv::ContentType_Blob);
@@ -363,7 +363,7 @@
auto interestSmall = *makeInterest("/root/test/small/valid");
face.receive(interestSmall);
- advanceClocks(time::milliseconds(1), 10);
+ advanceClocks(1_ms, 10);
// one data packet is generated and sent to both places
BOOST_CHECK_EQUAL(face.sentData.size(), 1);
@@ -375,7 +375,7 @@
face.receive(*makeInterest(Name("/root/test/small/valid").appendVersion(10))); // should be ignored
face.receive(*makeInterest(Name("/root/test/small/valid").appendSegment(20))); // should be ignored
- advanceClocks(time::milliseconds(1), 10);
+ advanceClocks(1_ms, 10);
BOOST_CHECK_EQUAL(face.sentData.size(), 1);
BOOST_CHECK_EQUAL(storage.size(), 1);
@@ -390,7 +390,7 @@
storage.erase("/", true); // clear the storage
face.sentData.clear();
face.receive(*makeInterest("/root/test/large/valid"));
- advanceClocks(time::milliseconds(1), 10);
+ advanceClocks(1_ms, 10);
// two data packets are generated, the first one will be sent to both places
// while the second one will only be inserted into the in-memory storage
@@ -429,7 +429,7 @@
storage.erase("/", true);// clear the storage
face.sentData.clear();
face.receive(*makeInterest("/root/test/reject/%80%00/valid")); // returns nack
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(face.sentData.size(), 1);
BOOST_CHECK(face.sentData[0].getContentType() == tlv::ContentType_Nack);
BOOST_CHECK_EQUAL(ControlResponse(face.sentData[0].getContent().blockFromValue()).getCode(), 400);
@@ -443,22 +443,22 @@
auto post = dispatcher.addNotificationStream("test");
post(block);
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(face.sentData.size(), 0);
dispatcher.addTopPrefix("/root");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
face.sentData.clear();
post(block);
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(face.sentData.size(), 1);
BOOST_CHECK_EQUAL(storage.size(), 1);
post(block);
post(block);
post(block);
- advanceClocks(time::milliseconds(1), 10);
+ advanceClocks(1_ms, 10);
BOOST_CHECK_EQUAL(face.sentData.size(), 4);
BOOST_CHECK_EQUAL(face.sentData[0].getName(), "/root/test/%FE%00");
diff --git a/tests/unit-tests/mgmt/nfd/command-options.t.cpp b/tests/unit-tests/mgmt/nfd/command-options.t.cpp
index 470cac9..e8fe76e 100644
--- a/tests/unit-tests/mgmt/nfd/command-options.t.cpp
+++ b/tests/unit-tests/mgmt/nfd/command-options.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -37,15 +37,15 @@
CommandOptions co;
BOOST_CHECK_EQUAL(co.getTimeout(), CommandOptions::DEFAULT_TIMEOUT);
- co.setTimeout(time::milliseconds(7414));
- BOOST_CHECK_EQUAL(co.getTimeout(), time::milliseconds(7414));
+ co.setTimeout(7414_ms);
+ BOOST_CHECK_EQUAL(co.getTimeout(), 7414_ms);
BOOST_CHECK_THROW(co.setTimeout(time::milliseconds::zero()), std::out_of_range);
BOOST_CHECK_THROW(co.setTimeout(time::milliseconds(-1)), std::out_of_range);
- BOOST_CHECK_EQUAL(co.getTimeout(), time::milliseconds(7414)); // unchanged after throw
+ BOOST_CHECK_EQUAL(co.getTimeout(), 7414_ms); // unchanged after throw
- co.setTimeout(time::milliseconds(1));
- BOOST_CHECK_EQUAL(co.getTimeout(), time::milliseconds(1));
+ co.setTimeout(1_ms);
+ BOOST_CHECK_EQUAL(co.getTimeout(), 1_ms);
}
BOOST_AUTO_TEST_CASE(Prefix)
diff --git a/tests/unit-tests/mgmt/nfd/control-parameters.t.cpp b/tests/unit-tests/mgmt/nfd/control-parameters.t.cpp
index 8f8f98a..199ba3b 100644
--- a/tests/unit-tests/mgmt/nfd/control-parameters.t.cpp
+++ b/tests/unit-tests/mgmt/nfd/control-parameters.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -111,7 +111,7 @@
.setOrigin(ROUTE_ORIGIN_NLSR)
.setCost(6)
.setFlags(0x01)
- .setExpirationPeriod(time::minutes(30));
+ .setExpirationPeriod(30_min);
Block wire = parameters.wireEncode();
@@ -121,7 +121,7 @@
BOOST_CHECK_EQUAL(decoded.getOrigin(), ROUTE_ORIGIN_NLSR);
BOOST_CHECK_EQUAL(decoded.getCost(), 6);
BOOST_CHECK_EQUAL(decoded.getFlags(), 0x01);
- BOOST_CHECK_EQUAL(decoded.getExpirationPeriod(), time::milliseconds(1800000));
+ BOOST_CHECK_EQUAL(decoded.getExpirationPeriod(), 1800000_ms);
BOOST_CHECK_EQUAL(decoded.hasUri(), false);
BOOST_CHECK_EQUAL(decoded.hasLocalUri(), false);
diff --git a/tests/unit-tests/mgmt/nfd/controller.t.cpp b/tests/unit-tests/mgmt/nfd/controller.t.cpp
index 92fcedd..e9a3c4f 100644
--- a/tests/unit-tests/mgmt/nfd/controller.t.cpp
+++ b/tests/unit-tests/mgmt/nfd/controller.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -48,7 +48,7 @@
auto responseData = makeData(face.sentInterests.at(0).getName());
responseData->setContent(responsePayload.wireEncode());
face.receive(*responseData);
- this->advanceClocks(time::milliseconds(1));
+ this->advanceClocks(1_ms);
}
private:
@@ -86,7 +86,7 @@
parameters.setUri("tcp4://192.0.2.1:6363");
controller.start<FaceCreateCommand>(parameters, succeedCallback, commandFailCallback);
- this->advanceClocks(time::milliseconds(1));
+ this->advanceClocks(1_ms);
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
const Interest& requestInterest = face.sentInterests[0];
@@ -119,7 +119,7 @@
parameters.setUri("tcp4://192.0.2.1:6363");
controller.start<FaceCreateCommand>(parameters, nullptr, commandFailCallback);
- this->advanceClocks(time::milliseconds(1));
+ this->advanceClocks(1_ms);
ControlParameters responseBody = makeFaceCreateResponse();
ControlResponse responsePayload(201, "created");
@@ -139,7 +139,7 @@
options.setPrefix("/localhop/net/example/router1/nfd");
controller.start<RibRegisterCommand>(parameters, succeedCallback, commandFailCallback, options);
- this->advanceClocks(time::milliseconds(1));
+ this->advanceClocks(1_ms);
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
const Interest& requestInterest = face.sentInterests[0];
@@ -167,7 +167,7 @@
parameters.setUri("tcp4://192.0.2.1:6363");
controller.start<FaceCreateCommand>(parameters, succeedCallback, commandFailCallback);
- this->advanceClocks(time::milliseconds(1));
+ this->advanceClocks(1_ms);
ControlParameters responseBody = makeFaceCreateResponse();
ControlResponse responsePayload(201, "created");
@@ -185,7 +185,7 @@
parameters.setUri("tcp4://192.0.2.1:6363");
controller.start<FaceCreateCommand>(parameters, succeedCallback, commandFailCallback);
- this->advanceClocks(time::milliseconds(1));
+ this->advanceClocks(1_ms);
ControlResponse responsePayload(401, "Not Authenticated");
this->respond(responsePayload);
@@ -201,7 +201,7 @@
parameters.setUri("tcp4://192.0.2.1:6363");
controller.start<FaceCreateCommand>(parameters, succeedCallback, commandFailCallback);
- this->advanceClocks(time::milliseconds(1));
+ this->advanceClocks(1_ms);
ControlParameters responseBody = makeFaceCreateResponse();
responseBody.unsetFaceId() // FaceId is missing
@@ -220,14 +220,14 @@
parameters.setUri("tcp4://192.0.2.1:6363");
controller.start<FaceCreateCommand>(parameters, succeedCallback, commandFailCallback);
- this->advanceClocks(time::milliseconds(1));
+ this->advanceClocks(1_ms);
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
const Interest& requestInterest = face.sentInterests[0];
auto responseNack = makeNack(requestInterest, lp::NackReason::NO_ROUTE);
face.receive(responseNack);
- this->advanceClocks(time::milliseconds(1));
+ this->advanceClocks(1_ms);
BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_NACK);
@@ -239,11 +239,11 @@
parameters.setUri("tcp4://192.0.2.1:6363");
CommandOptions options;
- options.setTimeout(time::milliseconds(50));
+ options.setTimeout(50_ms);
controller.start<FaceCreateCommand>(parameters, succeedCallback, commandFailCallback, options);
- this->advanceClocks(time::milliseconds(1)); // express Interest
- this->advanceClocks(time::milliseconds(51)); // timeout
+ this->advanceClocks(1_ms); // express Interest
+ this->advanceClocks(51_ms); // timeout
BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_TIMEOUT);
@@ -255,11 +255,11 @@
parameters.setUri("tcp4://192.0.2.1:6363");
CommandOptions options;
- options.setTimeout(time::milliseconds(50));
+ options.setTimeout(50_ms);
controller.start<FaceCreateCommand>(parameters, succeedCallback, nullptr, options);
- this->advanceClocks(time::milliseconds(1)); // express Interest
- this->advanceClocks(time::milliseconds(51)); // timeout
+ this->advanceClocks(1_ms); // express Interest
+ this->advanceClocks(51_ms); // timeout
BOOST_CHECK_EQUAL(succeeds.size(), 0);
}
diff --git a/tests/unit-tests/mgmt/nfd/face-status.t.cpp b/tests/unit-tests/mgmt/nfd/face-status.t.cpp
index 16fe108..dee1de2 100644
--- a/tests/unit-tests/mgmt/nfd/face-status.t.cpp
+++ b/tests/unit-tests/mgmt/nfd/face-status.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -42,7 +42,7 @@
.setFaceScope(FACE_SCOPE_LOCAL)
.setFacePersistency(FACE_PERSISTENCY_ON_DEMAND)
.setLinkType(LINK_TYPE_MULTI_ACCESS)
- .setExpirationPeriod(time::seconds(10))
+ .setExpirationPeriod(10_s)
.setNInInterests(10)
.setNInData(200)
.setNInNacks(1)
@@ -135,9 +135,9 @@
FaceStatus status;
BOOST_CHECK_EQUAL(status.hasExpirationPeriod(), false);
- status.setExpirationPeriod(time::minutes(1));
+ status.setExpirationPeriod(1_min);
BOOST_REQUIRE_EQUAL(status.hasExpirationPeriod(), true);
- BOOST_CHECK_EQUAL(status.getExpirationPeriod(), time::minutes(1));
+ BOOST_CHECK_EQUAL(status.getExpirationPeriod(), 1_min);
status.unsetExpirationPeriod();
BOOST_CHECK_EQUAL(status.hasExpirationPeriod(), false);
diff --git a/tests/unit-tests/mgmt/nfd/rib-entry.t.cpp b/tests/unit-tests/mgmt/nfd/rib-entry.t.cpp
index 15c14d1..f2ab51a 100644
--- a/tests/unit-tests/mgmt/nfd/rib-entry.t.cpp
+++ b/tests/unit-tests/mgmt/nfd/rib-entry.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -48,13 +48,13 @@
return RibEntry()
.setName("/hello/world")
.addRoute(makeRoute()
- .setExpirationPeriod(time::seconds(10)));
+ .setExpirationPeriod(10_s));
}
BOOST_AUTO_TEST_CASE(RouteEncode)
{
Route route1 = makeRoute();
- route1.setExpirationPeriod(time::seconds(10));
+ route1.setExpirationPeriod(10_s);
const Block& wire = route1.wireEncode();
static const uint8_t expected[] = {
@@ -89,15 +89,15 @@
BOOST_CHECK_EQUAL(route.hasExpirationPeriod(), false);
BOOST_CHECK_EQUAL(route.getExpirationPeriod(), time::milliseconds::max());
- route.setExpirationPeriod(time::minutes(1));
+ route.setExpirationPeriod(1_min);
BOOST_CHECK_EQUAL(route.hasExpirationPeriod(), true);
- BOOST_CHECK_EQUAL(route.getExpirationPeriod(), time::minutes(1));
+ BOOST_CHECK_EQUAL(route.getExpirationPeriod(), 1_min);
route.setExpirationPeriod(time::milliseconds::max());
BOOST_CHECK_EQUAL(route.hasExpirationPeriod(), false);
BOOST_CHECK_EQUAL(route.getExpirationPeriod(), time::milliseconds::max());
- route.setExpirationPeriod(time::minutes(1));
+ route.setExpirationPeriod(1_min);
BOOST_CHECK_EQUAL(route.hasExpirationPeriod(), true);
route.unsetExpirationPeriod();
@@ -116,7 +116,7 @@
BOOST_CHECK_NE(route1, route2);
route2 = route1;
- route2.setExpirationPeriod(time::minutes(1));
+ route2.setExpirationPeriod(1_min);
BOOST_CHECK_NE(route1, route2);
}
@@ -128,7 +128,7 @@
.setOrigin(ROUTE_ORIGIN_APP)
.setCost(32)
.setFlags(ROUTE_FLAG_CHILD_INHERIT)
- .setExpirationPeriod(time::seconds(5)));
+ .setExpirationPeriod(5_s));
const Block& wire = entry1.wireEncode();
static const uint8_t expected[] = {
diff --git a/tests/unit-tests/mgmt/nfd/status-dataset.t.cpp b/tests/unit-tests/mgmt/nfd/status-dataset.t.cpp
index 990f7f1..2abbdaa 100644
--- a/tests/unit-tests/mgmt/nfd/status-dataset.t.cpp
+++ b/tests/unit-tests/mgmt/nfd/status-dataset.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -110,12 +110,12 @@
BOOST_AUTO_TEST_CASE(Timeout)
{
CommandOptions options;
- options.setTimeout(time::milliseconds(3000));
+ options.setTimeout(3000_ms);
controller.fetch<FaceDataset>(
[] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
datasetFailCallback,
options);
- this->advanceClocks(time::milliseconds(500), 7);
+ this->advanceClocks(500_ms, 7);
BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_TIMEOUT);
@@ -126,10 +126,10 @@
controller.fetch<FaceDataset>(
[] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
face.receive(*makeData("/localhost/nfd/faces/list/%FD%00"));
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
@@ -142,12 +142,12 @@
controller.fetch<FaceDataset>(
[] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
FaceStatus payload;
payload.setFaceId(5744);
this->sendDataset("/localhost/nfd/faces/list", payload);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_VALIDATION);
@@ -158,11 +158,11 @@
controller.fetch<FaceDataset>(
[] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
face.receive(lp::Nack(face.sentInterests.back()));
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_NACK);
@@ -173,11 +173,11 @@
controller.fetch<FaceDataset>(
[] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
Name payload; // Name is not valid FaceStatus
this->sendDataset("/localhost/nfd/faces/list", payload);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
@@ -188,13 +188,13 @@
controller.fetch<FaceDataset>(
[] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
FaceStatus payload1;
payload1.setFaceId(10930);
Name payload2; // Name is not valid FaceStatus
this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
@@ -209,12 +209,12 @@
controller.fetch<FaceDataset>(
nullptr,
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
FaceStatus payload;
payload.setFaceId(2577);
this->sendDataset("/localhost/nfd/faces/list", payload);
- BOOST_CHECK_NO_THROW(this->advanceClocks(time::milliseconds(500)));
+ BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms));
BOOST_CHECK_EQUAL(failCodes.size(), 0);
}
@@ -222,12 +222,12 @@
BOOST_AUTO_TEST_CASE(Failure)
{
CommandOptions options;
- options.setTimeout(time::milliseconds(3000));
+ options.setTimeout(3000_ms);
controller.fetch<FaceDataset>(
[] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
nullptr,
options);
- BOOST_CHECK_NO_THROW(this->advanceClocks(time::milliseconds(500), 7));
+ BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms, 7));
}
BOOST_AUTO_TEST_SUITE_END() // NoCallback
@@ -243,12 +243,12 @@
BOOST_CHECK_EQUAL(result.getNfdVersion(), "0.4.2");
},
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
ForwarderStatus payload;
payload.setNfdVersion("0.4.2");
this->sendDataset("/localhost/nfd/status/general", payload);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_CHECK(hasResult);
BOOST_CHECK_EQUAL(failCodes.size(), 0);
@@ -264,14 +264,14 @@
BOOST_CHECK_EQUAL(result.front().getFaceId(), 24485);
},
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
FaceStatus payload1;
payload1.setFaceId(24485);
FaceStatus payload2;
payload2.setFaceId(12987);
this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_CHECK(hasResult);
BOOST_CHECK_EQUAL(failCodes.size(), 0);
@@ -290,14 +290,14 @@
BOOST_CHECK_EQUAL(result.front().getFaceId(), 8795);
},
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
Name prefix("/localhost/nfd/faces/query");
prefix.append(filter.wireEncode());
FaceStatus payload;
payload.setFaceId(8795);
this->sendDataset(prefix, payload);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_CHECK(hasResult);
BOOST_CHECK_EQUAL(failCodes.size(), 0);
@@ -308,7 +308,7 @@
FaceQueryFilter filter;
filter.setUriScheme("udp4");
CommandOptions options;
- options.setTimeout(time::milliseconds(3000));
+ options.setTimeout(3000_ms);
bool hasResult = false;
controller.fetch<FaceQueryDataset>(
filter,
@@ -319,14 +319,14 @@
},
datasetFailCallback,
options);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
Name prefix("/localhost/nfd/faces/query");
prefix.append(filter.wireEncode());
FaceStatus payload;
payload.setFaceId(14022);
this->sendDataset(prefix, payload);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_CHECK(hasResult);
BOOST_CHECK_EQUAL(failCodes.size(), 0);
@@ -342,14 +342,14 @@
BOOST_CHECK_EQUAL(result.front().getLocalUri(), "tcp4://192.0.2.1:6363");
},
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
ChannelStatus payload1;
payload1.setLocalUri("tcp4://192.0.2.1:6363");
ChannelStatus payload2;
payload2.setLocalUri("udp4://192.0.2.1:6363");
this->sendDataset("/localhost/nfd/faces/channels", payload1, payload2);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_CHECK(hasResult);
BOOST_CHECK_EQUAL(failCodes.size(), 0);
@@ -365,14 +365,14 @@
BOOST_CHECK_EQUAL(result.front().getPrefix(), "/wYs7fzYcfG");
},
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
FibEntry payload1;
payload1.setPrefix("/wYs7fzYcfG");
FibEntry payload2;
payload2.setPrefix("/LKvmnzY5S");
this->sendDataset("/localhost/nfd/fib/list", payload1, payload2);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_CHECK(hasResult);
BOOST_CHECK_EQUAL(failCodes.size(), 0);
@@ -389,12 +389,12 @@
BOOST_CHECK_EQUAL(result.getNHits(), 4539);
},
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
CsInfo payload;
payload.setNHits(4539);
this->sendDataset("/localhost/nfd/cs/info", payload);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_CHECK(hasResult);
BOOST_CHECK_EQUAL(failCodes.size(), 0);
@@ -410,14 +410,14 @@
BOOST_CHECK_EQUAL(result.front().getName(), "/8MLz6N3B");
},
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
StrategyChoice payload1;
payload1.setName("/8MLz6N3B");
StrategyChoice payload2;
payload2.setName("/svqcBu0YwU");
this->sendDataset("/localhost/nfd/strategy-choice/list", payload1, payload2);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_CHECK(hasResult);
BOOST_CHECK_EQUAL(failCodes.size(), 0);
@@ -433,14 +433,14 @@
BOOST_CHECK_EQUAL(result.front().getName(), "/zXxBth97ee");
},
datasetFailCallback);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
RibEntry payload1;
payload1.setName("/zXxBth97ee");
RibEntry payload2;
payload2.setName("/rJ8CvUpr4G");
this->sendDataset("/localhost/nfd/rib/list", payload1, payload2);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_CHECK(hasResult);
BOOST_CHECK_EQUAL(failCodes.size(), 0);
@@ -459,12 +459,12 @@
},
datasetFailCallback,
options);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
RibEntry payload;
payload.setName("/e6L5K4ascd");
this->sendDataset("/localhop/nfd/rib/list", payload);
- this->advanceClocks(time::milliseconds(500));
+ this->advanceClocks(500_ms);
BOOST_CHECK(hasResult);
BOOST_CHECK_EQUAL(failCodes.size(), 0);
diff --git a/tests/unit-tests/mgmt/status-dataset-context.t.cpp b/tests/unit-tests/mgmt/status-dataset-context.t.cpp
index 5c432a7..c5af199 100644
--- a/tests/unit-tests/mgmt/status-dataset-context.t.cpp
+++ b/tests/unit-tests/mgmt/status-dataset-context.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -54,7 +54,7 @@
[this] (const ControlResponse& resp) {
sendNackHistory.push_back(resp);
})
- , defaultImsFresh(time::milliseconds(1000))
+ , defaultImsFresh(1000_ms)
{
}
@@ -141,8 +141,8 @@
BOOST_AUTO_TEST_CASE(GetAndSet)
{
- auto period = time::milliseconds(9527);
- BOOST_CHECK_EQUAL(context.getExpiry(), time::milliseconds(1000));
+ auto period = 9527_ms;
+ BOOST_CHECK_EQUAL(context.getExpiry(), 1000_ms);
BOOST_CHECK_EQUAL(context.setExpiry(period).getExpiry(), period);
}
diff --git a/tests/unit-tests/name-component.t.cpp b/tests/unit-tests/name-component.t.cpp
index d91ce24..9463144 100644
--- a/tests/unit-tests/name-component.t.cpp
+++ b/tests/unit-tests/name-component.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -297,7 +297,7 @@
bind(&name::Component::toTimestamp, _1),
[] (Name& name, time::system_clock::TimePoint t) -> Name& { return name.appendTimestamp(t); },
Name("/%FC%00%04%7BE%E3%1B%00%00"),
- time::getUnixEpoch() + time::days(14600), // 40 years
+ time::getUnixEpoch() + 14600_days, // 40 years
bind(&name::Component::isTimestamp, _1)};
}
};
diff --git a/tests/unit-tests/net/face-uri.t.cpp b/tests/unit-tests/net/face-uri.t.cpp
index 1dd40c8..1f90f67 100644
--- a/tests/unit-tests/net/face-uri.t.cpp
+++ b/tests/unit-tests/net/face-uri.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California,
+ * Copyright (c) 2013-2018 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -49,7 +49,7 @@
FaceUri uri(request);
uri.canonize(bind(&CanonizeFixture::onCanonizeSuccess, this, tc, _1),
bind(&CanonizeFixture::onCanonizeFailure, this, tc, _1),
- m_io, time::seconds(10));
+ m_io, 10_s);
}
void
@@ -575,22 +575,22 @@
// unsupported scheme
FaceUri("null://").canonize(FaceUri::CanonizeSuccessCallback(),
FaceUri::CanonizeFailureCallback(),
- io, time::milliseconds(1));
+ io, 1_ms);
// cannot resolve
FaceUri("udp://192.0.2.333").canonize(FaceUri::CanonizeSuccessCallback(),
FaceUri::CanonizeFailureCallback(),
- io, time::milliseconds(1));
+ io, 1_ms);
// already canonical
FaceUri("udp4://192.0.2.1:6363").canonize(FaceUri::CanonizeSuccessCallback(),
FaceUri::CanonizeFailureCallback(),
- io, time::milliseconds(1));
+ io, 1_ms);
// need DNS resolution
FaceUri("udp://192.0.2.1:6363").canonize(FaceUri::CanonizeSuccessCallback(),
FaceUri::CanonizeFailureCallback(),
- io, time::milliseconds(1));
+ io, 1_ms);
io.run(); // should not crash
diff --git a/tests/unit-tests/security/command-interest-signer.t.cpp b/tests/unit-tests/security/command-interest-signer.t.cpp
index 4c95293..784a209 100644
--- a/tests/unit-tests/security/command-interest-signer.t.cpp
+++ b/tests/unit-tests/security/command-interest-signer.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -55,7 +55,7 @@
BOOST_CHECK_NE(i2.getName().at(command_interest::POS_RANDOM_VAL),
i1.getName().at(command_interest::POS_RANDOM_VAL)); // this sometimes can fail
- advanceClocks(time::seconds(100));
+ advanceClocks(100_s);
i2 = signer.makeCommandInterest("/hello/world/!");
BOOST_CHECK_GT(i2.getName().at(command_interest::POS_TIMESTAMP), i1.getName().at(command_interest::POS_TIMESTAMP));
diff --git a/tests/unit-tests/security/pib/detail/key-impl.t.cpp b/tests/unit-tests/security/pib/detail/key-impl.t.cpp
index ec51751..517ea60 100644
--- a/tests/unit-tests/security/pib/detail/key-impl.t.cpp
+++ b/tests/unit-tests/security/pib/detail/key-impl.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -156,7 +156,7 @@
auto otherCert = id1Key1Cert1;
SignatureInfo info;
info.setValidityPeriod(ValidityPeriod(time::system_clock::now(),
- time::system_clock::now() + time::seconds(1)));
+ time::system_clock::now() + 1_s));
m_keyChain.sign(otherCert, SigningInfo().setSignatureInfo(info));
BOOST_CHECK_EQUAL(otherCert.getName(), id1Key1Cert1.getName());
diff --git a/tests/unit-tests/security/pib/pib-data-fixture.cpp b/tests/unit-tests/security/pib/pib-data-fixture.cpp
index 0856b85..91e5b34 100644
--- a/tests/unit-tests/security/pib/pib-data-fixture.cpp
+++ b/tests/unit-tests/security/pib/pib-data-fixture.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -52,7 +52,7 @@
// .appendVersion(certVersion);
// v2::Certificate cert;
// cert.setName(certName);
-// cert.setFreshnessPeriod(time::hours(1));
+// cert.setFreshnessPeriod(1_h);
// cert.setContent(tpm.getPublicKey(keyName));
// // @TODO sign using the new KeyChain
diff --git a/tests/unit-tests/security/signature-sha256-with-ecdsa.t.cpp b/tests/unit-tests/security/signature-sha256-with-ecdsa.t.cpp
index cb2cf00..edc15d7 100644
--- a/tests/unit-tests/security/signature-sha256-with-ecdsa.t.cpp
+++ b/tests/unit-tests/security/signature-sha256-with-ecdsa.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -127,16 +127,16 @@
Interest interest("/SecurityTestSignatureSha256WithEcdsa/InterestSignature/Interest1");
Interest interest11("/SecurityTestSignatureSha256WithEcdsa/InterestSignature/Interest1");
- scheduler.scheduleEvent(time::milliseconds(100), [&] {
+ scheduler.scheduleEvent(100_ms, [&] {
BOOST_CHECK_NO_THROW(m_keyChain.sign(interest, security::SigningInfo(identity)));
});
- advanceClocks(time::milliseconds(100));
- scheduler.scheduleEvent(time::milliseconds(100), [&] {
+ advanceClocks(100_ms);
+ scheduler.scheduleEvent(100_ms, [&] {
BOOST_CHECK_NO_THROW(m_keyChain.sign(interest11, security::SigningInfo(identity)));
});
- advanceClocks(time::milliseconds(100));
+ advanceClocks(100_ms);
Block interestBlock(interest.wireEncode().wire(), interest.wireEncode().size());
diff --git a/tests/unit-tests/security/signature-sha256-with-rsa.t.cpp b/tests/unit-tests/security/signature-sha256-with-rsa.t.cpp
index 510bb1f..4348ade 100644
--- a/tests/unit-tests/security/signature-sha256-with-rsa.t.cpp
+++ b/tests/unit-tests/security/signature-sha256-with-rsa.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -132,16 +132,16 @@
Interest interest("/SecurityTestSignatureSha256WithRsa/InterestSignature/Interest1");
Interest interest11("/SecurityTestSignatureSha256WithRsa/InterestSignature/Interest1");
- scheduler.scheduleEvent(time::milliseconds(100), [&] {
+ scheduler.scheduleEvent(100_ms, [&] {
BOOST_CHECK_NO_THROW(m_keyChain.sign(interest, security::SigningInfo(identity)));
});
- advanceClocks(time::milliseconds(100));
- scheduler.scheduleEvent(time::milliseconds(100), [&] {
+ advanceClocks(100_ms);
+ scheduler.scheduleEvent(100_ms, [&] {
BOOST_CHECK_NO_THROW(m_keyChain.sign(interest11, security::SigningInfo(identity)));
});
- advanceClocks(time::milliseconds(100));
+ advanceClocks(100_ms);
Block interestBlock(interest.wireEncode().wire(), interest.wireEncode().size());
diff --git a/tests/unit-tests/security/v2/certificate-bundle-fetcher.t.cpp b/tests/unit-tests/security/v2/certificate-bundle-fetcher.t.cpp
index b837339..f9bc22c 100644
--- a/tests/unit-tests/security/v2/certificate-bundle-fetcher.t.cpp
+++ b/tests/unit-tests/security/v2/certificate-bundle-fetcher.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -126,7 +126,7 @@
shared_ptr<Data> certBundle = make_shared<Data>();
certBundle->setName(bundleName);
- certBundle->setFreshnessPeriod(time::seconds(100));
+ certBundle->setFreshnessPeriod(100_s);
certBundle->setContent(certList);
certBundle->setFinalBlockId(name::Component::fromSegment(1));
@@ -139,7 +139,7 @@
void
CertificateBundleFetcherFixture<Timeout>::makeResponse(const Interest& interest)
{
- this->advanceClocks(time::seconds(200));
+ this->advanceClocks(200_s);
}
template<>
diff --git a/tests/unit-tests/security/v2/certificate-cache.t.cpp b/tests/unit-tests/security/v2/certificate-cache.t.cpp
index 56c7dd0..4ae3505 100644
--- a/tests/unit-tests/security/v2/certificate-cache.t.cpp
+++ b/tests/unit-tests/security/v2/certificate-cache.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -36,7 +36,7 @@
{
public:
CertificateCacheFixture()
- : certCache(time::seconds(10))
+ : certCache(10_s)
{
identity = addIdentity("/TestCertificateCache/");
cert = identity.getDefaultKey().getDefaultCertificate();
@@ -57,16 +57,16 @@
BOOST_CHECK_NO_THROW(certCache.insert(cert));
BOOST_CHECK(certCache.find(cert.getName()) != nullptr);
- advanceClocks(time::seconds(11), 1);
+ advanceClocks(11_s, 1);
BOOST_CHECK(certCache.find(cert.getName()) == nullptr);
BOOST_CHECK_NO_THROW(certCache.insert(cert));
BOOST_CHECK(certCache.find(cert.getName()) != nullptr);
- advanceClocks(time::seconds(5));
+ advanceClocks(5_s);
BOOST_CHECK(certCache.find(cert.getName()) != nullptr);
- advanceClocks(time::seconds(15));
+ advanceClocks(15_s);
BOOST_CHECK(certCache.find(cert.getName()) == nullptr);
}
@@ -79,7 +79,7 @@
BOOST_CHECK(certCache.find(Interest(cert.getKeyName())) != nullptr);
BOOST_CHECK(certCache.find(Interest(Name(cert.getName()).appendVersion())) == nullptr);
- advanceClocks(time::seconds(12));
+ advanceClocks(12_s);
BOOST_CHECK(certCache.find(Interest(cert.getIdentity())) == nullptr);
Certificate cert3 = addCertificate(identity.getDefaultKey(), "3");
diff --git a/tests/unit-tests/security/v2/certificate-fetcher-from-network.t.cpp b/tests/unit-tests/security/v2/certificate-fetcher-from-network.t.cpp
index 0caa12f..e4b1ec9 100644
--- a/tests/unit-tests/security/v2/certificate-fetcher-from-network.t.cpp
+++ b/tests/unit-tests/security/v2/certificate-fetcher-from-network.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -110,7 +110,7 @@
BOOST_CHECK_EQUAL(this->face.sentInterests.size(), 2);
this->face.sentInterests.clear();
- this->advanceClocks(time::hours(1), 2); // expire validator caches
+ this->advanceClocks(1_h, 2); // expire validator caches
VALIDATE_SUCCESS(this->interest, "Should get accepted, as interests bring certs");
BOOST_CHECK_EQUAL(this->face.sentInterests.size(), 2);
@@ -122,7 +122,7 @@
BOOST_CHECK_GT(this->face.sentInterests.size(), 2);
this->face.sentInterests.clear();
- this->advanceClocks(time::hours(1), 2); // expire validator caches
+ this->advanceClocks(1_h, 2); // expire validator caches
VALIDATE_FAILURE(this->interest, "Should fail, as interests don't bring data");
BOOST_CHECK_GT(this->face.sentInterests.size(), 2);
diff --git a/tests/unit-tests/security/v2/certificate.t.cpp b/tests/unit-tests/security/v2/certificate.t.cpp
index 9522b55..5e0e24f 100644
--- a/tests/unit-tests/security/v2/certificate.t.cpp
+++ b/tests/unit-tests/security/v2/certificate.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -171,7 +171,7 @@
{
Certificate certificate;
certificate.setName("/ndn/site1/KEY/ksk-1416425377094/0123/%FD%00%00%01I%C9%8B");
- certificate.setFreshnessPeriod(time::seconds(3600));
+ certificate.setFreshnessPeriod(1_h);
certificate.setContent(PUBLIC_KEY, sizeof(PUBLIC_KEY));
certificate.setSignature(generateFakeSignature());
@@ -191,7 +191,7 @@
{
Certificate certificate;
certificate.setName("/ndn/site1/KEY/ksk-1416425377094/0123/%FD%00%00%01I%C9%8B");
- certificate.setFreshnessPeriod(time::seconds(3600));
+ certificate.setFreshnessPeriod(1_h);
certificate.setContent(PUBLIC_KEY, sizeof(PUBLIC_KEY));
certificate.setSignature(generateFakeSignature());
diff --git a/tests/unit-tests/security/v2/key-chain.t.cpp b/tests/unit-tests/security/v2/key-chain.t.cpp
index 9575754..d03f572 100644
--- a/tests/unit-tests/security/v2/key-chain.t.cpp
+++ b/tests/unit-tests/security/v2/key-chain.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -396,9 +396,8 @@
.getDefaultKey()
.getDefaultCertificate();
BOOST_CHECK(cert.isValid());
- BOOST_CHECK(cert.isValid(time::system_clock::now() + time::days(10 * 365)));
- BOOST_CHECK_GT(cert.getValidityPeriod().getPeriod().second,
- time::system_clock::now() + time::days(10 * 365));
+ BOOST_CHECK(cert.isValid(time::system_clock::now() + 10 * 365_days));
+ BOOST_CHECK_GT(cert.getValidityPeriod().getPeriod().second, time::system_clock::now() + 10 * 365_days);
}
BOOST_AUTO_TEST_SUITE_END() // TestKeyChain
diff --git a/tests/unit-tests/security/v2/trust-anchor-container.t.cpp b/tests/unit-tests/security/v2/trust-anchor-container.t.cpp
index 0efecdc..30749ac 100644
--- a/tests/unit-tests/security/v2/trust-anchor-container.t.cpp
+++ b/tests/unit-tests/security/v2/trust-anchor-container.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -20,10 +20,11 @@
*/
#include "security/v2/trust-anchor-container.hpp"
+#include "util/io.hpp"
#include "../../identity-management-time-fixture.hpp"
-#include "util/io.hpp"
#include "boost-test.hpp"
+
#include <boost/filesystem.hpp>
namespace ndn {
@@ -97,21 +98,21 @@
BOOST_CHECK_NO_THROW(anchorContainer.insert("group1", Certificate(cert1)));
BOOST_CHECK_EQUAL(cert, anchorContainer.find(cert1.getName())); // still the same instance of the certificate
// cannot add dynamic group when static already exists
- BOOST_CHECK_THROW(anchorContainer.insert("group1", certPath1.string(), time::seconds(1)), TrustAnchorContainer::Error);
+ BOOST_CHECK_THROW(anchorContainer.insert("group1", certPath1.string(), 1_s), TrustAnchorContainer::Error);
BOOST_CHECK_EQUAL(anchorContainer.getGroup("group1").size(), 1);
BOOST_CHECK_EQUAL(anchorContainer.size(), 1);
// From file
- anchorContainer.insert("group2", certPath2.string(), time::seconds(1));
+ anchorContainer.insert("group2", certPath2.string(), 1_s);
BOOST_CHECK(anchorContainer.find(cert2.getName()) != nullptr);
BOOST_CHECK(anchorContainer.find(identity2.getName()) != nullptr);
BOOST_CHECK_THROW(anchorContainer.insert("group2", Certificate(cert2)), TrustAnchorContainer::Error);
- BOOST_CHECK_THROW(anchorContainer.insert("group2", certPath2.string(), time::seconds(1)), TrustAnchorContainer::Error);
+ BOOST_CHECK_THROW(anchorContainer.insert("group2", certPath2.string(), 1_s), TrustAnchorContainer::Error);
BOOST_CHECK_EQUAL(anchorContainer.getGroup("group2").size(), 1);
BOOST_CHECK_EQUAL(anchorContainer.size(), 2);
boost::filesystem::remove(certPath2);
- advanceClocks(time::seconds(1), 11);
+ advanceClocks(1_s, 11);
BOOST_CHECK(anchorContainer.find(identity2.getName()) == nullptr);
BOOST_CHECK(anchorContainer.find(cert2.getName()) == nullptr);
@@ -133,7 +134,7 @@
{
boost::filesystem::remove(certPath2);
- anchorContainer.insert("group", certDirPath.string(), time::seconds(1), true /* isDir */);
+ anchorContainer.insert("group", certDirPath.string(), 1_s, true /* isDir */);
BOOST_CHECK(anchorContainer.find(identity1.getName()) != nullptr);
BOOST_CHECK(anchorContainer.find(identity2.getName()) == nullptr);
@@ -141,7 +142,7 @@
saveCertToFile(cert2, certPath2.string());
- advanceClocks(time::milliseconds(100), 11);
+ advanceClocks(100_ms, 11);
BOOST_CHECK(anchorContainer.find(identity1.getName()) != nullptr);
BOOST_CHECK(anchorContainer.find(identity2.getName()) != nullptr);
@@ -149,7 +150,7 @@
boost::filesystem::remove_all(certDirPath);
- advanceClocks(time::milliseconds(100), 11);
+ advanceClocks(100_ms, 11);
BOOST_CHECK(anchorContainer.find(identity1.getName()) == nullptr);
BOOST_CHECK(anchorContainer.find(identity2.getName()) == nullptr);
@@ -158,7 +159,7 @@
BOOST_FIXTURE_TEST_CASE(FindByInterest, AnchorContainerTestFixture)
{
- anchorContainer.insert("group1", certPath1.string(), time::seconds(1));
+ anchorContainer.insert("group1", certPath1.string(), 1_s);
Interest interest(identity1.getName());
BOOST_CHECK(anchorContainer.find(interest) != nullptr);
Interest interest1(identity1.getName().getPrefix(-1));
diff --git a/tests/unit-tests/security/v2/validation-policy-command-interest.t.cpp b/tests/unit-tests/security/v2/validation-policy-command-interest.t.cpp
index dd400b4..4a3365c 100644
--- a/tests/unit-tests/security/v2/validation-policy-command-interest.t.cpp
+++ b/tests/unit-tests/security/v2/validation-policy-command-interest.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -91,7 +91,7 @@
auto i1 = makeCommandInterest(identity);
VALIDATE_SUCCESS(i1, "Should succeed (within grace period)");
- advanceClocks(time::milliseconds(5));
+ advanceClocks(5_ms);
auto i2 = makeCommandInterest(identity);
VALIDATE_SUCCESS(i2, "Should succeed (timestamp larger than previous)");
}
@@ -173,7 +173,7 @@
getOptions()
{
ValidationPolicyCommandInterest::Options options;
- options.gracePeriod = time::seconds(15);
+ options.gracePeriod = 15_s;
return options;
}
};
@@ -181,7 +181,7 @@
BOOST_FIXTURE_TEST_CASE(TimestampOutOfGracePositive, ValidationPolicyCommandInterestFixture<GracePeriod15Sec>)
{
auto i1 = makeCommandInterest(identity); // signed at 0s
- advanceClocks(time::seconds(16)); // verifying at +16s
+ advanceClocks(16_s); // verifying at +16s
VALIDATE_FAILURE(i1, "Should fail (timestamp outside the grace period)");
rewindClockAfterValidation();
@@ -192,12 +192,12 @@
BOOST_FIXTURE_TEST_CASE(TimestampOutOfGraceNegative, ValidationPolicyCommandInterestFixture<GracePeriod15Sec>)
{
auto i1 = makeCommandInterest(identity); // signed at 0s
- advanceClocks(time::seconds(1));
+ advanceClocks(1_s);
auto i2 = makeCommandInterest(identity); // signed at +1s
- advanceClocks(time::seconds(1));
+ advanceClocks(1_s);
auto i3 = makeCommandInterest(identity); // signed at +2s
- systemClock->advance(time::seconds(-18)); // verifying at -16s
+ systemClock->advance(-18_s); // verifying at -16s
VALIDATE_FAILURE(i1, "Should fail (timestamp outside the grace period)");
rewindClockAfterValidation();
@@ -206,7 +206,7 @@
rewindClockAfterValidation();
// CommandInterestValidator should not remember i2's timestamp, and should treat i3 as initial
- advanceClocks(time::seconds(18)); // verifying at +2s
+ advanceClocks(18_s); // verifying at +2s
VALIDATE_SUCCESS(i3, "Should succeed");
}
@@ -220,7 +220,7 @@
i1.getName()[command_interest::POS_TIMESTAMP]);
VALIDATE_FAILURE(i2, "Should fail (timestamp reordered)");
- advanceClocks(time::seconds(2));
+ advanceClocks(2_s);
auto i3 = makeCommandInterest(identity); // signed at +2s
VALIDATE_SUCCESS(i3, "Should succeed");
}
@@ -228,27 +228,27 @@
BOOST_AUTO_TEST_CASE(TimestampReorderNegative)
{
auto i2 = makeCommandInterest(identity); // signed at 0ms
- advanceClocks(time::milliseconds(200));
+ advanceClocks(200_ms);
auto i3 = makeCommandInterest(identity); // signed at +200ms
- advanceClocks(time::milliseconds(900));
+ advanceClocks(900_ms);
auto i1 = makeCommandInterest(identity); // signed at +1100ms
- advanceClocks(time::milliseconds(300));
+ advanceClocks(300_ms);
auto i4 = makeCommandInterest(identity); // signed at +1400ms
- systemClock->advance(time::milliseconds(-300)); // verifying at +1100ms
+ systemClock->advance(-300_ms); // verifying at +1100ms
VALIDATE_SUCCESS(i1, "Should succeed");
rewindClockAfterValidation();
- systemClock->advance(time::milliseconds(-1100)); // verifying at 0ms
+ systemClock->advance(-1100_ms); // verifying at 0ms
VALIDATE_FAILURE(i2, "Should fail (timestamp reordered)");
rewindClockAfterValidation();
// CommandInterestValidator should not remember i2's timestamp
- advanceClocks(time::milliseconds(200)); // verifying at +200ms
+ advanceClocks(200_ms); // verifying at +200ms
VALIDATE_FAILURE(i3, "Should fail (timestamp reordered)");
rewindClockAfterValidation();
- advanceClocks(time::milliseconds(1200)); // verifying at 1400ms
+ advanceClocks(1200_ms); // verifying at 1400ms
VALIDATE_SUCCESS(i4, "Should succeed");
}
@@ -287,7 +287,7 @@
VALIDATE_SUCCESS(i1, "Should succeed when validating at 0ms");
this->rewindClockAfterValidation();
- this->advanceClocks(time::milliseconds(1));
+ this->advanceClocks(1_ms);
VALIDATE_FAILURE(i2, "Should fail when validating at 1ms");
}
@@ -298,7 +298,7 @@
getOptions()
{
ValidationPolicyCommandInterest::Options options;
- options.gracePeriod = time::seconds(15);
+ options.gracePeriod = 15_s;
options.maxRecords = 3;
return options;
}
@@ -319,9 +319,9 @@
auto i2 = makeCommandInterest(id3);
auto i3 = makeCommandInterest(id4);
auto i00 = makeCommandInterest(id1); // signed at 0s
- advanceClocks(time::seconds(1));
+ advanceClocks(1_s);
auto i01 = makeCommandInterest(id1); // signed at 1s
- advanceClocks(time::seconds(1));
+ advanceClocks(1_s);
auto i02 = makeCommandInterest(id1); // signed at 2s
VALIDATE_SUCCESS(i00, "Should succeed");
@@ -349,7 +349,7 @@
getOptions()
{
ValidationPolicyCommandInterest::Options options;
- options.gracePeriod = time::seconds(15);
+ options.gracePeriod = 15_s;
options.maxRecords = -1;
return options;
}
@@ -365,7 +365,7 @@
}
auto i1 = makeCommandInterest(identities.at(0)); // signed at 0s
- advanceClocks(time::seconds(1));
+ advanceClocks(1_s);
for (int i = 0; i < 20; ++i) {
auto i2 = makeCommandInterest(identities.at(i)); // signed at +1s
@@ -382,7 +382,7 @@
getOptions()
{
ValidationPolicyCommandInterest::Options options;
- options.gracePeriod = time::seconds(15);
+ options.gracePeriod = 15_s;
options.maxRecords = 0;
return options;
}
@@ -391,7 +391,7 @@
BOOST_FIXTURE_TEST_CASE(ZeroRecords, ValidationPolicyCommandInterestFixture<ZeroRecordsOptions>)
{
auto i1 = makeCommandInterest(identity); // signed at 0s
- advanceClocks(time::seconds(1));
+ advanceClocks(1_s);
auto i2 = makeCommandInterest(identity); // signed at +1s
VALIDATE_SUCCESS(i2, "Should succeed");
rewindClockAfterValidation();
@@ -406,8 +406,8 @@
getOptions()
{
ValidationPolicyCommandInterest::Options options;
- options.gracePeriod = time::seconds(400);
- options.recordLifetime = time::seconds(300);
+ options.gracePeriod = 400_s;
+ options.recordLifetime = 300_s;
return options;
}
};
@@ -415,19 +415,19 @@
BOOST_FIXTURE_TEST_CASE(LimitedRecordLifetime, ValidationPolicyCommandInterestFixture<LimitedRecordLifetimeOptions>)
{
auto i1 = makeCommandInterest(identity); // signed at 0s
- advanceClocks(time::seconds(240));
+ advanceClocks(240_s);
auto i2 = makeCommandInterest(identity); // signed at +240s
- advanceClocks(time::seconds(120));
+ advanceClocks(120_s);
auto i3 = makeCommandInterest(identity); // signed at +360s
- systemClock->advance(time::seconds(-360)); // rewind system clock to 0s
+ systemClock->advance(-360_s); // rewind system clock to 0s
VALIDATE_SUCCESS(i1, "Should succeed");
rewindClockAfterValidation();
VALIDATE_SUCCESS(i3, "Should succeed");
rewindClockAfterValidation();
- advanceClocks(time::seconds(30), time::seconds(301)); // advance steady clock by 301s, and system clock to +301s
+ advanceClocks(30_s, 301_s); // advance steady clock by 301s, and system clock to +301s
VALIDATE_SUCCESS(i2, "Should succeed despite timestamp is reordered, because record has been expired");
}
@@ -438,7 +438,7 @@
getOptions()
{
ValidationPolicyCommandInterest::Options options;
- options.gracePeriod = time::seconds(15);
+ options.gracePeriod = 15_s;
options.recordLifetime = time::seconds::zero();
return options;
}
@@ -447,7 +447,7 @@
BOOST_FIXTURE_TEST_CASE(ZeroRecordLifetime, ValidationPolicyCommandInterestFixture<ZeroRecordLifetimeOptions>)
{
auto i1 = makeCommandInterest(identity); // signed at 0s
- advanceClocks(time::seconds(1));
+ advanceClocks(1_s);
auto i2 = makeCommandInterest(identity); // signed at +1s
VALIDATE_SUCCESS(i2, "Should succeed");
rewindClockAfterValidation();
diff --git a/tests/unit-tests/security/v2/validation-policy-config.t.cpp b/tests/unit-tests/security/v2/validation-policy-config.t.cpp
index 7808700..31cba27 100644
--- a/tests/unit-tests/security/v2/validation-policy-config.t.cpp
+++ b/tests/unit-tests/security/v2/validation-policy-config.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -232,7 +232,7 @@
static time::milliseconds
getRefreshTime()
{
- return time::hours(1);
+ return 1_h;
}
};
@@ -248,7 +248,7 @@
static time::milliseconds
getRefreshTime()
{
- return time::minutes(1);
+ return 1_min;
}
};
@@ -264,7 +264,7 @@
static time::milliseconds
getRefreshTime()
{
- return time::seconds(1);
+ return 1_s;
}
};
diff --git a/tests/unit-tests/security/v2/validator-fixture.hpp b/tests/unit-tests/security/v2/validator-fixture.hpp
index 7f52048..c9a5763 100644
--- a/tests/unit-tests/security/v2/validator-fixture.hpp
+++ b/tests/unit-tests/security/v2/validator-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -43,7 +43,7 @@
: face(io, {true, true})
, validator(make_unique<ValidationPolicy>(), make_unique<CertificateFetcher>(face))
, policy(static_cast<ValidationPolicy&>(validator.getPolicy()))
- , cache(time::days(100))
+ , cache(100_days)
{
processInterest = [this] (const Interest& interest) {
auto cert = cache.find(interest);
diff --git a/tests/unit-tests/security/v2/validator.t.cpp b/tests/unit-tests/security/v2/validator.t.cpp
index ac5ca86..af64557 100644
--- a/tests/unit-tests/security/v2/validator.t.cpp
+++ b/tests/unit-tests/security/v2/validator.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -104,8 +104,8 @@
{
Data expiredCert = subIdentity.getDefaultKey().getDefaultCertificate();
SignatureInfo info;
- info.setValidityPeriod(ValidityPeriod(time::system_clock::now() - time::hours(2),
- time::system_clock::now() - time::hours(1)));
+ info.setValidityPeriod(ValidityPeriod(time::system_clock::now() - 2_h,
+ time::system_clock::now() - 1_h));
m_keyChain.sign(expiredCert, signingByIdentity(identity).setSignatureInfo(info));
BOOST_REQUIRE_NO_THROW(Certificate(expiredCert.wireEncode()));
@@ -150,7 +150,7 @@
BOOST_CHECK_EQUAL(face.sentInterests.size(), 0);
face.sentInterests.clear();
- advanceClocks(time::hours(1), 2); // expire trusted cache
+ advanceClocks(1_h, 2); // expire trusted cache
VALIDATE_FAILURE(data, "Should try and fail to retrieve certs");
BOOST_CHECK_GT(face.sentInterests.size(), 1);
@@ -187,7 +187,7 @@
BOOST_CHECK_EQUAL(face.sentInterests.size(), 0);
face.sentInterests.clear();
- advanceClocks(time::minutes(10), 2); // expire untrusted cache
+ advanceClocks(10_min, 2); // expire untrusted cache
VALIDATE_FAILURE(data, "Should try and fail to retrieve certs");
BOOST_CHECK_GT(face.sentInterests.size(), 1);
@@ -246,7 +246,7 @@
BOOST_CHECK_EQUAL(face.sentInterests.size(), 0);
face.sentInterests.clear();
- advanceClocks(time::hours(1), 2); // expire trusted cache
+ advanceClocks(1_h, 2); // expire trusted cache
m_keyChain.sign(interest, signingByIdentity(subSelfSignedIdentity));
m_keyChain.sign(data, signingByIdentity(subSelfSignedIdentity));
@@ -272,15 +272,15 @@
// set metainfo
certificate.setContentType(tlv::ContentType_Key);
- certificate.setFreshnessPeriod(time::hours(1));
+ certificate.setFreshnessPeriod(1_h);
// set content
certificate.setContent(requestedKey.getPublicKey().data(), requestedKey.getPublicKey().size());
// set signature-info
SignatureInfo info;
- info.setValidityPeriod(security::ValidityPeriod(time::system_clock::now() - time::days(10),
- time::system_clock::now() + time::days(10)));
+ info.setValidityPeriod(security::ValidityPeriod(time::system_clock::now() - 10_days,
+ time::system_clock::now() + 10_days));
m_keyChain.sign(certificate, signingByKey(parentKey).setSignatureInfo(info));
face.receive(certificate);
@@ -295,7 +295,7 @@
BOOST_CHECK_EQUAL(face.sentInterests.size(), 40);
face.sentInterests.clear();
- advanceClocks(time::hours(1), 5); // expire caches
+ advanceClocks(1_h, 5); // expire caches
validator.setMaxDepth(30);
BOOST_CHECK_EQUAL(validator.getMaxDepth(), 30);
@@ -315,8 +315,8 @@
request.setName(Name(key.getName()).append("looper").appendVersion());
SignatureInfo info;
- info.setValidityPeriod({time::system_clock::now() - time::days(100),
- time::system_clock::now() + time::days(100)});
+ info.setValidityPeriod({time::system_clock::now() - 100_days,
+ time::system_clock::now() + 100_days});
m_keyChain.sign(request, signingByKey(signer).setSignatureInfo(info));
m_keyChain.addCertificate(key, request);
diff --git a/tests/unit-tests/security/validity-period.t.cpp b/tests/unit-tests/security/validity-period.t.cpp
index 1fc91cd..4c6fb6b 100644
--- a/tests/unit-tests/security/validity-period.t.cpp
+++ b/tests/unit-tests/security/validity-period.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -38,22 +38,20 @@
{
time::system_clock::TimePoint now = this->systemClock->getNow();
- time::system_clock::TimePoint notBefore = now - time::days(1);
- time::system_clock::TimePoint notAfter = notBefore + time::days(2);
+ time::system_clock::TimePoint notBefore = now - 1_day;
+ time::system_clock::TimePoint notAfter = notBefore + 2_days;
ValidityPeriod validity1 = ValidityPeriod(notBefore, notAfter);
auto period = validity1.getPeriod();
BOOST_CHECK_GE(period.first, notBefore); // fractional seconds will be removed
- BOOST_CHECK_LT(period.first, notBefore + time::seconds(1));
+ BOOST_CHECK_LT(period.first, notBefore + 1_s);
BOOST_CHECK_LE(period.second, notAfter); // fractional seconds will be removed
- BOOST_CHECK_GT(period.second, notAfter - time::seconds(1));
+ BOOST_CHECK_GT(period.second, notAfter - 1_s);
BOOST_CHECK_EQUAL(validity1.isValid(), true);
- BOOST_CHECK_EQUAL(ValidityPeriod(now - time::days(2),
- now - time::days(1)).isValid(),
- false);
+ BOOST_CHECK_EQUAL(ValidityPeriod(now - 2_days, now - 1_day).isValid(), false);
BOOST_CHECK_NO_THROW((ValidityPeriod()));
ValidityPeriod validity2;
@@ -63,17 +61,17 @@
BOOST_CHECK(validity2.getPeriod() != std::make_pair(time::getUnixEpoch(), time::getUnixEpoch()));
BOOST_CHECK_EQUAL(validity2, validity1);
- validity1.setPeriod(time::getUnixEpoch(), time::getUnixEpoch() + time::days(10 * 365));
+ validity1.setPeriod(time::getUnixEpoch(), time::getUnixEpoch() + 10 * 365_days);
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(validity1),
"(19700101T000000, 19791230T000000)");
- validity1.setPeriod(time::getUnixEpoch() + time::nanoseconds(1),
- time::getUnixEpoch() + time::days(10 * 365) + time::nanoseconds(1));
+ validity1.setPeriod(time::getUnixEpoch() + 1_ns,
+ time::getUnixEpoch() + (10 * 365_days) + 1_ns);
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(validity1),
"(19700101T000001, 19791230T000000)");
BOOST_CHECK_EQUAL(ValidityPeriod(now, now).isValid(), true);
- BOOST_CHECK_EQUAL(ValidityPeriod(now + time::seconds(1), now).isValid(), false);
+ BOOST_CHECK_EQUAL(ValidityPeriod(now + 1_s, now).isValid(), false);
}
const uint8_t VP1[] = {
@@ -89,7 +87,7 @@
BOOST_AUTO_TEST_CASE(EncodingDecoding)
{
time::system_clock::TimePoint notBefore = time::getUnixEpoch();
- time::system_clock::TimePoint notAfter = notBefore + time::days(1);
+ time::system_clock::TimePoint notAfter = notBefore + 1_day;
ValidityPeriod v1(notBefore, notAfter);
@@ -182,8 +180,8 @@
BOOST_AUTO_TEST_CASE(Comparison)
{
time::system_clock::TimePoint notBefore = time::getUnixEpoch();
- time::system_clock::TimePoint notAfter = notBefore + time::days(1);
- time::system_clock::TimePoint notAfter2 = notBefore + time::days(2);
+ time::system_clock::TimePoint notAfter = notBefore + 1_day;
+ time::system_clock::TimePoint notAfter2 = notBefore + 2_days;
ValidityPeriod validity1(notBefore, notAfter);
ValidityPeriod validity2(notBefore, notAfter);
diff --git a/tests/unit-tests/signature-info.t.cpp b/tests/unit-tests/signature-info.t.cpp
index 9ca9cff..836c114 100644
--- a/tests/unit-tests/signature-info.t.cpp
+++ b/tests/unit-tests/signature-info.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -186,7 +186,7 @@
};
time::system_clock::TimePoint notBefore = time::getUnixEpoch();
- time::system_clock::TimePoint notAfter = notBefore + time::days(1);
+ time::system_clock::TimePoint notAfter = notBefore + 1_day;
security::ValidityPeriod vp1(notBefore, notAfter);
// encode
diff --git a/tests/unit-tests/util/dummy-client-face.t.cpp b/tests/unit-tests/util/dummy-client-face.t.cpp
index 8469d59..5308e28 100644
--- a/tests/unit-tests/util/dummy-client-face.t.cpp
+++ b/tests/unit-tests/util/dummy-client-face.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -37,11 +37,11 @@
bool isOverrideInvoked = false;
auto override = [&] (time::milliseconds timeout) {
isOverrideInvoked = true;
- BOOST_CHECK_EQUAL(timeout, time::milliseconds(200));
+ BOOST_CHECK_EQUAL(timeout, 200_ms);
};
DummyClientFace face(io, {false, false, override});
- face.processEvents(time::milliseconds(200));
+ face.processEvents(200_ms);
BOOST_CHECK(isOverrideInvoked);
}
@@ -67,7 +67,7 @@
return;
}, nullptr, nullptr);
- advanceClocks(time::milliseconds(25), 4);
+ advanceClocks(25_ms, 4);
int nFace1Data = 0;
int nFace2Nack = 0;
@@ -85,7 +85,7 @@
nFace2Nack++;
}, nullptr);
- advanceClocks(time::milliseconds(10), 100);
+ advanceClocks(10_ms, 100);
BOOST_CHECK_EQUAL(nFace1Data, 1);
BOOST_CHECK_EQUAL(nFace2Nack, 1);
diff --git a/tests/unit-tests/util/notification-stream.t.cpp b/tests/unit-tests/util/notification-stream.t.cpp
index faedec8..3721091 100644
--- a/tests/unit-tests/util/notification-stream.t.cpp
+++ b/tests/unit-tests/util/notification-stream.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017 Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,10 +26,10 @@
*/
#include "util/notification-stream.hpp"
-#include "simple-notification.hpp"
#include "util/dummy-client-face.hpp"
#include "boost-test.hpp"
+#include "simple-notification.hpp"
#include "../identity-management-time-fixture.hpp"
namespace ndn {
@@ -48,11 +48,10 @@
SimpleNotification event1("msg1");
notificationStream.postNotification(event1);
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
- BOOST_CHECK_EQUAL(face.sentData[0].getName(),
- "/localhost/nfd/NotificationStreamTest/%FE%00");
+ BOOST_CHECK_EQUAL(face.sentData[0].getName(), "/localhost/nfd/NotificationStreamTest/%FE%00");
SimpleNotification decoded1;
BOOST_CHECK_NO_THROW(decoded1.wireDecode(face.sentData[0].getContent().blockFromValue()));
BOOST_CHECK_EQUAL(decoded1.getMessage(), "msg1");
@@ -60,11 +59,10 @@
SimpleNotification event2("msg2");
notificationStream.postNotification(event2);
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_REQUIRE_EQUAL(face.sentData.size(), 2);
- BOOST_CHECK_EQUAL(face.sentData[1].getName(),
- "/localhost/nfd/NotificationStreamTest/%FE%01");
+ BOOST_CHECK_EQUAL(face.sentData[1].getName(), "/localhost/nfd/NotificationStreamTest/%FE%01");
SimpleNotification decoded2;
BOOST_CHECK_NO_THROW(decoded2.wireDecode(face.sentData[1].getContent().blockFromValue()));
BOOST_CHECK_EQUAL(decoded2.getMessage(), "msg2");
diff --git a/tests/unit-tests/util/notification-subscriber.t.cpp b/tests/unit-tests/util/notification-subscriber.t.cpp
index aef46a3..3fe3fd6 100644
--- a/tests/unit-tests/util/notification-subscriber.t.cpp
+++ b/tests/unit-tests/util/notification-subscriber.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017 Regents of the University of California,
+ * Copyright (c) 2014-2018 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -45,7 +45,7 @@
NotificationSubscriberFixture()
: streamPrefix("ndn:/NotificationSubscriberTest")
, subscriberFace(io, m_keyChain)
- , subscriber(subscriberFace, streamPrefix, time::seconds(1))
+ , subscriber(subscriberFace, streamPrefix, 1_s)
, nextSendNotificationNo(0)
{
}
@@ -61,7 +61,7 @@
dataName.appendSequenceNumber(nextSendNotificationNo);
Data data(dataName);
data.setContent(notification.wireEncode());
- data.setFreshnessPeriod(time::seconds(1));
+ data.setFreshnessPeriod(1_s);
m_keyChain.sign(data);
lastDeliveredSeqNo = nextSendNotificationNo;
@@ -185,7 +185,7 @@
this->connectHandlers();
subscriber.start();
BOOST_REQUIRE_EQUAL(subscriber.isRunning(), true);
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK(this->hasInitialRequest());
subscriberFace.sentInterests.clear();
@@ -198,19 +198,19 @@
{
this->connectHandlers();
subscriber.start();
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
// respond to initial request
subscriberFace.sentInterests.clear();
this->deliverNotification("n1");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n1");
BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
// respond to continuation request
subscriberFace.sentInterests.clear();
this->deliverNotification("n2");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n2");
BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
}
@@ -219,17 +219,17 @@
{
this->connectHandlers();
subscriber.start();
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
// send the first Nack to initial request
BOOST_REQUIRE_EQUAL(subscriberFace.sentInterests.size(), 1);
Interest interest = subscriberFace.sentInterests[0];
subscriberFace.sentInterests.clear();
this->deliverNack(interest, lp::NackReason::CONGESTION);
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(lastNack.getReason(), lp::NackReason::CONGESTION);
BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), false);
- advanceClocks(time::milliseconds(300));
+ advanceClocks(300_ms);
BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), true);
// send the second Nack to initial request
@@ -237,25 +237,25 @@
interest = subscriberFace.sentInterests[0];
subscriberFace.sentInterests.clear();
this->deliverNack(interest, lp::NackReason::CONGESTION);
- advanceClocks(time::milliseconds(301));
+ advanceClocks(301_ms);
BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), false);
- advanceClocks(time::milliseconds(200));
+ advanceClocks(200_ms);
BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), true);
// send a notification to initial request
subscriberFace.sentInterests.clear();
this->deliverNotification("n1");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
// send a Nack to subsequent request
BOOST_REQUIRE_EQUAL(subscriberFace.sentInterests.size(), 1);
interest = subscriberFace.sentInterests[0];
subscriberFace.sentInterests.clear();
this->deliverNack(interest, lp::NackReason::CONGESTION);
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(lastNack.getReason(), lp::NackReason::CONGESTION);
BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), false);
- advanceClocks(time::milliseconds(300));
+ advanceClocks(300_ms);
BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), true);
}
@@ -263,7 +263,7 @@
{
this->connectHandlers();
subscriber.start();
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
subscriberFace.sentInterests.clear();
lastNotification.setMessage("");
@@ -274,7 +274,7 @@
subscriberFace.sentInterests.clear();
this->deliverNotification("n1");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n1");
}
@@ -282,7 +282,7 @@
{
this->connectHandlers();
subscriber.start();
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
Name wrongName = streamPrefix;
wrongName.append("%07%07");
@@ -291,7 +291,7 @@
subscriberFace.receive(wrongData);
subscriberFace.sentInterests.clear();
lastNotification.setMessage("");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK(lastNotification.getMessage().empty());
BOOST_CHECK_EQUAL(lastDecodeErrorData.getName(), wrongName);
BOOST_CHECK(this->hasInitialRequest());
@@ -301,12 +301,12 @@
{
this->connectHandlers();
subscriber.start();
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
subscriberFace.sentInterests.clear();
lastNotification.setMessage("");
this->deliverNotification("\x07n4");
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_CHECK(lastNotification.getMessage().empty());
BOOST_CHECK(this->hasInitialRequest());
}
diff --git a/tests/unit-tests/util/scheduler.t.cpp b/tests/unit-tests/util/scheduler.t.cpp
index 8189f01..de54800 100644
--- a/tests/unit-tests/util/scheduler.t.cpp
+++ b/tests/unit-tests/util/scheduler.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -55,27 +55,27 @@
size_t count1 = 0;
size_t count2 = 0;
- scheduler.scheduleEvent(time::milliseconds(500), [&] {
+ scheduler.scheduleEvent(500_ms, [&] {
++count1;
BOOST_CHECK_EQUAL(count2, 1);
});
- EventId i = scheduler.scheduleEvent(time::seconds(1), [&] {
+ EventId i = scheduler.scheduleEvent(1_s, [&] {
BOOST_ERROR("This event should not have been fired");
});
scheduler.cancelEvent(i);
- scheduler.scheduleEvent(time::milliseconds(250), [&] {
+ scheduler.scheduleEvent(250_ms, [&] {
BOOST_CHECK_EQUAL(count1, 0);
++count2;
});
- i = scheduler.scheduleEvent(time::milliseconds(50), [&] {
+ i = scheduler.scheduleEvent(50_ms, [&] {
BOOST_ERROR("This event should not have been fired");
});
scheduler.cancelEvent(i);
- advanceClocks(time::milliseconds(25), time::milliseconds(1000));
+ advanceClocks(25_ms, 1000_ms);
BOOST_CHECK_EQUAL(count1, 1);
BOOST_CHECK_EQUAL(count2, 1);
}
@@ -85,13 +85,13 @@
class MyException : public std::exception
{
};
- scheduler.scheduleEvent(time::milliseconds(10), [] { BOOST_THROW_EXCEPTION(MyException()); });
+ scheduler.scheduleEvent(10_ms, [] { BOOST_THROW_EXCEPTION(MyException()); });
bool isCallbackInvoked = false;
- scheduler.scheduleEvent(time::milliseconds(20), [&isCallbackInvoked] { isCallbackInvoked = true; });
+ scheduler.scheduleEvent(20_ms, [&isCallbackInvoked] { isCallbackInvoked = true; });
- BOOST_CHECK_THROW(this->advanceClocks(time::milliseconds(6), 2), MyException);
- this->advanceClocks(time::milliseconds(6), 2);
+ BOOST_CHECK_THROW(this->advanceClocks(6_ms, 2), MyException);
+ this->advanceClocks(6_ms, 2);
BOOST_CHECK(isCallbackInvoked);
}
@@ -107,11 +107,11 @@
BOOST_AUTO_TEST_CASE(SelfCancel)
{
EventId selfEventId;
- selfEventId = scheduler.scheduleEvent(time::milliseconds(100), [&] {
+ selfEventId = scheduler.scheduleEvent(100_ms, [&] {
scheduler.cancelEvent(selfEventId);
});
- BOOST_REQUIRE_NO_THROW(advanceClocks(time::milliseconds(100), 10));
+ BOOST_REQUIRE_NO_THROW(advanceClocks(100_ms, 10));
}
class SelfRescheduleFixture : public SchedulerFixture
@@ -125,7 +125,7 @@
void
reschedule()
{
- EventId eventId = scheduler.scheduleEvent(time::milliseconds(100),
+ EventId eventId = scheduler.scheduleEvent(100_ms,
bind(&SelfRescheduleFixture::reschedule, this));
scheduler.cancelEvent(selfEventId);
selfEventId = eventId;
@@ -142,7 +142,7 @@
scheduler.cancelEvent(selfEventId);
if (count < 5) {
- selfEventId = scheduler.scheduleEvent(time::milliseconds(100),
+ selfEventId = scheduler.scheduleEvent(100_ms,
bind(&SelfRescheduleFixture::reschedule2, this));
count++;
}
@@ -153,12 +153,12 @@
{
scheduler.cancelEvent(selfEventId);
- scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
- scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
- scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
- scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
- scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
- scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
+ scheduler.scheduleEvent(100_ms, [&] { ++count; });
+ scheduler.scheduleEvent(100_ms, [&] { ++count; });
+ scheduler.scheduleEvent(100_ms, [&] { ++count; });
+ scheduler.scheduleEvent(100_ms, [&] { ++count; });
+ scheduler.scheduleEvent(100_ms, [&] { ++count; });
+ scheduler.scheduleEvent(100_ms, [&] { ++count; });
}
public:
@@ -168,30 +168,30 @@
BOOST_FIXTURE_TEST_CASE(Reschedule, SelfRescheduleFixture)
{
- selfEventId = scheduler.scheduleEvent(time::seconds(0),
+ selfEventId = scheduler.scheduleEvent(0_s,
bind(&SelfRescheduleFixture::reschedule, this));
- BOOST_REQUIRE_NO_THROW(advanceClocks(time::milliseconds(50), time::milliseconds(1000)));
+ BOOST_REQUIRE_NO_THROW(advanceClocks(50_ms, 1000_ms));
BOOST_CHECK_EQUAL(count, 5);
}
BOOST_FIXTURE_TEST_CASE(Reschedule2, SelfRescheduleFixture)
{
- selfEventId = scheduler.scheduleEvent(time::seconds(0),
+ selfEventId = scheduler.scheduleEvent(0_s,
bind(&SelfRescheduleFixture::reschedule2, this));
- BOOST_REQUIRE_NO_THROW(advanceClocks(time::milliseconds(50), time::milliseconds(1000)));
+ BOOST_REQUIRE_NO_THROW(advanceClocks(50_ms, 1000_ms));
BOOST_CHECK_EQUAL(count, 5);
}
BOOST_FIXTURE_TEST_CASE(Reschedule3, SelfRescheduleFixture)
{
- selfEventId = scheduler.scheduleEvent(time::seconds(0),
+ selfEventId = scheduler.scheduleEvent(0_s,
bind(&SelfRescheduleFixture::reschedule3, this));
- BOOST_REQUIRE_NO_THROW(advanceClocks(time::milliseconds(50), time::milliseconds(1000)));
+ BOOST_REQUIRE_NO_THROW(advanceClocks(50_ms, 1000_ms));
BOOST_CHECK_EQUAL(count, 6);
}
@@ -209,7 +209,7 @@
{
++count;
- scheduler.scheduleEvent(time::seconds(1), [&] { event(); });
+ scheduler.scheduleEvent(1_s, [&] { event(); });
}
public:
@@ -218,15 +218,15 @@
BOOST_FIXTURE_TEST_CASE(CancelAll, CancelAllFixture)
{
- scheduler.scheduleEvent(time::milliseconds(500), [&] { scheduler.cancelAllEvents(); });
+ scheduler.scheduleEvent(500_ms, [&] { scheduler.cancelAllEvents(); });
- scheduler.scheduleEvent(time::seconds(1), [&] { event(); });
+ scheduler.scheduleEvent(1_s, [&] { event(); });
- scheduler.scheduleEvent(time::seconds(3), [] {
+ scheduler.scheduleEvent(3_s, [] {
BOOST_ERROR("This event should have been cancelled" );
});
- advanceClocks(time::milliseconds(100), 100);
+ advanceClocks(100_ms, 100);
BOOST_CHECK_EQUAL(count, 0);
}
@@ -235,7 +235,7 @@
{
Scheduler sched(io);
ScopedEventId eid(sched);
- eid = sched.scheduleEvent(time::milliseconds(10), []{});
+ eid = sched.scheduleEvent(10_ms, []{});
sched.cancelAllEvents();
eid.cancel(); // should not crash
@@ -266,7 +266,7 @@
BOOST_CHECK_EQUAL(eid == nullptr, true);
BOOST_CHECK_EQUAL(eid != nullptr, false);
- eid = scheduler.scheduleEvent(time::milliseconds(10), []{});
+ eid = scheduler.scheduleEvent(10_ms, []{});
BOOST_CHECK_EQUAL(eid == eid2, false);
BOOST_CHECK_EQUAL(eid != eid2, true);
BOOST_CHECK_EQUAL(eid == nullptr, false);
@@ -276,7 +276,7 @@
BOOST_CHECK_EQUAL(eid == eid2, true);
BOOST_CHECK_EQUAL(eid != eid2, false);
- eid2 = scheduler.scheduleEvent(time::milliseconds(10), []{});
+ eid2 = scheduler.scheduleEvent(10_ms, []{});
BOOST_CHECK_EQUAL(eid == eid2, false);
BOOST_CHECK_EQUAL(eid != eid2, true);
}
@@ -287,7 +287,7 @@
BOOST_CHECK_EQUAL(static_cast<bool>(eid), false);
BOOST_CHECK_EQUAL(!eid, true);
- eid = scheduler.scheduleEvent(time::milliseconds(10), []{});
+ eid = scheduler.scheduleEvent(10_ms, []{});
BOOST_CHECK_EQUAL(static_cast<bool>(eid), true);
BOOST_CHECK_EQUAL(!eid, false);
@@ -302,10 +302,10 @@
BOOST_AUTO_TEST_CASE(DuringCallback)
{
EventId eid;
- EventId eid2 = scheduler.scheduleEvent(time::milliseconds(20), []{});
+ EventId eid2 = scheduler.scheduleEvent(20_ms, []{});
bool isCallbackInvoked = false;
- eid = scheduler.scheduleEvent(time::milliseconds(10), [this, &eid, &eid2, &isCallbackInvoked] {
+ eid = scheduler.scheduleEvent(10_ms, [this, &eid, &eid2, &isCallbackInvoked] {
isCallbackInvoked = true;
// eid is "expired" during callback execution
@@ -320,20 +320,20 @@
BOOST_CHECK_EQUAL(eid == eid2, true);
BOOST_CHECK_EQUAL(eid != eid2, false);
});
- this->advanceClocks(time::milliseconds(6), 2);
+ this->advanceClocks(6_ms, 2);
BOOST_CHECK(isCallbackInvoked);
}
BOOST_AUTO_TEST_CASE(Reset)
{
bool isCallbackInvoked = false;
- EventId eid = scheduler.scheduleEvent(time::milliseconds(10),
+ EventId eid = scheduler.scheduleEvent(10_ms,
[&isCallbackInvoked]{ isCallbackInvoked = true; });
eid.reset();
BOOST_CHECK_EQUAL(!eid, true);
BOOST_CHECK_EQUAL(eid == nullptr, true);
- this->advanceClocks(time::milliseconds(6), 2);
+ this->advanceClocks(6_ms, 2);
BOOST_CHECK(isCallbackInvoked);
}
@@ -344,7 +344,7 @@
EventId eid;
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(eid), nullString);
- eid = scheduler.scheduleEvent(time::milliseconds(10), []{});
+ eid = scheduler.scheduleEvent(10_ms, []{});
BOOST_TEST_MESSAGE("eid=" << eid);
BOOST_CHECK_NE(boost::lexical_cast<std::string>(eid), nullString);
}
@@ -360,9 +360,9 @@
int hit = 0;
{
ScopedEventId se(scheduler);
- se = scheduler.scheduleEvent(time::milliseconds(10), [&] { ++hit; });
+ se = scheduler.scheduleEvent(10_ms, [&] { ++hit; });
} // se goes out of scope
- this->advanceClocks(time::milliseconds(1), 15);
+ this->advanceClocks(1_ms, 15);
BOOST_CHECK_EQUAL(hit, 0);
}
@@ -370,9 +370,9 @@
{
int hit1 = 0, hit2 = 0;
ScopedEventId se1(scheduler);
- se1 = scheduler.scheduleEvent(time::milliseconds(10), [&] { ++hit1; });
- se1 = scheduler.scheduleEvent(time::milliseconds(10), [&] { ++hit2; });
- this->advanceClocks(time::milliseconds(1), 15);
+ se1 = scheduler.scheduleEvent(10_ms, [&] { ++hit1; });
+ se1 = scheduler.scheduleEvent(10_ms, [&] { ++hit2; });
+ this->advanceClocks(1_ms, 15);
BOOST_CHECK_EQUAL(hit1, 0);
BOOST_CHECK_EQUAL(hit2, 1);
}
@@ -382,10 +382,10 @@
int hit = 0;
{
ScopedEventId se(scheduler);
- se = scheduler.scheduleEvent(time::milliseconds(10), [&] { ++hit; });
+ se = scheduler.scheduleEvent(10_ms, [&] { ++hit; });
se.release();
} // se goes out of scope
- this->advanceClocks(time::milliseconds(1), 15);
+ this->advanceClocks(1_ms, 15);
BOOST_CHECK_EQUAL(hit, 1);
}
@@ -395,10 +395,10 @@
unique_ptr<scheduler::ScopedEventId> se2;
{
ScopedEventId se(scheduler);
- se = scheduler.scheduleEvent(time::milliseconds(10), [&] { ++hit; });
+ se = scheduler.scheduleEvent(10_ms, [&] { ++hit; });
se2.reset(new ScopedEventId(std::move(se)));
} // se goes out of scope
- this->advanceClocks(time::milliseconds(1), 15);
+ this->advanceClocks(1_ms, 15);
BOOST_CHECK_EQUAL(hit, 1);
}
diff --git a/tests/unit-tests/util/segment-fetcher.t.cpp b/tests/unit-tests/util/segment-fetcher.t.cpp
index 0b512e8..edcb9ca 100644
--- a/tests/unit-tests/util/segment-fetcher.t.cpp
+++ b/tests/unit-tests/util/segment-fetcher.t.cpp
@@ -82,7 +82,7 @@
const Interest& lastInterest = face.sentInterests.back();
lp::Nack nack = makeNack(lastInterest, nackReason);
face.receive(nack);
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
}
public:
@@ -98,12 +98,12 @@
BOOST_FIXTURE_TEST_CASE(Timeout, Fixture)
{
DummyValidator acceptValidator;
- SegmentFetcher::fetch(face, Interest("/hello/world", time::milliseconds(100)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", 100_ms),
acceptValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
const Interest& interest = face.sentInterests[0];
@@ -111,12 +111,12 @@
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), true);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 1);
- advanceClocks(time::milliseconds(98));
+ advanceClocks(98_ms);
BOOST_CHECK_EQUAL(nErrors, 0);
BOOST_CHECK_EQUAL(nData, 0);
BOOST_CHECK_EQUAL(face.sentData.size(), 0);
- advanceClocks(time::milliseconds(1), 2);
+ advanceClocks(1_ms, 2);
BOOST_CHECK_EQUAL(nErrors, 1);
BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::INTEREST_TIMEOUT));
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
@@ -127,15 +127,15 @@
BOOST_FIXTURE_TEST_CASE(Basic, Fixture)
{
DummyValidator acceptValidator;
- SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
acceptValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeDataSegment("/hello/world/version0", 0, true));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_CHECK_EQUAL(nErrors, 0);
BOOST_CHECK_EQUAL(nData, 1);
@@ -159,19 +159,19 @@
BOOST_FIXTURE_TEST_CASE(NoSegmentInData, Fixture)
{
DummyValidator acceptValidator;
- SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
acceptValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
const uint8_t buffer[] = "Hello, world!";
auto data = makeData("/hello/world/version0/no-segment");
data->setContent(buffer, sizeof(buffer));
face.receive(*data);
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_CHECK_EQUAL(nErrors, 1);
BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::DATA_HAS_NO_SEGMENT));
@@ -181,14 +181,14 @@
BOOST_FIXTURE_TEST_CASE(SegmentValidationFailure, Fixture)
{
DummyValidator rejectValidator(false);
- SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
rejectValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeDataSegment("/hello/world/version0", 0, true));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_CHECK_EQUAL(nErrors, 1);
BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::SEGMENT_VALIDATION_FAIL));
@@ -198,21 +198,21 @@
BOOST_FIXTURE_TEST_CASE(Triple, Fixture)
{
DummyValidator acceptValidator;
- SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
acceptValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeDataSegment("/hello/world/version0", 0, false));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeDataSegment("/hello/world/version0", 1, false));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeDataSegment("/hello/world/version0", 2, true));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_CHECK_EQUAL(nErrors, 0);
BOOST_CHECK_EQUAL(nData, 1);
@@ -247,24 +247,24 @@
BOOST_FIXTURE_TEST_CASE(TripleWithInitialSegmentFetching, Fixture)
{
DummyValidator acceptValidator;
- SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
acceptValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeDataSegment("/hello/world/version0", 1, false));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeDataSegment("/hello/world/version0", 0, false));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeDataSegment("/hello/world/version0", 1, false));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeDataSegment("/hello/world/version0", 2, true));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_CHECK_EQUAL(nErrors, 0);
BOOST_CHECK_EQUAL(nData, 1);
@@ -306,21 +306,21 @@
BOOST_FIXTURE_TEST_CASE(MultipleSegmentFetching, Fixture)
{
DummyValidator acceptValidator;
- SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
acceptValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
for (uint64_t i = 0; i < 400; i++) {
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeDataSegment("/hello/world/version0", i, false));
}
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
face.receive(*makeDataSegment("/hello/world/version0", 400, true));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
BOOST_CHECK_EQUAL(nErrors, 0);
BOOST_CHECK_EQUAL(nData, 1);
@@ -328,11 +328,11 @@
BOOST_FIXTURE_TEST_CASE(DuplicateNack, Fixture)
{
- SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
make_shared<DummyValidator>(true),
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
// receive nack for the original interest
nackLastInterest(lp::NackReason::DUPLICATE);
@@ -348,11 +348,11 @@
BOOST_FIXTURE_TEST_CASE(CongestionNack, Fixture)
{
- SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
make_shared<DummyValidator>(true),
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
// receive nack for the original interest
nackLastInterest(lp::NackReason::CONGESTION);
@@ -377,19 +377,19 @@
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
- advanceClocks(time::milliseconds(1000));
+ advanceClocks(1000_ms);
for (uint64_t segmentNo = 0; segmentNo <= 3; segmentNo++) {
if (segmentNo == 1) {
while (nNacks--) {
nackLastInterest(lp::NackReason::CONGESTION);
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
}
}
auto data = makeDataSegment(interestName, segmentNo, segmentNo == 3);
face.receive(*data);
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
}
// Total number of sent interests should be 6: one interest for segment zero and segment one each,
@@ -411,7 +411,7 @@
make_shared<DummyValidator>(true),
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
- advanceClocks(time::milliseconds(10));
+ advanceClocks(10_ms);
nackLastInterest(lp::NackReason::DUPLICATE);
face.receive(*makeDataSegment("/hello/world", 0, true));
@@ -430,7 +430,7 @@
return flipResult;
});
shared_ptr<SegmentFetcher> fetcher =
- SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
validator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
@@ -448,15 +448,15 @@
++nValidatedSegments;
});
- advanceClocks(time::milliseconds(10), 10);
+ advanceClocks(10_ms, 10);
face.receive(*data1);
- advanceClocks(time::milliseconds(10), 10);
+ advanceClocks(10_ms, 10);
face.receive(*data2);
- advanceClocks(time::milliseconds(10), 10);
+ advanceClocks(10_ms, 10);
BOOST_CHECK_EQUAL(nRecvSegments, 2);
BOOST_CHECK_EQUAL(nValidatedSegments, 1);
diff --git a/tests/unit-tests/util/time-unit-test-clock.t.cpp b/tests/unit-tests/util/time-unit-test-clock.t.cpp
index 20330fd..dd8346a 100644
--- a/tests/unit-tests/util/time-unit-test-clock.t.cpp
+++ b/tests/unit-tests/util/time-unit-test-clock.t.cpp
@@ -43,11 +43,11 @@
BOOST_CHECK_EQUAL(time::system_clock::now().time_since_epoch(),
time::UnitTestClockTraits<time::system_clock>::getDefaultStartTime());
- steadyClock->advance(time::days(1));
+ steadyClock->advance(1_day);
BOOST_CHECK_EQUAL(time::system_clock::now().time_since_epoch(),
time::UnitTestClockTraits<time::system_clock>::getDefaultStartTime());
- systemClock->advance(time::days(1));
+ systemClock->advance(1_day);
BOOST_CHECK_GT(time::system_clock::now().time_since_epoch(),
time::UnitTestClockTraits<time::system_clock>::getDefaultStartTime());
@@ -77,16 +77,16 @@
BOOST_CHECK_EQUAL(time::fromIsoString("20140129T034247.032000"), referenceTime);
BOOST_CHECK_EQUAL(time::fromIsoString("20140129T034247.032000Z"), referenceTime);
BOOST_CHECK_EQUAL(time::fromString("2014-01-29 03:42:47"),
- time::fromUnixTimestamp(time::seconds(1390966967)));
+ time::fromUnixTimestamp(1390966967_s));
// Unfortunately, not all systems has lv_LV locale installed :(
// BOOST_CHECK_EQUAL(time::fromString("2014. gada 29. Janvāris", "%Y. gada %d. %B",
// std::locale("lv_LV.UTF-8")),
- // time::fromUnixTimestamp(time::seconds(1390953600)));
+ // time::fromUnixTimestamp(1390953600_s));
BOOST_CHECK_EQUAL(time::fromString("2014 -- 29 -- January", "%Y -- %d -- %B",
std::locale("C")),
- time::fromUnixTimestamp(time::seconds(1390953600)));
+ time::fromUnixTimestamp(1390953600_s));
}
BOOST_AUTO_TEST_CASE(SteadyClock)
@@ -98,18 +98,18 @@
BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(),
time::steady_clock::duration::zero());
- systemClock->advance(time::days(36500));
+ systemClock->advance(36500_days);
BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(),
time::steady_clock::duration::zero());
- steadyClock->advance(time::nanoseconds(100));
- BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), time::nanoseconds(100));
+ steadyClock->advance(100_ns);
+ BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), 100_ns);
- steadyClock->advance(time::microseconds(100));
- BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), time::nanoseconds(100100));
+ steadyClock->advance(100_us);
+ BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), 100100_ns);
- steadyClock->setNow(time::milliseconds(1));
- BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), time::nanoseconds(1000000));
+ 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");
@@ -120,12 +120,12 @@
ndn::Scheduler scheduler(io);
bool hasFired = false;
- scheduler.scheduleEvent(time::seconds(100), [&] { hasFired = true; });
+ scheduler.scheduleEvent(100_s, [&] { hasFired = true; });
io.poll();
BOOST_CHECK_EQUAL(hasFired, false);
- steadyClock->advance(time::seconds(100));
+ steadyClock->advance(100_s);
io.poll();
BOOST_CHECK_EQUAL(hasFired, true);
diff --git a/tests/unit-tests/util/time.t.cpp b/tests/unit-tests/util/time.t.cpp
index 3d7160d..58fdfae 100644
--- a/tests/unit-tests/util/time.t.cpp
+++ b/tests/unit-tests/util/time.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -23,6 +23,8 @@
#include "boost-test.hpp"
+#include <thread>
+
namespace ndn {
namespace time {
namespace tests {
@@ -42,12 +44,10 @@
BOOST_CHECK_EQUAL(toString(referenceTime), "2014-01-29 03:42:47");
// Unfortunately, not all systems has lv_LV locale installed :(
- // BOOST_CHECK_EQUAL(toString(referenceTime, "%Y. gada %d. %B",
- // std::locale("lv_LV.UTF-8")),
+ // BOOST_CHECK_EQUAL(toString(referenceTime, "%Y. gada %d. %B", std::locale("lv_LV.UTF-8")),
// "2014. gada 29. Janvāris");
- BOOST_CHECK_EQUAL(toString(referenceTime, "%Y -- %d -- %B",
- std::locale("C")),
+ BOOST_CHECK_EQUAL(toString(referenceTime, "%Y -- %d -- %B", std::locale("C")),
"2014 -- 29 -- January");
BOOST_CHECK_EQUAL(fromIsoString("20140129T034247.032000"), referenceTime);
@@ -56,21 +56,18 @@
fromUnixTimestamp(seconds(1390966967)));
// Unfortunately, not all systems has lv_LV locale installed :(
- // BOOST_CHECK_EQUAL(fromString("2014. gada 29. Janvāris", "%Y. gada %d. %B",
- // std::locale("lv_LV.UTF-8")),
+ // BOOST_CHECK_EQUAL(fromString("2014. gada 29. Janvāris", "%Y. gada %d. %B", std::locale("lv_LV.UTF-8")),
// fromUnixTimestamp(seconds(1390953600)));
- BOOST_CHECK_EQUAL(fromString("2014 -- 29 -- January", "%Y -- %d -- %B",
- std::locale("C")),
+ BOOST_CHECK_EQUAL(fromString("2014 -- 29 -- January", "%Y -- %d -- %B", std::locale("C")),
fromUnixTimestamp(seconds(1390953600)));
}
BOOST_AUTO_TEST_CASE(SteadyClock)
{
steady_clock::TimePoint oldValue = steady_clock::now();
- usleep(100);
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
steady_clock::TimePoint newValue = steady_clock::now();
-
BOOST_CHECK_GT(newValue, oldValue);
}
@@ -83,13 +80,41 @@
BOOST_AUTO_TEST_CASE(LargeDates)
{
- system_clock::TimePoint value = fromUnixTimestamp(milliseconds(1390966967032LL));
+ auto value = fromUnixTimestamp(milliseconds(1390966967032LL));
BOOST_CHECK_EQUAL(toIsoString(value), "20140129T034247.032000");
value += days(365 * 100 + 25 - 1); // 36524 days
BOOST_CHECK_EQUAL(toIsoString(value), "21140129T034247.032000");
}
+BOOST_AUTO_TEST_CASE(Literals)
+{
+ BOOST_CHECK_EQUAL(42_s, seconds(42));
+
+ BOOST_CHECK_EQUAL(1_day, 24_h);
+ BOOST_CHECK_EQUAL(2_days, 48_h);
+ BOOST_CHECK_EQUAL(0.5_day, 12_h);
+ BOOST_CHECK_EQUAL(.5_days, 12_h);
+
+ BOOST_CHECK_EQUAL(1_h, 60_min);
+ BOOST_CHECK_EQUAL(0.5_h, 30_min);
+
+ BOOST_CHECK_EQUAL(1_min, 60_s);
+ BOOST_CHECK_EQUAL(0.5_min, 30_s);
+
+ BOOST_CHECK_EQUAL(1_s, 1000_ms);
+ BOOST_CHECK_EQUAL(0.5_s, 500_ms);
+
+ BOOST_CHECK_EQUAL(1_ms, 1000_us);
+ BOOST_CHECK_EQUAL(0.5_ms, 500_us);
+
+ BOOST_CHECK_EQUAL(1_us, 1000_ns);
+ BOOST_CHECK_EQUAL(0.5_us, 500_ns);
+
+ BOOST_CHECK_EQUAL(1_ns, nanoseconds(1));
+ BOOST_CHECK_EQUAL(5.5_ns, 0.0055_us);
+}
+
BOOST_AUTO_TEST_SUITE_END() // TestTime
BOOST_AUTO_TEST_SUITE_END() // Util