Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -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 <profile.h> |
| 9 | |
| 10 | #define BOOST_TEST_MODULE ChronoChat |
| 11 | #include <boost/test/unit_test.hpp> |
| 12 | |
| 13 | using namespace ndn; |
| 14 | using namespace std; |
| 15 | |
| 16 | BOOST_AUTO_TEST_SUITE(ProfileTests) |
| 17 | |
| 18 | BOOST_AUTO_TEST_CASE(WriteRead) |
| 19 | { |
| 20 | Name identity("/ndn/ucla/yingdi"); |
| 21 | Profile profile(identity); |
| 22 | profile.setProfileEntry(string("name"), string("Yingdi Yu")); |
| 23 | profile.setProfileEntry(string("school"), string("UCLA")); |
| 24 | |
| 25 | string encoded; |
| 26 | profile.encode(&encoded); |
| 27 | |
| 28 | ptr_lib::shared_ptr<Profile> decodedProfile = Profile::decode(encoded); |
| 29 | |
| 30 | BOOST_CHECK_EQUAL(decodedProfile->getIdentityName().toUri(), string("/ndn/ucla/yingdi")); |
| 31 | BOOST_CHECK_EQUAL(decodedProfile->getProfileEntry(string("name")), string("Yingdi Yu")); |
| 32 | BOOST_CHECK_EQUAL(decodedProfile->getProfileEntry(string("school")), string("UCLA")); |
| 33 | } |
| 34 | |
| 35 | BOOST_AUTO_TEST_SUITE_END() |