name: remove unused and redundant `push_back(const T&)`
Change-Id: I88b9070eda34c31aea03d1772c14bdc596947b00
diff --git a/ndn-cxx/name.hpp b/ndn-cxx/name.hpp
index 5f72ef8..2a07f1b 100644
--- a/ndn-cxx/name.hpp
+++ b/ndn-cxx/name.hpp
@@ -44,12 +44,10 @@
class Name : private boost::totally_ordered<Name>
{
public: // nested types
- using Error = name::Component::Error;
-
using Component = name::Component;
- using component_container = std::vector<Component>;
+ using Error = Component::Error;
- // Name appears as a container of name components
+ // Name appears as an ordered sequence of name components
using value_type = Component;
using allocator_type = void;
using reference = Component&;
@@ -60,8 +58,8 @@
using const_iterator = const Component*;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
- using difference_type = component_container::difference_type;
- using size_type = component_container::size_type;
+ using difference_type = std::vector<Component>::difference_type;
+ using size_type = std::vector<Component>::size_type;
public: // constructors, encoding, decoding
/**
@@ -344,13 +342,14 @@
return append(Component(tlv::GenericNameComponent, value));
}
- /** @brief Append a `NameComponent` of TLV-TYPE @p type, copying the TLV-VALUE from a range.
- * @tparam Iterator an @c InputIterator dereferencing to a one-octet value type. More efficient
- * implementation is available when it is a @c RandomAccessIterator.
- * @param type the TLV-TYPE.
- * @param first beginning of the range.
- * @param last past-end of the range.
- * @return A reference to this Name, to allow chaining.
+ /**
+ * @brief Append a `NameComponent` of TLV-TYPE @p type, copying the TLV-VALUE from a range.
+ * @tparam Iterator an @c InputIterator dereferencing to a one-octet value type. More efficient
+ * implementation is available when it is a @c RandomAccessIterator.
+ * @param type the TLV-TYPE.
+ * @param first beginning of the range.
+ * @param last past-end of the range.
+ * @return A reference to this Name, to allow chaining.
*/
template<class Iterator>
Name&
@@ -359,12 +358,13 @@
return append(Component(type, first, last));
}
- /** @brief Append a `GenericNameComponent`, copying the TLV-VALUE from a range.
- * @tparam Iterator an @c InputIterator dereferencing to a one-octet value type. More efficient
- * implementation is available when it is a @c RandomAccessIterator.
- * @param first beginning of the range.
- * @param last past-end of the range.
- * @return A reference to this Name, to allow chaining.
+ /**
+ * @brief Append a `GenericNameComponent`, copying the TLV-VALUE from a range.
+ * @tparam Iterator an @c InputIterator dereferencing to a one-octet value type. More efficient
+ * implementation is available when it is a @c RandomAccessIterator.
+ * @param first beginning of the range.
+ * @param last past-end of the range.
+ * @return A reference to this Name, to allow chaining.
*/
template<class Iterator>
Name&
@@ -373,10 +373,11 @@
return append(Component(tlv::GenericNameComponent, first, last));
}
- /** @brief Append a `GenericNameComponent`, copying TLV-VALUE from a null-terminated string.
- * @param str a null-terminated string. Bytes from the string are copied as is, and not
- * interpreted as URI component.
- * @return A reference to this Name, to allow chaining.
+ /**
+ * @brief Append a `GenericNameComponent`, copying the TLV-VALUE from a null-terminated string.
+ * @param str a null-terminated string. Bytes from the string are copied as is, and not
+ * interpreted as a URI component.
+ * @return A reference to this Name, to allow chaining.
*/
Name&
append(const char* str)
@@ -384,9 +385,10 @@
return append(Component(str));
}
- /** @brief Append a PartialName.
- * @param name the components to append
- * @return A reference to this Name, to allow chaining.
+ /**
+ * @brief Append a PartialName.
+ * @param name the components to append
+ * @return A reference to this Name, to allow chaining.
*/
Name&
append(const PartialName& name);
@@ -402,15 +404,16 @@
return append(Component::fromNumber(number));
}
- /** @brief Append a component with a marked number.
- * @param marker 1-octet marker
- * @param number the number
+ /**
+ * @brief Append a component with a marked number.
+ * @param marker 1-octet marker
+ * @param number the number
*
- * The component is encoded as a 1-octet marker, followed by a NonNegativeInteger.
+ * The component is encoded as a 1-octet marker, followed by a NonNegativeInteger.
*
- * @return A reference to this Name, to allow chaining.
- * @sa NDN Naming Conventions revision 1 (obsolete)
- * https://named-data.net/wp-content/uploads/2014/08/ndn-tr-22-ndn-memo-naming-conventions.pdf
+ * @return A reference to this Name, to allow chaining.
+ * @sa NDN Naming Conventions revision 1 (obsolete)
+ * https://named-data.net/wp-content/uploads/2014/08/ndn-tr-22-ndn-memo-naming-conventions.pdf
*/
Name&
appendNumberWithMarker(uint8_t marker, uint64_t number)
@@ -544,17 +547,6 @@
}
/**
- * @brief Append a name component.
- * @note This makes push_back() an alias of append(), giving Name a similar API as `std::vector`.
- */
- template<class T>
- void
- push_back(const T& component)
- {
- append(component);
- }
-
- /**
* @brief Erase the component at the specified index.
* @param i zero-based index of the component to erase;
* if negative, it is interpreted as offset from the end of the name
diff --git a/tests/unit/name.t.cpp b/tests/unit/name.t.cpp
index b105818..a7fdf7a 100644
--- a/tests/unit/name.t.cpp
+++ b/tests/unit/name.t.cpp
@@ -459,7 +459,7 @@
BOOST_AUTO_TEST_CASE(CompareOp)
{
- std::vector<Name> names = {
+ const std::vector<Name> names = {
Name("/"),
Name("/sha256digest=0000000000000000000000000000000000000000000000000000000000000000"),
Name("/sha256digest=0000000000000000000000000000000000000000000000000000000000000001"),
@@ -501,8 +501,10 @@
for (size_t i = 0; i < names.size(); ++i) {
for (size_t j = 0; j < names.size(); ++j) {
- Name lhs = names[i];
- Name rhs = names[j];
+ const auto& lhs = names[i];
+ const auto& rhs = names[j];
+ BOOST_TEST_INFO_SCOPE("lhs = " << lhs);
+ BOOST_TEST_INFO_SCOPE("rhs = " << rhs);
BOOST_CHECK_EQUAL(lhs == rhs, i == j);
BOOST_CHECK_EQUAL(lhs != rhs, i != j);
BOOST_CHECK_EQUAL(lhs < rhs, i < j);
diff --git a/tests/unit/security/tpm/back-end.t.cpp b/tests/unit/security/tpm/back-end.t.cpp
index d432d73..cb0ec5d 100644
--- a/tests/unit/security/tpm/back-end.t.cpp
+++ b/tests/unit/security/tpm/back-end.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -343,7 +343,8 @@
for (int i = 0; i < 100; i++) {
auto key = tpm.createKey(identity, RsaKeyParams());
Name keyName = key->getKeyName();
- BOOST_CHECK(keyNames.insert(keyName).second);
+ BOOST_TEST_INFO_SCOPE("KeyName = " << keyName);
+ BOOST_TEST(keyNames.insert(keyName).second);
}
}
diff --git a/tests/unit/security/validator-config/checker.t.cpp b/tests/unit/security/validator-config/checker.t.cpp
index 523f1a2..e340b26 100644
--- a/tests/unit/security/validator-config/checker.t.cpp
+++ b/tests/unit/security/validator-config/checker.t.cpp
@@ -40,10 +40,10 @@
public:
CheckerFixture()
{
- names.push_back("/foo/bar");
- names.push_back("/foo/bar/bar");
- names.push_back("/foo");
- names.push_back("/other/prefix");
+ names.emplace_back("/foo/bar");
+ names.emplace_back("/foo/bar/bar");
+ names.emplace_back("/foo");
+ names.emplace_back("/other/prefix");
}
static Name
@@ -60,22 +60,6 @@
return Name(name).append(suffix);
}
- template<typename PktType, typename C>
- static void
- testChecker(C& checker, tlv::SignatureTypeValue sigType, const Name& pktName, const Name& klName, bool expectedOutcome)
- {
- BOOST_TEST_INFO_SCOPE("Packet = " << pktName);
- BOOST_TEST_INFO_SCOPE("KeyLocator = " << klName);
-
- auto state = PktType::makeState();
- auto result = checker.check(PktType::getType(), sigType, pktName, klName, *state);
- BOOST_CHECK_EQUAL(bool(result), expectedOutcome);
- BOOST_CHECK(boost::logic::indeterminate(state->getOutcome()));
- if (!result) {
- BOOST_CHECK_NE(result.getErrorMessage(), "");
- }
- }
-
public:
std::vector<Name> names;
};
@@ -308,6 +292,23 @@
CheckerFixtures
>;
+template<typename PktType, typename C>
+static void
+testChecker(C& checker, tlv::SignatureTypeValue sigType, const Name& pktName, const Name& klName, bool expectedOutcome)
+{
+ BOOST_TEST_INFO_SCOPE("Packet = " << pktName);
+ BOOST_TEST_INFO_SCOPE("SignatureType = " << sigType);
+ BOOST_TEST_INFO_SCOPE("KeyLocator = " << klName);
+
+ auto state = PktType::makeState();
+ auto result = checker.check(PktType::getType(), sigType, pktName, klName, *state);
+ BOOST_TEST(bool(result) == expectedOutcome);
+ BOOST_TEST(boost::logic::indeterminate(state->getOutcome()));
+ if (!result) {
+ BOOST_TEST(!result.getErrorMessage().empty());
+ }
+}
+
BOOST_FIXTURE_TEST_CASE_TEMPLATE(Checks, T, Tests, boost::mp11::mp_second<T>)
{
using PktType = boost::mp11::mp_first<T>;
@@ -321,12 +322,12 @@
bool expectedOutcome = this->outcomes[i][j];
auto klName = this->makeKeyLocatorKeyName(this->names[j]);
- this->template testChecker<PktType>(this->checker, tlv::SignatureSha256WithRsa, pktName, klName, expectedOutcome);
- this->template testChecker<PktType>(this->checker, tlv::SignatureSha256WithEcdsa, pktName, klName, false);
+ testChecker<PktType>(this->checker, tlv::SignatureSha256WithRsa, pktName, klName, expectedOutcome);
+ testChecker<PktType>(this->checker, tlv::SignatureSha256WithEcdsa, pktName, klName, false);
klName = this->makeKeyLocatorCertName(this->names[j]);
- this->template testChecker<PktType>(this->checker, tlv::SignatureSha256WithRsa, pktName, klName, expectedOutcome);
- this->template testChecker<PktType>(this->checker, tlv::SignatureSha256WithEcdsa, pktName, klName, false);
+ testChecker<PktType>(this->checker, tlv::SignatureSha256WithRsa, pktName, klName, expectedOutcome);
+ testChecker<PktType>(this->checker, tlv::SignatureSha256WithEcdsa, pktName, klName, false);
}
}
}
diff --git a/tests/unit/util/sha256.t.cpp b/tests/unit/util/sha256.t.cpp
index 4a31ac7..55eaa10 100644
--- a/tests/unit/util/sha256.t.cpp
+++ b/tests/unit/util/sha256.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -25,6 +25,8 @@
#include "tests/boost-test.hpp"
#include <boost/endian/conversion.hpp>
+
+#include <array>
#include <sstream>
namespace ndn::tests {
@@ -114,12 +116,12 @@
BOOST_AUTO_TEST_CASE(InsertionOperatorUnsignedInt)
{
- const uint64_t input[] = {1, 2, 3, 4};
+ const std::array input{1, 2, 3, 4};
auto expected = fromHex("7236c00c170036c6de133a878210ddd58567aa1d0619a0f70f69e38ae6f916e9");
Sha256 statefulSha256;
- for (size_t i = 0; i < sizeof(input) / sizeof(uint64_t); ++i) {
- statefulSha256 << boost::endian::native_to_big(input[i]);
+ for (auto i : input) {
+ statefulSha256 << boost::endian::native_to_big(static_cast<uint64_t>(i));
}
ConstBufferPtr digest = statefulSha256.computeDigest();