tests: use BOOST_TEST_CONTEXT and BOOST_DATA_TEST_CASE where possible

Fix the last two "CanBePrefix unset" warnings in unit tests

Change-Id: Ifd2420ae98e7c4741a1c20e7fa0d52f74d7178c8
diff --git a/tests/unit/encoding/block.t.cpp b/tests/unit/encoding/block.t.cpp
index fea4714..52ad9c1 100644
--- a/tests/unit/encoding/block.t.cpp
+++ b/tests/unit/encoding/block.t.cpp
@@ -25,7 +25,7 @@
 #include "tests/boost-test.hpp"
 
 #include <boost/lexical_cast.hpp>
-#include <boost/mpl/vector.hpp>
+#include <boost/test/data/test_case.hpp>
 
 #include <cstring>
 #include <sstream>
@@ -358,49 +358,26 @@
   BOOST_CHECK_EQUAL(*b.wire(),  0xfe);
 }
 
-template<typename T>
-struct MalformedInput
-{
-  static const std::vector<uint8_t> INPUT;
+static const Buffer MalformedInputs[] = {
+  {0x00, 0x00}, // invalid TLV type (zero)
+  {0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}, // TLV type too large
+  {0x01, 0xff, 0x42, 0x42}, // bad TLV length
+  {0x01, 0x02, 0x03}, // truncated TLV value
 };
 
-template<>
-const std::vector<uint8_t> MalformedInput<struct TlvTypeZero>::INPUT{
-  0x00, 0x00
-};
-template<>
-const std::vector<uint8_t> MalformedInput<struct TlvTypeTooLarge>::INPUT{
-  0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-template<>
-const std::vector<uint8_t> MalformedInput<struct BadTlvLength>::INPUT{
-  0x01, 0xff, 0x42, 0x42
-};
-template<>
-const std::vector<uint8_t> MalformedInput<struct TruncatedTlvValue>::INPUT{
-  0x01, 0x02, 0x03
-};
-
-using MalformedInputs = boost::mpl::vector<
-  MalformedInput<TlvTypeZero>,
-  MalformedInput<TlvTypeTooLarge>,
-  MalformedInput<BadTlvLength>,
-  MalformedInput<TruncatedTlvValue>
->;
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(Malformed, T, MalformedInputs)
+BOOST_DATA_TEST_CASE(Malformed, MalformedInputs)
 {
   // constructor from raw buffer
-  BOOST_CHECK_THROW(Block(T::INPUT.data(), T::INPUT.size()), tlv::Error);
+  BOOST_CHECK_THROW(Block(sample.data(), sample.size()), tlv::Error);
 
   // fromStream()
   std::stringstream stream;
-  stream.write(reinterpret_cast<const char*>(T::INPUT.data()), T::INPUT.size());
+  stream.write(sample.template get<char>(), sample.size());
   stream.seekg(0);
   BOOST_CHECK_THROW(Block::fromStream(stream), tlv::Error);
 
   // fromBuffer(), ConstBufferPtr overload
-  auto buf = make_shared<Buffer>(T::INPUT.begin(), T::INPUT.end());
+  auto buf = make_shared<Buffer>(sample.begin(), sample.end());
   bool isOk;
   Block b;
   std::tie(isOk, b) = Block::fromBuffer(buf, 0);
@@ -408,7 +385,7 @@
   BOOST_CHECK(!b.isValid());
 
   // fromBuffer(), raw buffer overload
-  std::tie(isOk, b) = Block::fromBuffer(T::INPUT.data(), T::INPUT.size());
+  std::tie(isOk, b) = Block::fromBuffer(sample.data(), sample.size());
   BOOST_CHECK(!isOk);
   BOOST_CHECK(!b.isValid());
 }
diff --git a/tests/unit/encoding/nfd-constants.t.cpp b/tests/unit/encoding/nfd-constants.t.cpp
index e87f391..e1bc111 100644
--- a/tests/unit/encoding/nfd-constants.t.cpp
+++ b/tests/unit/encoding/nfd-constants.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-2020 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -24,6 +24,7 @@
 #include "tests/boost-test.hpp"
 
 #include <boost/lexical_cast.hpp>
+#include <iomanip>
 #include <sstream>
 
 namespace ndn {
@@ -72,22 +73,25 @@
 BOOST_AUTO_TEST_CASE(ParseRouteOrigin)
 {
   auto expectSuccess = [] (const std::string& input, RouteOrigin expected) {
-    std::istringstream is(input);
-    RouteOrigin routeOrigin;
-    is >> routeOrigin;
+    BOOST_TEST_CONTEXT("input = " << std::quoted(input)) {
+      std::istringstream is(input);
+      RouteOrigin routeOrigin;
+      is >> routeOrigin;
 
-    BOOST_TEST_MESSAGE("parsing " << input);
-    BOOST_CHECK_EQUAL(routeOrigin, expected);
+      BOOST_CHECK(!is.fail());
+      BOOST_CHECK_EQUAL(routeOrigin, expected);
+    }
   };
 
   auto expectFail = [] (const std::string& input) {
-    std::istringstream is(input);
-    RouteOrigin routeOrigin;
-    is >> routeOrigin;
+    BOOST_TEST_CONTEXT("input = " << std::quoted(input)) {
+      std::istringstream is(input);
+      RouteOrigin routeOrigin;
+      is >> routeOrigin;
 
-    BOOST_TEST_MESSAGE("parsing " << input);
-    BOOST_CHECK(is.fail());
-    BOOST_CHECK_EQUAL(routeOrigin, ROUTE_ORIGIN_NONE);
+      BOOST_CHECK(is.fail());
+      BOOST_CHECK_EQUAL(routeOrigin, ROUTE_ORIGIN_NONE);
+    }
   };
 
   expectSuccess("none", ROUTE_ORIGIN_NONE);