tests: Add boost's test framework based tests
Change-Id: I1b2f62a9c79ede703ac4d91f9f63b380aa5d5d16
diff --git a/tests_boost/test-encode-decode-interest.cpp b/tests_boost/test-encode-decode-interest.cpp
new file mode 100644
index 0000000..0b21847
--- /dev/null
+++ b/tests_boost/test-encode-decode-interest.cpp
@@ -0,0 +1,69 @@
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Jeff Thompson <jefft0@remap.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#include <boost/test/unit_test.hpp>
+
+#include <ndn-cpp/interest.hpp>
+
+using namespace std;
+using namespace ndn;
+
+BOOST_AUTO_TEST_SUITE(TestInterest)
+
+const uint8_t Interest1[] = {
+ 0x0, 0x41,
+ 0x2, 0x14,
+ 0x3, 0x5, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+ 0x3, 0x3, 0x6e, 0x64, 0x6e,
+ 0x3, 0x6, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78,
+ 0x4, 0x1f,
+ 0x8, 0x1, 0x1,
+ 0x9, 0x1, 0x1,
+ 0xb, 0x14,
+ 0x3, 0x4, 0x61, 0x6c, 0x65, 0x78,
+ 0x3, 0x4, 0x78, 0x78, 0x78, 0x78,
+ 0xe, 0x0,
+ 0x3, 0x4, 0x79, 0x79, 0x79, 0x79,
+ 0xc, 0x1, 0x1,
+ 0x5, 0x1, 0x0,
+ 0x6, 0x1, 0x1,
+ 0x7, 0x2, 0x3, 0xe8
+};
+
+BOOST_AUTO_TEST_CASE (Decode)
+{
+ Block interestBlock(Interest1, sizeof(Interest1));
+
+ ndn::Interest i;
+ BOOST_CHECK_NO_THROW(i.wireDecode(interestBlock));
+
+ BOOST_CHECK_EQUAL(i.getName().toUri(), "/local/ndn/prefix");
+ BOOST_CHECK_EQUAL(i.getScope(), 1);
+ BOOST_CHECK_EQUAL(i.getInterestLifetime(), 1000);
+ BOOST_CHECK_EQUAL(i.getMinSuffixComponents(), 1);
+ BOOST_CHECK_EQUAL(i.getMaxSuffixComponents(), 1);
+ BOOST_CHECK_EQUAL(i.getChildSelector(), 1);
+ BOOST_CHECK_EQUAL(i.getMustBeFresh(), false);
+ BOOST_CHECK_EQUAL(i.getExclude().toUri(), "alex,xxxx,*,yyyy");
+}
+
+BOOST_AUTO_TEST_CASE (Encode)
+{
+ ndn::Interest i(ndn::Name("/local/ndn/prefix"));
+ i.setScope(1);
+ i.setInterestLifetime(1000);
+ i.setMinSuffixComponents(1);
+ i.setMaxSuffixComponents(1);
+ i.setChildSelector(1);
+ i.setMustBeFresh(false);
+ i.getExclude().excludeOne("alex").excludeRange("xxxx", "yyyy");
+
+ const Block &wire = i.wireEncode();
+ BOOST_CHECK_EQUAL_COLLECTIONS(Interest1, Interest1+sizeof(Interest1),
+ wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_SUITE_END()