name: convert to span

Change-Id: I805936731948732114762d0d022d1b447622788d
diff --git a/tests/unit/data.t.cpp b/tests/unit/data.t.cpp
index 153c471..0a4c9b7 100644
--- a/tests/unit/data.t.cpp
+++ b/tests/unit/data.t.cpp
@@ -204,9 +204,7 @@
   }
   d.setSignatureValue(sig.buf());
 
-  Block dataBlock(d.wireEncode());
-  BOOST_CHECK_EQUAL_COLLECTIONS(DATA1, DATA1 + sizeof(DATA1),
-                                dataBlock.begin(), dataBlock.end());
+  BOOST_TEST(d.wireEncode() == DATA1, boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_SUITE_END() // Encode
@@ -537,8 +535,12 @@
   BOOST_CHECK_EQUAL(d.hasContent(), true);
   BOOST_CHECK_EQUAL(d.getContent().type(), tlv::Content);
   BOOST_CHECK_EQUAL(d.getContent().value_size(), 0);
+
   // raw buffer overload (deprecated)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
   BOOST_CHECK_THROW(d.setContent(nullptr, 1), std::invalid_argument);
+#pragma GCC diagnostic pop
 
   // ConstBufferPtr overload
   d.setContent(std::make_shared<Buffer>(direct, sizeof(direct)));
diff --git a/tests/unit/encoding/block.t.cpp b/tests/unit/encoding/block.t.cpp
index a39df87..e7c8bac 100644
--- a/tests/unit/encoding/block.t.cpp
+++ b/tests/unit/encoding/block.t.cpp
@@ -111,7 +111,6 @@
   };
 
   Block b1(buf);
-
   Block b2(b1, b1.begin(), b1.end());
   auto buf2 = b2.getBuffer();
 
@@ -120,9 +119,8 @@
   b1.encode();
 
   b2.parse();
-
-  BOOST_CHECK_EQUAL_COLLECTIONS(b2.begin(), b2.end(), buf, buf + sizeof(buf));
-  BOOST_CHECK_EQUAL(buf2, b2.getBuffer());
+  BOOST_TEST(b2 == buf, boost::test_tools::per_element());
+  BOOST_TEST(buf2 == b2.getBuffer()); // check pointers
 }
 
 BOOST_AUTO_TEST_CASE(FromBlockCopyOnWriteModifyCopy)
@@ -133,7 +131,6 @@
 
   Block b1(buf);
   auto buf1 = b1.getBuffer();
-
   Block b2(b1, b1.begin(), b1.end());
 
   b2.parse();
@@ -141,8 +138,8 @@
   b2.encode();
 
   b1.parse();
-  BOOST_CHECK_EQUAL_COLLECTIONS(b1.begin(), b1.end(), buf, buf + sizeof(buf));
-  BOOST_CHECK_EQUAL(buf1, b1.getBuffer());
+  BOOST_TEST(b1 == buf, boost::test_tools::per_element());
+  BOOST_TEST(buf1 == b1.getBuffer()); // check pointers
 }
 
 BOOST_AUTO_TEST_CASE(FromType)
diff --git a/tests/unit/ims/in-memory-storage.t.cpp b/tests/unit/ims/in-memory-storage.t.cpp
index 54ceeb0..3d9ff1e 100644
--- a/tests/unit/ims/in-memory-storage.t.cpp
+++ b/tests/unit/ims/in-memory-storage.t.cpp
@@ -270,7 +270,7 @@
 {
   shared_ptr<Data> data = makeData("/digest/compute");
 
-  ConstBufferPtr digest1 = util::Sha256::computeDigest(data->wireEncode().wire(), data->wireEncode().size());
+  auto digest1 = util::Sha256::computeDigest({data->wireEncode().wire(), data->wireEncode().size()});
   BOOST_CHECK_EQUAL(digest1->size(), 32);
 
   InMemoryStorageEntry entry;
@@ -368,7 +368,7 @@
   shared_ptr<Data> data7 = makeData("/c/c/1");
   ims.insert(*data7);
 
-  ConstBufferPtr digest1 = util::Sha256::computeDigest(data->wireEncode().wire(), data->wireEncode().size());
+  auto digest1 = util::Sha256::computeDigest({data->wireEncode().wire(), data->wireEncode().size()});
 
   Name name("/a");
   ims.erase(name);
diff --git a/tests/unit/interest.t.cpp b/tests/unit/interest.t.cpp
index 903d9bb..495d036 100644
--- a/tests/unit/interest.t.cpp
+++ b/tests/unit/interest.t.cpp
@@ -86,7 +86,7 @@
   BOOST_CHECK_EQUAL(i1.isParametersDigestValid(), true);
 
   Block wire1 = i1.wireEncode();
-  BOOST_CHECK_EQUAL_COLLECTIONS(wire1.begin(), wire1.end(), WIRE, WIRE + sizeof(WIRE));
+  BOOST_TEST(wire1 == WIRE, boost::test_tools::per_element());
 
   Interest i2(wire1);
   BOOST_CHECK_EQUAL(i2.getName(), "/local/ndn/prefix");
@@ -129,7 +129,7 @@
   BOOST_CHECK_EQUAL(i1.isParametersDigestValid(), true);
 
   Block wire1 = i1.wireEncode();
-  BOOST_CHECK_EQUAL_COLLECTIONS(wire1.begin(), wire1.end(), WIRE, WIRE + sizeof(WIRE));
+  BOOST_TEST(wire1 == WIRE, boost::test_tools::per_element());
 
   Interest i2(wire1);
   BOOST_CHECK_EQUAL(i2.getName(),
@@ -186,7 +186,7 @@
   BOOST_CHECK_EQUAL(i1.isParametersDigestValid(), true);
 
   Block wire1 = i1.wireEncode();
-  BOOST_CHECK_EQUAL_COLLECTIONS(wire1.begin(), wire1.end(), WIRE, WIRE + sizeof(WIRE));
+  BOOST_TEST(wire1 == WIRE, boost::test_tools::per_element());
 
   Interest i2(wire1);
   BOOST_CHECK_EQUAL(i2.getName(),
@@ -248,8 +248,7 @@
   BOOST_CHECK_EQUAL(i1.getNonce(), 0x4c1ecb4a);
   BOOST_CHECK_EQUAL(i1.getSignatureInfo()->getSignatureType(), tlv::DigestSha256);
   BOOST_CHECK(i1.getSignatureInfo()->getNonce() == nonce);
-  BOOST_CHECK_EQUAL_COLLECTIONS(i1.getSignatureValue().begin(), i1.getSignatureValue().end(),
-                                sv.begin(), sv.end());
+  BOOST_TEST(i1.getSignatureValue() == sv, boost::test_tools::per_element());
   BOOST_CHECK_EQUAL(i1.getApplicationParameters(), "2404C0C1C2C3"_block);
   BOOST_CHECK_EQUAL(i1.isParametersDigestValid(), true);
 
@@ -259,8 +258,7 @@
   i1.setCanBePrefix(false);
   BOOST_CHECK_EQUAL(i1.hasWire(), false);
 
-  Block wire1 = i1.wireEncode();
-  BOOST_CHECK_EQUAL_COLLECTIONS(wire1.begin(), wire1.end(), WIRE, WIRE + sizeof(WIRE));
+  BOOST_TEST(i1.wireEncode() == WIRE, boost::test_tools::per_element());
 
   Interest i2("/local/ndn/prefix");
   i2.setMustBeFresh(true);
@@ -270,8 +268,7 @@
   i2.setSignatureValue(make_shared<Buffer>(sv.value(), sv.value_size()));
   BOOST_CHECK_EQUAL(i2.isParametersDigestValid(), true);
 
-  Block wire2 = i2.wireEncode();
-  BOOST_CHECK_EQUAL_COLLECTIONS(wire2.begin(), wire2.end(), WIRE, WIRE + sizeof(WIRE));
+  BOOST_TEST(i2.wireEncode() == WIRE, boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(SignedApplicationElements)
@@ -325,8 +322,7 @@
   BOOST_CHECK_EQUAL(i1.getNonce(), 0x4c1ecb4a);
   BOOST_CHECK_EQUAL(i1.getSignatureInfo()->getSignatureType(), tlv::DigestSha256);
   BOOST_CHECK(i1.getSignatureInfo()->getNonce() == nonce);
-  BOOST_CHECK_EQUAL_COLLECTIONS(i1.getSignatureValue().begin(), i1.getSignatureValue().end(),
-                                sv.begin(), sv.end());
+  BOOST_TEST(i1.getSignatureValue() == sv, boost::test_tools::per_element());
   BOOST_CHECK_EQUAL(i1.getApplicationParameters(), "2404C0C1C2C3"_block);
   BOOST_CHECK_EQUAL(i1.isParametersDigestValid(), true);
 
@@ -336,8 +332,7 @@
   i1.setCanBePrefix(false);
   BOOST_CHECK_EQUAL(i1.hasWire(), false);
 
-  Block wire1 = i1.wireEncode();
-  BOOST_CHECK_EQUAL_COLLECTIONS(wire1.begin(), wire1.end(), WIRE, WIRE + sizeof(WIRE));
+  BOOST_TEST(i1.wireEncode() == WIRE, boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(MissingApplicationParameters)
@@ -888,8 +883,12 @@
   BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2401C1"_block);
   i.setApplicationParameters(span<uint8_t>{});
   BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2400"_block);
+
   // raw buffer+size overload (deprecated)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
   BOOST_CHECK_THROW(i.setApplicationParameters(nullptr, 42), std::invalid_argument);
+#pragma GCC diagnostic pop
 
   // ConstBufferPtr overload
   i.setApplicationParameters(make_shared<Buffer>(PARAMETERS2, sizeof(PARAMETERS2)));
diff --git a/tests/unit/meta-info.t.cpp b/tests/unit/meta-info.t.cpp
index 87add29..56ad239 100644
--- a/tests/unit/meta-info.t.cpp
+++ b/tests/unit/meta-info.t.cpp
@@ -109,7 +109,7 @@
   // // These octets are obtained by the snippet below.
   // // This check is intended to detect unexpected encoding change in the future.
   // const Block& wire = info1.wireEncode();
-  // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+  // for (auto it = wire.begin(); it != wire.end(); ++it) {
   //   printf("0x%02x, ", *it);
   // }
   const uint8_t METAINFO[] = {0x14, 0x77, 0x18, 0x01, 0xc4, 0x19, 0x02, 0x0e, 0x10, 0x1a, 0x0c,
diff --git a/tests/unit/metadata-object.t.cpp b/tests/unit/metadata-object.t.cpp
index 9606db7..3fd5d09 100644
--- a/tests/unit/metadata-object.t.cpp
+++ b/tests/unit/metadata-object.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -151,7 +151,7 @@
 
   // invalid keyword name component
   name = name.getPrefix(-3)
-         .append(tlv::KeywordNameComponent, reinterpret_cast<const uint8_t*>("foo"), std::strlen("foo"))
+         .append(tlv::KeywordNameComponent, {'f', 'o', 'o'})
          .appendVersion()
          .appendSegment(0);
   BOOST_CHECK_EQUAL(MetadataObject::isValidName(name), false);
diff --git a/tests/unit/mgmt/nfd/channel-status.t.cpp b/tests/unit/mgmt/nfd/channel-status.t.cpp
index 9b1a4fa..dc29def 100644
--- a/tests/unit/mgmt/nfd/channel-status.t.cpp
+++ b/tests/unit/mgmt/nfd/channel-status.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,6 +22,7 @@
 #include "ndn-cxx/mgmt/nfd/channel-status.hpp"
 
 #include "tests/boost-test.hpp"
+
 #include <boost/lexical_cast.hpp>
 
 namespace ndn {
@@ -40,7 +41,7 @@
 
   // These octets are obtained by the snippet below.
   // This check is intended to detect unexpected encoding change in the future.
-  // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+  // for (auto it = wire.begin(); it != wire.end(); ++it) {
   //   printf("0x%02x, ", *it);
   // }
   static const uint8_t expected[] = {
diff --git a/tests/unit/mgmt/nfd/face-event-notification.t.cpp b/tests/unit/mgmt/nfd/face-event-notification.t.cpp
index 3354a1b..f1dfc38 100644
--- a/tests/unit/mgmt/nfd/face-event-notification.t.cpp
+++ b/tests/unit/mgmt/nfd/face-event-notification.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,6 +22,7 @@
 #include "ndn-cxx/mgmt/nfd/face-event-notification.hpp"
 
 #include "tests/boost-test.hpp"
+
 #include <boost/lexical_cast.hpp>
 
 namespace ndn {
@@ -75,7 +76,7 @@
 
   // These octets are obtained by the snippet below.
   // This check is intended to detect unexpected encoding change in the future.
-  // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+  // for (auto it = wire.begin(); it != wire.end(); ++it) {
   //   printf("0x%02x, ", *it);
   // }
   static const uint8_t expected[] = {
@@ -120,7 +121,7 @@
 
   // These octets are obtained by the snippet below.
   // This check is intended to detect unexpected encoding change in the future.
-  // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+  // for (auto it = wire.begin(); it != wire.end(); ++it) {
   //   printf("0x%02x, ", *it);
   // }
   static const uint8_t expected[] = {
@@ -165,7 +166,7 @@
 
   // These octets are obtained by the snippet below.
   // This check is intended to detect unexpected encoding change in the future.
-  // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+  // for (auto it = wire.begin(); it != wire.end(); ++it) {
   //   printf("0x%02x, ", *it);
   // }
   static const uint8_t expected[] = {
@@ -210,7 +211,7 @@
 
   // These octets are obtained by the snippet below.
   // This check is intended to detect unexpected encoding change in the future.
-  // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+  // for (auto it = wire.begin(); it != wire.end(); ++it) {
   //   printf("0x%02x, ", *it);
   // }
   static const uint8_t expected[] = {
diff --git a/tests/unit/mgmt/nfd/face-query-filter.t.cpp b/tests/unit/mgmt/nfd/face-query-filter.t.cpp
index 3b32ac8..e46d6c1 100644
--- a/tests/unit/mgmt/nfd/face-query-filter.t.cpp
+++ b/tests/unit/mgmt/nfd/face-query-filter.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,6 +22,7 @@
 #include "ndn-cxx/mgmt/nfd/face-query-filter.hpp"
 
 #include "tests/boost-test.hpp"
+
 #include <boost/lexical_cast.hpp>
 
 namespace ndn {
@@ -55,7 +56,7 @@
 
   // These octets are obtained by the snippet below.
   // This check is intended to detect unexpected encoding change in the future.
-  // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+  // for (auto it = wire.begin(); it != wire.end(); ++it) {
   //  printf("0x%02x, ", *it);
   // }
   static const uint8_t expected[] = {
diff --git a/tests/unit/mgmt/nfd/face-status.t.cpp b/tests/unit/mgmt/nfd/face-status.t.cpp
index a4ad4ac..405bf2c 100644
--- a/tests/unit/mgmt/nfd/face-status.t.cpp
+++ b/tests/unit/mgmt/nfd/face-status.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,6 +22,7 @@
 #include "ndn-cxx/mgmt/nfd/face-status.hpp"
 
 #include "tests/boost-test.hpp"
+
 #include <boost/lexical_cast.hpp>
 
 namespace ndn {
@@ -64,7 +65,7 @@
 
   // These octets are obtained by the snippet below.
   // This check is intended to detect unexpected encoding change in the future.
-  // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+  // for (auto it = wire.begin(); it != wire.end(); ++it) {
   //   printf("0x%02x, ", *it);
   // }
   static const uint8_t expected[] = {
diff --git a/tests/unit/mgmt/nfd/forwarder-status.t.cpp b/tests/unit/mgmt/nfd/forwarder-status.t.cpp
index f899ce9..b4eb339 100644
--- a/tests/unit/mgmt/nfd/forwarder-status.t.cpp
+++ b/tests/unit/mgmt/nfd/forwarder-status.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,6 +22,7 @@
 #include "ndn-cxx/mgmt/nfd/forwarder-status.hpp"
 
 #include "tests/boost-test.hpp"
+
 #include <boost/lexical_cast.hpp>
 
 namespace ndn {
@@ -61,7 +62,7 @@
 
   // These octets are obtained by the snippet below.
   // This check is intended to detect unexpected encoding change in the future.
-  // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+  // for (auto it = wire.begin(); it != wire.end(); ++it) {
   //   printf("0x%02x, ", *it);
   // }
   static const uint8_t expected[] = {
diff --git a/tests/unit/mgmt/nfd/strategy-choice.t.cpp b/tests/unit/mgmt/nfd/strategy-choice.t.cpp
index 1d8329b..94c30e8 100644
--- a/tests/unit/mgmt/nfd/strategy-choice.t.cpp
+++ b/tests/unit/mgmt/nfd/strategy-choice.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,6 +22,7 @@
 #include "ndn-cxx/mgmt/nfd/strategy-choice.hpp"
 
 #include "tests/boost-test.hpp"
+
 #include <boost/lexical_cast.hpp>
 
 namespace ndn {
@@ -41,7 +42,7 @@
 
   // These octets are obtained by the snippet below.
   // This check is intended to detect unexpected encoding change in the future.
-  // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+  // for (auto it = wire.begin(); it != wire.end(); ++it) {
   //   printf("0x%02x, ", *it);
   // }
   static const uint8_t expected[] = {
diff --git a/tests/unit/name.t.cpp b/tests/unit/name.t.cpp
index 4e8d104..165c3fc 100644
--- a/tests/unit/name.t.cpp
+++ b/tests/unit/name.t.cpp
@@ -236,13 +236,13 @@
   name.append(Component("Emid"));
   BOOST_CHECK_EQUAL(name.wireEncode(), "0706 0804456D6964"_block);
 
-  name.append(25042, reinterpret_cast<const uint8_t*>("P3"), 2);
+  name.append(25042, {'P', '3'});
   BOOST_CHECK_EQUAL(name.wireEncode(), "070C 0804456D6964 FD61D2025033"_block);
 
-  name.append(reinterpret_cast<const uint8_t*>("."), 1);
+  name.append(Component(make_span<uint8_t>({'.'})));
   BOOST_CHECK_EQUAL(name.wireEncode(), "070F 0804456D6964 FD61D2025033 08012E"_block);
 
-  std::vector<uint8_t> v1{0x28, 0xF0, 0xA3, 0x6B};
+  const std::vector<uint8_t> v1{0x28, 0xF0, 0xA3, 0x6B};
   name.append(16, v1.begin(), v1.end());
   BOOST_CHECK_EQUAL(name.wireEncode(), "0715 0804456D6964 FD61D2025033 08012E 100428F0A36B"_block);
 
diff --git a/tests/unit/security/verification-helpers.t.cpp b/tests/unit/security/verification-helpers.t.cpp
index e3ecc86..d15f8f2 100644
--- a/tests/unit/security/verification-helpers.t.cpp
+++ b/tests/unit/security/verification-helpers.t.cpp
@@ -51,7 +51,7 @@
 //   auto print = [] (const std::string& name, const uint8_t* buf, size_t size) {
 //     std::cout << "  const Block " + name + "{{\n    ";
 
-//     std::string hex = toHex(buf, size);
+//     std::string hex = toHex({buf, size});
 
 //     for (size_t i = 0; i < hex.size(); i++) {
 //       if (i > 0 && i % 32 == 0)
diff --git a/tests/unit/util/exception.t.cpp b/tests/unit/util/exception.t.cpp
index 33884dc..49ac2ab 100644
--- a/tests/unit/util/exception.t.cpp
+++ b/tests/unit/util/exception.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2019 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -28,7 +28,7 @@
 
 namespace ndn {
 namespace exception {
-namespace test {
+namespace tests {
 
 BOOST_AUTO_TEST_SUITE(Util)
 BOOST_AUTO_TEST_SUITE(TestException)
@@ -106,6 +106,6 @@
 BOOST_AUTO_TEST_SUITE_END() // TestException
 BOOST_AUTO_TEST_SUITE_END() // Util
 
-} // namespace test
+} // namespace tests
 } // namespace exception
 } // namespace ndn
diff --git a/tests/unit/util/sha256.t.cpp b/tests/unit/util/sha256.t.cpp
index 3340204..ae4fea3 100644
--- a/tests/unit/util/sha256.t.cpp
+++ b/tests/unit/util/sha256.t.cpp
@@ -29,27 +29,27 @@
 
 namespace ndn {
 namespace util {
-namespace test {
+namespace tests {
 
 BOOST_AUTO_TEST_SUITE(Util)
 BOOST_AUTO_TEST_SUITE(TestSha256)
 
 BOOST_AUTO_TEST_CASE(Basic)
 {
-  const uint8_t input[] = {0x01, 0x02, 0x03, 0x04};
+  const uint8_t buf[] = {0x01, 0x02, 0x03, 0x04};
+  auto input = make_span(buf);
   auto expected = fromHex("9f64a747e1b97f131fabb6b447296c9b6f0201e79fb3c5356e6c77e89b6a806a");
 
   Sha256 statefulSha256;
   BOOST_CHECK_EQUAL(statefulSha256.empty(), true);
 
-  statefulSha256.update(input, 1);
-  statefulSha256.update(input + 1, 1);
-  statefulSha256.update(input + 2, 1);
-  statefulSha256.update(input + 3, 1);
+  statefulSha256.update(input.subspan(0, 1));
+  statefulSha256.update(input.subspan(1, 1));
+  statefulSha256.update(input.subspan(2, 1));
+  statefulSha256.update(input.subspan(3, 1));
   ConstBufferPtr digest = statefulSha256.computeDigest();
   BOOST_CHECK_EQUAL(digest->size(), Sha256::DIGEST_SIZE);
-  BOOST_CHECK_EQUAL_COLLECTIONS(expected->data(), expected->data() + expected->size(),
-                                digest->data(), digest->data() + digest->size());
+  BOOST_TEST(*digest == *expected, boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(ConstructFromStream)
@@ -63,8 +63,7 @@
   BOOST_CHECK_EQUAL(sha.toString(), "315F5BDB76D078C43B8AC0064E4A0164612B1FCE77C869345BFC94C75894EDD3");
 
   ConstBufferPtr digest = sha.computeDigest();
-  BOOST_CHECK_EQUAL_COLLECTIONS(expected->data(), expected->data() + expected->size(),
-                                digest->data(), digest->data() + digest->size());
+  BOOST_TEST(*digest == *expected, boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(Compare)
@@ -72,14 +71,13 @@
   const uint8_t origin[] = {0x01, 0x02, 0x03, 0x04};
 
   Sha256 digest1;
-  digest1.update(origin, sizeof(origin));
+  digest1.update(origin);
   digest1.computeDigest();
 
   Sha256 digest2;
-  digest2.update(origin, 1);
-  digest2.update(origin + 1, 1);
-  digest2.update(origin + 2, 1);
-  digest2.update(origin + 3, 1);
+  auto in = make_span(origin);
+  digest2.update(in.first(2));
+  digest2.update(in.last(2));
   digest2.computeDigest();
 
   BOOST_CHECK_EQUAL(digest1 == digest2, true);
@@ -98,8 +96,7 @@
   ConstBufferPtr digest = statefulSha256.computeDigest();
 
   BOOST_CHECK_EQUAL(statefulSha256.empty(), false);
-  BOOST_CHECK_EQUAL_COLLECTIONS(expected->data(), expected->data() + expected->size(),
-                                digest->data(), digest->data() + digest->size());
+  BOOST_TEST(*digest == *expected, boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(InsertionOperatorString)
@@ -112,8 +109,7 @@
   ConstBufferPtr digest = statefulSha256.computeDigest();
 
   BOOST_CHECK_EQUAL(statefulSha256.empty(), false);
-  BOOST_CHECK_EQUAL_COLLECTIONS(expected->data(), expected->data() + expected->size(),
-                                digest->data(), digest->data() + digest->size());
+  BOOST_TEST(*digest == *expected, boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(InsertionOperatorBlock)
@@ -138,8 +134,7 @@
   ConstBufferPtr digest = statefulSha256.computeDigest();
 
   BOOST_CHECK_EQUAL(statefulSha256.empty(), false);
-  BOOST_CHECK_EQUAL_COLLECTIONS(expected->data(), expected->data() + expected->size(),
-                                digest->data(), digest->data() + digest->size());
+  BOOST_TEST(*digest == *expected, boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(InsertionOperatorUint64t)
@@ -154,8 +149,7 @@
   ConstBufferPtr digest = statefulSha256.computeDigest();
 
   BOOST_CHECK_EQUAL(statefulSha256.empty(), false);
-  BOOST_CHECK_EQUAL_COLLECTIONS(expected->data(), expected->data() + expected->size(),
-                                digest->data(), digest->data() + digest->size());
+  BOOST_TEST(*digest == *expected, boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(Reset)
@@ -182,12 +176,10 @@
 
 BOOST_AUTO_TEST_CASE(StaticComputeDigest)
 {
-  const uint8_t input[] = {0x01, 0x02, 0x03, 0x04};
   auto expected = fromHex("9f64a747e1b97f131fabb6b447296c9b6f0201e79fb3c5356e6c77e89b6a806a");
 
-  ConstBufferPtr digest = Sha256::computeDigest(input, sizeof(input));
-  BOOST_CHECK_EQUAL_COLLECTIONS(expected->data(), expected->data() + expected->size(),
-                                digest->data(), digest->data() + digest->size());
+  ConstBufferPtr digest = Sha256::computeDigest({0x01, 0x02, 0x03, 0x04});
+  BOOST_TEST(*digest == *expected, boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(Print)
@@ -209,6 +201,6 @@
 BOOST_AUTO_TEST_SUITE_END() // TestSha256
 BOOST_AUTO_TEST_SUITE_END() // Util
 
-} // namespace test
+} // namespace tests
 } // namespace util
 } // namespace ndn
diff --git a/tests/unit/util/string-helper.t.cpp b/tests/unit/util/string-helper.t.cpp
index 8747301..a129c1a 100644
--- a/tests/unit/util/string-helper.t.cpp
+++ b/tests/unit/util/string-helper.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2019 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -35,7 +35,7 @@
 
 namespace ndn {
 namespace util {
-namespace test {
+namespace tests {
 
 using boost::test_tools::output_test_stream;
 
@@ -85,12 +85,12 @@
 
 BOOST_AUTO_TEST_CASE(ToHex)
 {
-  std::string test = "Hello, world!";
-  BOOST_CHECK_EQUAL(toHex(reinterpret_cast<const uint8_t*>(test.data()), test.size()),
+  const std::string test = "Hello, world!";
+  BOOST_CHECK_EQUAL(toHex({reinterpret_cast<const uint8_t*>(test.data()), test.size()}),
                     "48656C6C6F2C20776F726C6421");
-  BOOST_CHECK_EQUAL(toHex(reinterpret_cast<const uint8_t*>(test.data()), test.size(), false),
+  BOOST_CHECK_EQUAL(toHex({reinterpret_cast<const uint8_t*>(test.data()), test.size()}, false),
                     "48656c6c6f2c20776f726c6421");
-  BOOST_CHECK_EQUAL(toHex(nullptr, 0), "");
+  BOOST_CHECK_EQUAL(toHex({}), "");
 
   Buffer buffer(test.data(), test.size());
   BOOST_CHECK_EQUAL(toHex(buffer, false),  "48656c6c6f2c20776f726c6421");
@@ -99,13 +99,13 @@
 
 BOOST_AUTO_TEST_CASE(FromHex)
 {
-  BOOST_CHECK(*fromHex("") == Buffer{});
-  BOOST_CHECK(*fromHex("48656c6c6f2c20776f726c6421") ==
-              (std::vector<uint8_t>{0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20,
-                                    0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21}));
-  BOOST_CHECK(*fromHex("012a3Bc4defAB5CdEF") ==
-              (std::vector<uint8_t>{0x01, 0x2a, 0x3b, 0xc4, 0xde,
-                                    0xfa, 0xb5, 0xcd, 0xef}));
+  BOOST_TEST(fromHex("")->empty());
+  const uint8_t expected1[] = {
+    0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21
+  };
+  BOOST_TEST(*fromHex("48656c6c6f2c20776f726c6421") == expected1, boost::test_tools::per_element());
+  const uint8_t expected2[] = {0x01, 0x2a, 0x3b, 0xc4, 0xde, 0xfa, 0xb5, 0xcd, 0xef};
+  BOOST_TEST(*fromHex("012a3Bc4defAB5CdEF") == expected2, boost::test_tools::per_element());
 
   BOOST_CHECK_THROW(fromHex("1"), StringHelperError);
   BOOST_CHECK_THROW(fromHex("zz"), StringHelperError);
@@ -209,6 +209,6 @@
 BOOST_AUTO_TEST_SUITE_END() // TestStringHelper
 BOOST_AUTO_TEST_SUITE_END() // Util
 
-} // namespace test
+} // namespace tests
 } // namespace util
 } // namespace ndn