blob: aa63b72dfd7affc27f673a738d9f559ce1d4fc0e [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/nrd-prefix-reg-options.hpp"
#include "boost-test.hpp"
namespace ndn {
namespace nrd {
BOOST_AUTO_TEST_SUITE(ManagementTestNrd)
const uint8_t RealPrefixRegOptions[] = {
0x65, 0x1b, 0x07, 0x16, 0x08, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74,
0x08, 0x03, 0x72, 0x65, 0x67, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x66, 0x01, 0x00,
};
BOOST_AUTO_TEST_CASE(PrefixRegOptionsEncode)
{
Name n("/localhost/reg/test");
PrefixRegOptions opt;
opt.setName(n);
opt.setFaceId(0);
opt.setCost(0);
const Block& blk = opt.wireEncode();
BOOST_CHECK_EQUAL_COLLECTIONS(RealPrefixRegOptions,
RealPrefixRegOptions + sizeof(RealPrefixRegOptions),
blk.begin(), blk.end());
std::ostringstream os;
os << opt;
BOOST_CHECK_EQUAL(os.str(), "PrefixRegOptions(Prefix: /localhost/reg/test, "
"FaceID: 0, Flags: 1, Cost: 0, "
"ExpirationPeriod: -9223372036854775808 milliseconds, Protocol: )");
}
BOOST_AUTO_TEST_CASE(PrefixRegOptionsDecoding)
{
Block blk(RealPrefixRegOptions, sizeof(RealPrefixRegOptions));
Name n("/localhost/reg/test");
PrefixRegOptions opt;
BOOST_REQUIRE_NO_THROW(opt.wireDecode(blk));
BOOST_CHECK_EQUAL(opt.getName(), n);
BOOST_CHECK_EQUAL(opt.getFaceId(), 0);
BOOST_CHECK_EQUAL(opt.getCost(), 0);
}
BOOST_AUTO_TEST_SUITE_END()
} // namespace nrd
} // namespace ndn