blob: 9c1b67a2906643d46a8b84a96ea8afacc4198ca4 [file] [log] [blame]
Yingdi Yufa4ce792014-02-06 18:09:22 -08001/* -*- 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 Yu348f5ea2014-03-01 14:47:25 -080010#include "profile.h"
Yingdi Yufa4ce792014-02-06 18:09:22 -080011
12using namespace ndn;
13using namespace std;
14using namespace chronos;
15
16BOOST_AUTO_TEST_SUITE(TestProfile)
17
18BOOST_AUTO_TEST_CASE(EncodeDecodeProfile)
19{
20 Name identity("/ndn/ucla/yingdi");
21 Profile profile(identity);
22 profile["name"] = "Yingdi Yu";
23 profile["school"] = "UCLA";
24
25 OBufferStream os;
26 profile.encode(os);
27
28 shared_ptr<Buffer> encoded = os.buf();
29
30 boost::iostreams::stream
31 <boost::iostreams::array_source> is (reinterpret_cast<const char*>(encoded->buf ()), encoded->size ());
32
33 Profile decodedProfile;
34 decodedProfile.decode(is);
35
36 BOOST_CHECK_EQUAL(decodedProfile.getIdentityName().toUri(), string("/ndn/ucla/yingdi"));
37 BOOST_CHECK_EQUAL(decodedProfile["name"], string("Yingdi Yu"));
38 BOOST_CHECK_EQUAL(decodedProfile["school"], string("UCLA"));
39}
40
Yingdi Yufa4ce792014-02-06 18:09:22 -080041BOOST_AUTO_TEST_SUITE_END()