Added dumpInterest.
diff --git a/tests/test-encode-decode-interest.cpp b/tests/test-encode-decode-interest.cpp
index 4969617..5f26114 100644
--- a/tests/test-encode-decode-interest.cpp
+++ b/tests/test-encode-decode-interest.cpp
@@ -30,30 +30,62 @@
1
};
-/*
- *
- */
+static void dumpInterest(const Interest &interest)
+{
+ cout << "name: " << interest.getName().to_uri() << endl;
+ cout << "minSuffixComponents: ";
+ if (interest.getMinSuffixComponents() >= 0)
+ cout << interest.getMinSuffixComponents() << endl;
+ else
+ cout << "<none>" << endl;
+ cout << "maxSuffixComponents: ";
+ if (interest.getMaxSuffixComponents() >= 0)
+ cout << interest.getMaxSuffixComponents() << endl;
+ else
+ cout << "<none>" << endl;
+ cout << "publisherPublicKeyDigest: "
+ << (interest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() > 0 ? toHex(interest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest()) : "<none>") << endl;
+ cout << "exclude: "
+ << (interest.getExclude().getEntryCount() > 0 ? interest.getExclude().toUri() : "<none>") << endl;
+ cout << "lifetimeMilliseconds: ";
+ if (interest.getInterestLifetimeMilliseconds() >= 0)
+ cout << interest.getInterestLifetimeMilliseconds() << endl;
+ else
+ cout << "<none>" << endl;
+ cout << "childSelector: ";
+ if (interest.getChildSelector() >= 0)
+ cout << interest.getChildSelector() << endl;
+ else
+ cout << "<none>" << endl;
+ cout << "answerOriginKind: ";
+ if (interest.getAnswerOriginKind() >= 0)
+ cout << interest.getAnswerOriginKind() << endl;
+ else
+ cout << "<none>" << endl;
+ cout << "scope: ";
+ if (interest.getScope() >= 0)
+ cout << interest.getScope() << endl;
+ else
+ cout << "<none>" << endl;
+ cout << "nonce: "
+ << (interest.getNonce().size() > 0 ? toHex(interest.getNonce()) : "<none>") << endl;
+}
+
int main(int argc, char** argv)
{
try {
Interest interest;
interest.wireDecode(Interest1, sizeof(Interest1));
- cout << "Interest name " << interest.getName().to_uri() << endl;
- cout << "Interest minSuffixComponents " << interest.getMinSuffixComponents() << endl;
- cout << "Interest publisherPublicKeyDigest length " << interest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() << endl;
- cout << "Interest excludeEntryCount " << interest.getExclude().getEntryCount() << endl;
- cout << "InterestLifetimeMilliseconds " << interest.getInterestLifetimeMilliseconds() << endl;
+ cout << "Interest:" << endl;
+ dumpInterest(interest);
ptr_lib::shared_ptr<vector<unsigned char> > encoding = interest.wireEncode();
cout << endl << "Re-encoded interest " << toHex(*encoding) << endl;
Interest reDecodedInterest;
reDecodedInterest.wireDecode(*encoding);
- cout << "Re-decoded Interest name " << reDecodedInterest.getName().to_uri() << endl;
- cout << "Re-decoded Interest minSuffixComponents " << reDecodedInterest.getMinSuffixComponents() << endl;
- cout << "Re-decoded Interest publisherPublicKeyDigest length " << reDecodedInterest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() << endl;
- cout << "Re-decoded Interest excludeEntryCount " << reDecodedInterest.getExclude().getEntryCount() << endl;
- cout << "Re-decoded InterestLifetimeMilliseconds " << reDecodedInterest.getInterestLifetimeMilliseconds() << endl;
+ cout << "Re-decoded Interest:" << endl;
+ dumpInterest(reDecodedInterest);
} catch (exception &e) {
cout << "exception: " << e.what() << endl;
}