blob: 5e3ea6c653661db7fcb8aafbf2593736d9542842 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Alexander Afanasyev4671bf72014-05-19 09:01:37 -04002/**
Alexander Afanasyevc169a812014-05-20 20:37:29 -04003 * Copyright (c) 2013-2014 Regents of the University of California.
Alexander Afanasyev4671bf72014-05-19 09:01:37 -04004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyev4671bf72014-05-19 09:01:37 -04006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Alexander Afanasyev4671bf72014-05-19 09:01:37 -040020 */
21
22#include "management/nfd-channel-status.hpp"
23
24#include "boost-test.hpp"
25
26namespace ndn {
27namespace nfd {
28namespace tests {
29
30BOOST_AUTO_TEST_SUITE(ManagementTestNfdChannelStatus)
31
32BOOST_AUTO_TEST_CASE(Encode)
33{
34 ChannelStatus status1;
35 status1
36 .setLocalUri("udp4://192.168.2.1")
37 ;
38
39 Block wire;
40 BOOST_REQUIRE_NO_THROW(wire = status1.wireEncode());
41
42 // These octets are obtained by the snippet below.
43 // This check is intended to detect unexpected encoding change in the future.
44 // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
45 // printf("0x%02x, ", *it);
46 // }
47 static const uint8_t expected[] = {
48 0x82, 0x14, 0x81, 0x12, 0x75, 0x64, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32,
49 0x2e, 0x31, 0x36, 0x38, 0x2e, 0x32, 0x2e, 0x31
50 };
51 BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected),
52 wire.begin(), wire.end());
53
54 BOOST_REQUIRE_NO_THROW(ChannelStatus(wire));
55 ChannelStatus status2(wire);
56 BOOST_CHECK_EQUAL(status1.getLocalUri(), status2.getLocalUri());
57}
58
59BOOST_AUTO_TEST_SUITE_END()
60
61} // namespace tests
62} // namespace nfd
63} // namespace ndn