util: remove ndn::optional, use std::optional directly
Change-Id: I503e8f250e80e0ff7708070effc2e84e3b38b3b7
diff --git a/tests/unit/security/certificate-cache.t.cpp b/tests/unit/security/certificate-cache.t.cpp
index 8c715eb..51aa72b 100644
--- a/tests/unit/security/certificate-cache.t.cpp
+++ b/tests/unit/security/certificate-cache.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -43,7 +43,7 @@
}
void
- checkFindByInterest(const Name& name, bool canBePrefix, optional<Certificate> expected) const
+ checkFindByInterest(const Name& name, bool canBePrefix, std::optional<Certificate> expected) const
{
Interest interest(name);
interest.setCanBePrefix(canBePrefix);
@@ -95,10 +95,10 @@
checkFindByInterest(cert.getIdentity(), true, cert);
checkFindByInterest(cert.getKeyName(), true, cert);
checkFindByInterest(cert.getName(), false, cert);
- checkFindByInterest(Name(cert.getName()).appendVersion(), true, nullopt);
+ checkFindByInterest(Name(cert.getName()).appendVersion(), true, std::nullopt);
advanceClocks(12_s);
- checkFindByInterest(cert.getIdentity(), true, nullopt);
+ checkFindByInterest(cert.getIdentity(), true, std::nullopt);
}
BOOST_AUTO_TEST_SUITE_END() // TestCertificateCache
diff --git a/tests/unit/security/certificate.t.cpp b/tests/unit/security/certificate.t.cpp
index f113ca9..37243d6 100644
--- a/tests/unit/security/certificate.t.cpp
+++ b/tests/unit/security/certificate.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -366,7 +366,7 @@
sigInfo.removeCustomTlv(tlv::AdditionalDescription);
sigInfo.addCustomTlv(makeStringBlock(tlv::ValidityPeriod, "malformed"));
sigInfo.setSignatureType(tlv::DigestSha256);
- sigInfo.setKeyLocator(nullopt);
+ sigInfo.setKeyLocator(std::nullopt);
Certificate cert6(cert3);
cert6.setSignatureInfo(sigInfo);
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(cert6), expected6);
diff --git a/tests/unit/security/key-chain.t.cpp b/tests/unit/security/key-chain.t.cpp
index 98a0721..9bd97af 100644
--- a/tests/unit/security/key-chain.t.cpp
+++ b/tests/unit/security/key-chain.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -427,7 +427,7 @@
const uint32_t expectedSigType = SignatureTypeTlvValue;
const bool shouldHaveKeyLocator = true;
- const optional<KeyLocator> expectedKeyLocator = cert.getName();
+ const std::optional<KeyLocator> expectedKeyLocator = cert.getName();
bool
verify(const SigningInfo&) const
@@ -504,7 +504,7 @@
const uint32_t expectedSigType = SignatureTypeTlvValue;
const bool shouldHaveKeyLocator = true;
- const optional<KeyLocator> expectedKeyLocator = nullopt; // don't check KeyLocator value
+ const std::optional<KeyLocator> expectedKeyLocator = std::nullopt; // don't check KeyLocator value
bool
verify(const SigningInfo& si) const
@@ -524,12 +524,12 @@
const uint32_t expectedSigType = tlv::DigestSha256;
const bool shouldHaveKeyLocator = false;
- const optional<KeyLocator> expectedKeyLocator = nullopt;
+ const std::optional<KeyLocator> expectedKeyLocator = std::nullopt;
bool
verify(const SigningInfo&) const
{
- return verifySignature(this->packet, nullopt);
+ return verifySignature(this->packet, std::nullopt);
}
};
@@ -591,7 +591,8 @@
}
void
- checkKeyLocatorName(const Certificate& cert, const optional<Name>& klName = nullopt) const
+ checkKeyLocatorName(const Certificate& cert,
+ const std::optional<Name>& klName = std::nullopt) const
{
auto kl = cert.getKeyLocator();
if (!kl.has_value()) {
diff --git a/tests/unit/security/trust-anchor-container.t.cpp b/tests/unit/security/trust-anchor-container.t.cpp
index 19d6867..09825db 100644
--- a/tests/unit/security/trust-anchor-container.t.cpp
+++ b/tests/unit/security/trust-anchor-container.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -20,7 +20,6 @@
*/
#include "ndn-cxx/security/trust-anchor-container.hpp"
-#include "ndn-cxx/util/io.hpp"
#include "tests/boost-test.hpp"
#include "tests/key-chain-fixture.hpp"
@@ -61,7 +60,7 @@
}
void
- checkFindByInterest(const Name& name, bool canBePrefix, optional<Certificate> expected) const
+ checkFindByInterest(const Name& name, bool canBePrefix, std::optional<Certificate> expected) const
{
Interest interest(name);
interest.setCanBePrefix(canBePrefix);
@@ -172,7 +171,7 @@
checkFindByInterest(identity1.getName().getPrefix(-1), true, cert1);
checkFindByInterest(cert1.getKeyName(), true, cert1);
checkFindByInterest(cert1.getName(), false, cert1);
- checkFindByInterest(Name(identity1.getName()).appendVersion(), true, nullopt);
+ checkFindByInterest(Name(identity1.getName()).appendVersion(), true, std::nullopt);
auto makeIdentity1Cert = [=] (const std::string& issuerId) {
auto key = identity1.getDefaultKey();
diff --git a/tests/unit/security/validation-policy-command-interest.t.cpp b/tests/unit/security/validation-policy-command-interest.t.cpp
index 604c60d..971b509 100644
--- a/tests/unit/security/validation-policy-command-interest.t.cpp
+++ b/tests/unit/security/validation-policy-command-interest.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -64,16 +64,16 @@
{
protected:
Interest
- makeCommandInterest(const Identity& identity, SignedInterestFormat format = SignedInterestFormat::V02)
+ makeCommandInterest(const Identity& id, SignedInterestFormat format = SignedInterestFormat::V02)
{
- Name name = identity.getName();
+ Name name = id.getName();
name.append("CMD");
switch (format) {
case SignedInterestFormat::V02:
- return m_signer.makeCommandInterest(name, signingByIdentity(identity));
+ return m_signer.makeCommandInterest(name, signingByIdentity(id));
case SignedInterestFormat::V03: {
Interest interest(name);
- m_signer.makeSignedInterest(interest, signingByIdentity(identity));
+ m_signer.makeSignedInterest(interest, signingByIdentity(id));
return interest;
}
}
@@ -198,7 +198,7 @@
{
auto i1 = makeCommandInterest(identity, SignedInterestFormat::V03);
auto si = i1.getSignatureInfo().value();
- si.setTime(nullopt);
+ si.setTime(std::nullopt);
i1.setSignatureInfo(si);
VALIDATE_FAILURE(i1, "Should fail (timestamp is missing)");
BOOST_TEST(lastError.getCode() == ValidationError::POLICY_ERROR);
@@ -218,7 +218,7 @@
{
auto i1 = makeCommandInterest(identity, SignedInterestFormat::V03);
auto si = i1.getSignatureInfo().value();
- si.setKeyLocator(nullopt);
+ si.setKeyLocator(std::nullopt);
i1.setSignatureInfo(si);
VALIDATE_FAILURE(i1, "Should fail (missing KeyLocator)");
BOOST_TEST(lastError.getCode() == ValidationError::INVALID_KEY_LOCATOR);
diff --git a/tests/unit/security/validator-fixture.hpp b/tests/unit/security/validator-fixture.hpp
index d8d357f..7e1e0b5 100644
--- a/tests/unit/security/validator-fixture.hpp
+++ b/tests/unit/security/validator-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -158,7 +158,7 @@
private:
void
- verifyOriginalPacket(const optional<Certificate>&) override
+ verifyOriginalPacket(const std::optional<Certificate>&) override
{
// do nothing
}
diff --git a/tests/unit/security/verification-helpers.t.cpp b/tests/unit/security/verification-helpers.t.cpp
index d3434c8..83d37da 100644
--- a/tests/unit/security/verification-helpers.t.cpp
+++ b/tests/unit/security/verification-helpers.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2022 Regents of the University of California.
+ * Copyright (c) 2013-2023 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -632,21 +632,21 @@
Interest interestOldFormat(dataset.goodInterestOldFormat);
Interest badSigInterestOldFormat(dataset.badSigInterestOldFormat);
- BOOST_CHECK(verifySignature(data, nullopt));
- BOOST_CHECK(verifySignature(interest, nullopt));
- BOOST_CHECK(verifySignature(interestOldFormat, nullopt));
+ BOOST_CHECK(verifySignature(data, std::nullopt));
+ BOOST_CHECK(verifySignature(interest, std::nullopt));
+ BOOST_CHECK(verifySignature(interestOldFormat, std::nullopt));
- BOOST_CHECK(!verifySignature(badSigData, nullopt));
- BOOST_CHECK(!verifySignature(badSigInterest, nullopt));
- BOOST_CHECK(!verifySignature(badSigInterestOldFormat, nullopt));
+ BOOST_CHECK(!verifySignature(badSigData, std::nullopt));
+ BOOST_CHECK(!verifySignature(badSigInterest, std::nullopt));
+ BOOST_CHECK(!verifySignature(badSigInterestOldFormat, std::nullopt));
Data unsignedData("/some/data");
Interest unsignedInterest1("/some/interest/with/several/name/components");
Interest unsignedInterest2("/interest-with-one-name-component");
- BOOST_CHECK(!verifySignature(unsignedData, nullopt));
- BOOST_CHECK(!verifySignature(unsignedInterest1, nullopt));
- BOOST_CHECK(!verifySignature(unsignedInterest2, nullopt));
+ BOOST_CHECK(!verifySignature(unsignedData, std::nullopt));
+ BOOST_CHECK(!verifySignature(unsignedInterest1, std::nullopt));
+ BOOST_CHECK(!verifySignature(unsignedInterest2, std::nullopt));
}
const uint8_t sha256DataUnrecognizedElements[] = {
@@ -673,8 +673,8 @@
Data data(Block{sha256DataUnrecognizedElements});
Interest interest(Block{sha256InterestUnrecognizedElements});
- BOOST_CHECK(verifySignature(data, nullopt));
- BOOST_CHECK(verifySignature(interest, nullopt));
+ BOOST_CHECK(verifySignature(data, std::nullopt));
+ BOOST_CHECK(verifySignature(interest, std::nullopt));
}
BOOST_AUTO_TEST_SUITE_END() // TestVerificationHelpers