util: add literal operators for duration types
Change-Id: I007fa61c80e535c6e4b12e85a32eeeee62fecc3c
Refs: #4468
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);