remove protobuf dependency
Change-Id: I10bf90ba940bbde27d91df58056f4f558843f697
diff --git a/test/chat-message.t.cpp b/test/chat-message.t.cpp
new file mode 100644
index 0000000..09ab127
--- /dev/null
+++ b/test/chat-message.t.cpp
@@ -0,0 +1,68 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013, Regents of the University of California
+ *
+ * BSD license, See the LICENSE file for more information
+ *
+ * Author: Qiuhan Ding <qiuhanding@cs.ucla.edu>
+ */
+
+#include <boost/test/unit_test.hpp>
+
+#include "chat-message.hpp"
+#include <ndn-cxx/encoding/buffer-stream.hpp>
+
+namespace chronochat{
+namespace tests{
+
+using std::string;
+
+BOOST_AUTO_TEST_SUITE(TestChatMessage)
+
+BOOST_AUTO_TEST_CASE(EncodeDecode)
+{
+ string nick("qiuhan");
+ string chatroomName("test");
+ int32_t seconds =
+ static_cast<int32_t>(time::toUnixTimestamp(time::system_clock::now()).count() / 1000);
+ ChatMessage helloMsg;
+ helloMsg.setNick(nick);
+ helloMsg.setChatroomName(chatroomName);
+ helloMsg.setTimestamp(seconds);
+ helloMsg.setMsgType(ChatMessage::ChatMessageType::HELLO);
+
+ Block helloWire;
+ BOOST_REQUIRE_NO_THROW(helloWire = helloMsg.wireEncode());
+ ChatMessage decodedHelloMsg;
+ BOOST_REQUIRE_NO_THROW(decodedHelloMsg.wireDecode(helloWire));
+
+ BOOST_CHECK_EQUAL(decodedHelloMsg.getNick(), nick);
+ BOOST_CHECK_EQUAL(decodedHelloMsg.getChatroomName(), chatroomName);
+ BOOST_CHECK_EQUAL(decodedHelloMsg.getTimestamp(), seconds);
+ BOOST_CHECK_EQUAL(decodedHelloMsg.getMsgType(), ChatMessage::ChatMessageType::HELLO);
+
+ ChatMessage chatMsg;
+ string data = "This is for testing";
+ chatMsg.setNick(nick);
+ chatMsg.setChatroomName(chatroomName);
+ chatMsg.setTimestamp(seconds);
+ chatMsg.setData(data);
+ chatMsg.setMsgType(ChatMessage::ChatMessageType::CHAT);
+
+ Block chatWire;
+ BOOST_REQUIRE_NO_THROW(chatWire = chatMsg.wireEncode());
+ ChatMessage decodedChatMsg;
+ BOOST_REQUIRE_NO_THROW(decodedChatMsg.wireDecode(chatWire));
+
+ BOOST_CHECK_EQUAL(decodedChatMsg.getNick(), nick);
+ BOOST_CHECK_EQUAL(decodedChatMsg.getChatroomName(), chatroomName);
+ BOOST_CHECK_EQUAL(decodedChatMsg.getTimestamp(), seconds);
+ BOOST_CHECK_EQUAL(decodedChatMsg.getData(), data);
+ BOOST_CHECK_EQUAL(decodedChatMsg.getMsgType(), ChatMessage::ChatMessageType::CHAT);
+
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace chronochat
diff --git a/test/conf.t.cpp b/test/conf.t.cpp
new file mode 100644
index 0000000..9af3e5d
--- /dev/null
+++ b/test/conf.t.cpp
@@ -0,0 +1,42 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013, Regents of the University of California
+ *
+ * BSD license, See the LICENSE file for more information
+ *
+ * Author: Qiuhan Ding <qiuhanding@cs.ucla.edu>
+ */
+
+#include <boost/test/unit_test.hpp>
+
+#include "conf.hpp"
+#include <ndn-cxx/encoding/buffer-stream.hpp>
+
+namespace chronochat{
+namespace tests {
+
+using std::string;
+
+BOOST_AUTO_TEST_SUITE(TestConf)
+
+BOOST_AUTO_TEST_CASE(EncodeDecode)
+{
+ string nick("qiuhan");
+ Name identity("/ndn/edu/ucla/qiuhan");
+ Conf conf;
+ conf.setIdentity(identity);
+ conf.setNick(nick);
+
+ Block confWire;
+ BOOST_REQUIRE_NO_THROW(confWire = conf.wireEncode());
+ Conf decodedConf;
+ BOOST_REQUIRE_NO_THROW(decodedConf.wireDecode(confWire));
+
+ BOOST_CHECK_EQUAL(decodedConf.getNick(), nick);
+ BOOST_CHECK_EQUAL(decodedConf.getIdentity(), identity);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace chronochat
diff --git a/test/endorse-certificate.t.cpp b/test/endorse-certificate.t.cpp
index 8d97173..5fa5c79 100644
--- a/test/endorse-certificate.t.cpp
+++ b/test/endorse-certificate.t.cpp
@@ -65,24 +65,19 @@
iwIBEQ==");
const string testEndorseCert("\
-Bv0DOgePCBdFbmRvcnNlQ2VydGlmaWNhdGVUZXN0cwgMRW5jb2RlRGVjb2RlCBFr\
-c2stMTM5NDA3MjE0NzMzNQgMUFJPRklMRS1DRVJUCDwHOggXRW5kb3JzZUNlcnRp\
-ZmljYXRlVGVzdHMIDEVuY29kZURlY29kZQgRa3NrLTEzOTQwNzIxNDczMzUIB/0B\
-RJVWq1kUAxgBAhX9AnkwggJ1MCIYDzIwMTQwMzA2MDIxNTQ3WhgPMjAxNDAzMTMw\
-OTI3NDdaMEAwPgYDVQQpEzcvRW5kb3JzZUNlcnRpZmljYXRlVGVzdHMvRW5jb2Rl\
-RGVjb2RlL2tzay0xMzk0MDcyMTQ3MzM1MIIBIDANBgkqhkiG9w0BAQEFAAOCAQ0A\
-MIIBCAKCAQEA2LFg9IsUBUX2LN+gRzbETb+aLhC+vaGkul1/4bEDdQcuETSOnkhu\
-Q6Wo7QMCtcvg1z8JCx3eUga78C80Xhe0rKxdjm2sM51NeBimkHW5/nlSBEewlr0q\
-SYR+cikuHwj0Tfm9TD/EEgy72mhrteU/fHIFbHCBKhZC351kkG3TehJ6HYzh9uyZ\
-AQs/C8b/RmS64XyhszspUXy87wiMiF2Jeh1q6DvsUyUGj/pokmTVRsn+I2Ks+Vm0\
-B+emvWY1JXU6YY7g2wY1KkGjVTs6Ck/h+KofJp9/fWkPfwYzPuv1oK0sO/zDtlAo\
-KGYckkGOB1as1FVVp2MDlDWD6Dktx3bxiwIBETCB6DCBwAYHKwYBBSACAQEB/wSB\
-sQoxCghJREVOVElUWRIlL0VuZG9yc2VDZXJ0aWZpY2F0ZVRlc3RzL0VuY29kZURl\
-Y29k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dyb3VwiwdhZHZpc29y\
+FgMbAQAXIHalD2NUzM7abX6QY+2qWNLVMC+ch2xnVyrlf89ZH/IV");
BOOST_AUTO_TEST_CASE(IdCert)
{
diff --git a/test/endorse-collection.t.cpp b/test/endorse-collection.t.cpp
new file mode 100644
index 0000000..1af3f6b
--- /dev/null
+++ b/test/endorse-collection.t.cpp
@@ -0,0 +1,41 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013, Regents of the University of California
+ *
+ * BSD license, See the LICENSE file for more information
+ *
+ * Author: Qiuhan Ding <qiuhanding@cs.ucla.edu>
+ */
+
+#include <boost/test/unit_test.hpp>
+
+#include "endorse-collection.hpp"
+#include <ndn-cxx/encoding/buffer-stream.hpp>
+
+namespace chronochat{
+namespace tests {
+
+using std::string;
+
+BOOST_AUTO_TEST_SUITE(TestEndorseCollection)
+
+BOOST_AUTO_TEST_CASE(EncodeDecode)
+{
+ EndorseCollection collection;
+ collection.addCollectionEntry(ndn::Name("/ndn/ucla/qiuhan"), "hash");
+ Block collectionWire;
+ BOOST_REQUIRE_NO_THROW(collectionWire = collection.wireEncode());
+ EndorseCollection decodedCollection;
+ BOOST_REQUIRE_NO_THROW(decodedCollection.wireDecode(collectionWire));
+
+ BOOST_CHECK_EQUAL(decodedCollection.getCollectionEntries().size(), 1);
+ BOOST_CHECK_EQUAL(decodedCollection.getCollectionEntries()[0].certName.toUri(),
+ string("/ndn/ucla/qiuhan"));
+ BOOST_CHECK_EQUAL(decodedCollection.getCollectionEntries()[0].hash, "hash");
+
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace chronochat
diff --git a/test/profile.t.cpp b/test/profile.t.cpp
index c003c70..3e85f38 100644
--- a/test/profile.t.cpp
+++ b/test/profile.t.cpp
@@ -24,17 +24,10 @@
profile["name"] = "Yingdi Yu";
profile["school"] = "UCLA";
- ndn::OBufferStream os;
- profile.encode(os);
-
- ndn::ConstBufferPtr encoded = os.buf();
-
- boost::iostreams::stream
- <boost::iostreams::array_source> is(reinterpret_cast<const char*>(encoded->buf()),
- encoded->size ());
+ Block profileWire = profile.wireEncode();
Profile decodedProfile;
- decodedProfile.decode(is);
+ decodedProfile.wireDecode(profileWire);
BOOST_CHECK_EQUAL(decodedProfile.getIdentityName().toUri(), string("/ndn/ucla/yingdi"));
BOOST_CHECK_EQUAL(decodedProfile["name"], string("Yingdi Yu"));