blob: 52329a5c0e5ee25f6d2aabedce1fe0f097bdc65f [file] [log] [blame]
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/**
* Copyright (c) 2013-2014, Regents of the University of California.
* All rights reserved.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*
* This file licensed under New BSD License. See COPYING for detailed information about
* ndn-cxx library copyright, permissions, and redistribution restrictions.
*/
#include "management/nfd-channel-status.hpp"
#include "boost-test.hpp"
namespace ndn {
namespace nfd {
namespace tests {
BOOST_AUTO_TEST_SUITE(ManagementTestNfdChannelStatus)
BOOST_AUTO_TEST_CASE(Encode)
{
ChannelStatus status1;
status1
.setLocalUri("udp4://192.168.2.1")
;
Block wire;
BOOST_REQUIRE_NO_THROW(wire = status1.wireEncode());
// These octets are obtained by the snippet below.
// This check is intended to detect unexpected encoding change in the future.
// for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
// printf("0x%02x, ", *it);
// }
static const uint8_t expected[] = {
0x82, 0x14, 0x81, 0x12, 0x75, 0x64, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32,
0x2e, 0x31, 0x36, 0x38, 0x2e, 0x32, 0x2e, 0x31
};
BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected),
wire.begin(), wire.end());
BOOST_REQUIRE_NO_THROW(ChannelStatus(wire));
ChannelStatus status2(wire);
BOOST_CHECK_EQUAL(status1.getLocalUri(), status2.getLocalUri());
}
BOOST_AUTO_TEST_SUITE_END()
} // namespace tests
} // namespace nfd
} // namespace ndn