Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Yingdi Yu <yingdi@cs.ucla.edu> |
| 5 | * See COPYING for copyright and distribution information. |
| 6 | */ |
| 7 | |
| 8 | #include <boost/test/unit_test.hpp> |
| 9 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 10 | #include "profile.hpp" |
| 11 | #include <ndn-cxx/encoding/buffer-stream.hpp> |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 12 | |
Qiuhan Ding | 52f1383 | 2015-03-06 14:05:59 -0800 | [diff] [blame] | 13 | namespace chronochat { |
| 14 | namespace tests { |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 15 | |
| 16 | using std::string; |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 17 | |
| 18 | BOOST_AUTO_TEST_SUITE(TestProfile) |
| 19 | |
| 20 | BOOST_AUTO_TEST_CASE(EncodeDecodeProfile) |
| 21 | { |
| 22 | Name identity("/ndn/ucla/yingdi"); |
| 23 | Profile profile(identity); |
| 24 | profile["name"] = "Yingdi Yu"; |
| 25 | profile["school"] = "UCLA"; |
| 26 | |
Qiuhan Ding | 0cfc151 | 2015-02-17 17:44:11 -0800 | [diff] [blame^] | 27 | Block profileWire = profile.wireEncode(); |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 28 | |
| 29 | Profile decodedProfile; |
Qiuhan Ding | 0cfc151 | 2015-02-17 17:44:11 -0800 | [diff] [blame^] | 30 | decodedProfile.wireDecode(profileWire); |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 31 | |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 32 | BOOST_CHECK_EQUAL(decodedProfile.getIdentityName().toUri(), string("/ndn/ucla/yingdi")); |
| 33 | BOOST_CHECK_EQUAL(decodedProfile["name"], string("Yingdi Yu")); |
| 34 | BOOST_CHECK_EQUAL(decodedProfile["school"], string("UCLA")); |
| 35 | } |
| 36 | |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 37 | BOOST_AUTO_TEST_SUITE_END() |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 38 | |
Qiuhan Ding | 52f1383 | 2015-03-06 14:05:59 -0800 | [diff] [blame] | 39 | } // namespace tests |
| 40 | } // namespace chronochat |