name: remove unused and redundant `push_back(const T&)`
Change-Id: I88b9070eda34c31aea03d1772c14bdc596947b00
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();