data: do not encode a Content element if not set
Add Data::hasContent() and Data::unsetContent().
Change the behavior of Interest::setApplicationParameters(Block{}) for
consistency with the corresponding getter and with Data::setContent().
Change-Id: I4cc9058912510db0dfe3da614adee727db149415
diff --git a/tests/unit/security/key-chain.t.cpp b/tests/unit/security/key-chain.t.cpp
index ba2bd7c..b6dd0c6 100644
--- a/tests/unit/security/key-chain.t.cpp
+++ b/tests/unit/security/key-chain.t.cpp
@@ -291,6 +291,10 @@
key3Cert2.setName(key3Cert2Name);
m_keyChain.addCertificate(key3, key3Cert2);
BOOST_CHECK_EQUAL(key3.getCertificates().size(), 2);
+ // Add empty cert
+ Certificate key3Cert3 = key3Cert1;
+ key3Cert3.unsetContent();
+ BOOST_CHECK_THROW(m_keyChain.addCertificate(key3, key3Cert3), std::invalid_argument);
// Default certificate setting
BOOST_CHECK_EQUAL(key3.getDefaultCertificate().getName(), key3CertName);