blob: 52329a5c0e5ee25f6d2aabedce1fe0f097bdc65f [file] [log] [blame]
Alexander Afanasyev4671bf72014-05-19 09:01:37 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
11 */
12
13#include "management/nfd-channel-status.hpp"
14
15#include "boost-test.hpp"
16
17namespace ndn {
18namespace nfd {
19namespace tests {
20
21BOOST_AUTO_TEST_SUITE(ManagementTestNfdChannelStatus)
22
23BOOST_AUTO_TEST_CASE(Encode)
24{
25 ChannelStatus status1;
26 status1
27 .setLocalUri("udp4://192.168.2.1")
28 ;
29
30 Block wire;
31 BOOST_REQUIRE_NO_THROW(wire = status1.wireEncode());
32
33 // These octets are obtained by the snippet below.
34 // This check is intended to detect unexpected encoding change in the future.
35 // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
36 // printf("0x%02x, ", *it);
37 // }
38 static const uint8_t expected[] = {
39 0x82, 0x14, 0x81, 0x12, 0x75, 0x64, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32,
40 0x2e, 0x31, 0x36, 0x38, 0x2e, 0x32, 0x2e, 0x31
41 };
42 BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected),
43 wire.begin(), wire.end());
44
45 BOOST_REQUIRE_NO_THROW(ChannelStatus(wire));
46 ChannelStatus status2(wire);
47 BOOST_CHECK_EQUAL(status1.getLocalUri(), status2.getLocalUri());
48}
49
50BOOST_AUTO_TEST_SUITE_END()
51
52} // namespace tests
53} // namespace nfd
54} // namespace ndn