interest+data: add string_view overloads for convenience
Also, explicitly declare the nullptr_t overloads as deleted, so that
users get a clear compilation error instead of a potentially confusing
"ambiguous overload" if they try to pass nullptr to these functions.
Change-Id: I399efcbd698a0d3f7e29219d21eb1a53a1d71070
diff --git a/tests/unit/link.t.cpp b/tests/unit/link.t.cpp
index f1bbd07..2a17a96 100644
--- a/tests/unit/link.t.cpp
+++ b/tests/unit/link.t.cpp
@@ -35,7 +35,7 @@
BOOST_AUTO_TEST_SUITE(TestLink)
const uint8_t GOOD_LINK[] = {
-0x06, 0xd0, // Data
+ 0x06, 0xd0, // Data
0x07, 0x14, // Name
0x08, 0x05,
0x6c, 0x6f, 0x63, 0x61, 0x6c,
@@ -84,7 +84,7 @@
BOOST_AUTO_TEST_CASE(Decode)
{
Link link(Block{GOOD_LINK});
- BOOST_CHECK_EQUAL(link.getName(), Name("/local/ndn/prefix"));
+ BOOST_TEST(link.getName() == "/local/ndn/prefix");
BOOST_TEST(link.getDelegationList() == std::vector<Name>({"/local", "/ndn"}),
boost::test_tools::per_element());
}
@@ -104,14 +104,25 @@
{
Link link1("/test", {"/test1", "/test2", "/test3"});
signData(link1);
- Block wire = link1.wireEncode();
+ BOOST_TEST(link1.getName() == "/test");
+ BOOST_TEST(link1.getContentType() == tlv::ContentType_Link);
- Link link2(wire);
- BOOST_CHECK_EQUAL(link2.getName(), "/test");
+ Link link2(link1.wireEncode());
+ BOOST_TEST(link2.getName() == "/test");
BOOST_TEST(link2.getDelegationList() == std::vector<Name>({"/test1", "/test2", "/test3"}),
boost::test_tools::per_element());
}
+BOOST_AUTO_TEST_CASE(EncodeEmpty)
+{
+ Link link("/L");
+ signData(link);
+ BOOST_TEST(link.getName() == "/L");
+ BOOST_TEST(link.getContentType() == tlv::ContentType_Link);
+ BOOST_TEST(link.getContent() == "1500"_block);
+ BOOST_TEST(link.getDelegationList().empty() == true);
+}
+
BOOST_AUTO_TEST_SUITE_END() // EncodeDecode
BOOST_AUTO_TEST_SUITE(Modify)