blob: de95ee25de80d8e3bef1819650865e3d4c8abc9c [file] [log] [blame]
Alexander Afanasyev0553cd52014-02-18 02:34:45 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "management/nrd-prefix-reg-options.hpp"
8
9#include <boost/test/unit_test.hpp>
10#include <boost/test/output_test_stream.hpp>
11
12using namespace std;
13
14namespace ndn {
15namespace nrd {
16
17BOOST_AUTO_TEST_SUITE(TestNrd)
18
19const uint8_t RealPrefixRegOptions[] = {
20 0x65, 0x1b, 0x07, 0x16, 0x08, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74,
21 0x08, 0x03, 0x72, 0x65, 0x67, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x66, 0x01, 0x00,
22};
23
24BOOST_AUTO_TEST_CASE (PrefixRegOptionsEncode)
25{
26 Name n ("/localhost/reg/test");
27 PrefixRegOptions opt;
28
29 opt.setName (n);
30 opt.setFaceId (0);
31 opt.setCost (0);
32
33 const Block& blk = opt.wireEncode ();
34
Obaid6e7f5f12014-03-11 14:46:10 -050035 BOOST_CHECK_EQUAL_COLLECTIONS(RealPrefixRegOptions,
36 RealPrefixRegOptions + sizeof (RealPrefixRegOptions),
37 blk.begin (), blk.end ());
38
39 std::ostringstream os;
40 os << opt;
41 BOOST_CHECK_EQUAL(os.str(), "PrefixRegOptions(Prefix: /localhost/reg/test, "
42 "FaceID: 0, Flags: 1, Cost: 0, ExpirationPeriod: -1, Protocol: )");
Alexander Afanasyev0553cd52014-02-18 02:34:45 -080043}
44
45BOOST_AUTO_TEST_CASE (PrefixRegOptionsDecoding)
46{
47 Block blk (RealPrefixRegOptions, sizeof (RealPrefixRegOptions));
48 Name n ("/localhost/reg/test");
49 PrefixRegOptions opt;
50
51 BOOST_REQUIRE_NO_THROW (opt.wireDecode (blk));
52
53 BOOST_CHECK_EQUAL (opt.getName (), n);
54 BOOST_CHECK_EQUAL (opt.getFaceId (), 0);
55 BOOST_CHECK_EQUAL (opt.getCost (), 0);
56}
57
58BOOST_AUTO_TEST_SUITE_END()
59
60} // namespace nrd
61} // namespace ndn