Alexander Afanasyev | 0553cd5 | 2014-02-18 02:34:45 -0800 | [diff] [blame^] | 1 | /* -*- 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 | |
| 12 | using namespace std; |
| 13 | |
| 14 | namespace ndn { |
| 15 | namespace nrd { |
| 16 | |
| 17 | BOOST_AUTO_TEST_SUITE(TestNrd) |
| 18 | |
| 19 | const 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 | |
| 24 | BOOST_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 | |
| 35 | BOOST_CHECK_EQUAL_COLLECTIONS (RealPrefixRegOptions, |
| 36 | RealPrefixRegOptions + sizeof (RealPrefixRegOptions), |
| 37 | blk.begin (), blk.end ()); |
| 38 | } |
| 39 | |
| 40 | BOOST_AUTO_TEST_CASE (PrefixRegOptionsDecoding) |
| 41 | { |
| 42 | Block blk (RealPrefixRegOptions, sizeof (RealPrefixRegOptions)); |
| 43 | Name n ("/localhost/reg/test"); |
| 44 | PrefixRegOptions opt; |
| 45 | |
| 46 | BOOST_REQUIRE_NO_THROW (opt.wireDecode (blk)); |
| 47 | |
| 48 | BOOST_CHECK_EQUAL (opt.getName (), n); |
| 49 | BOOST_CHECK_EQUAL (opt.getFaceId (), 0); |
| 50 | BOOST_CHECK_EQUAL (opt.getCost (), 0); |
| 51 | } |
| 52 | |
| 53 | BOOST_AUTO_TEST_SUITE_END() |
| 54 | |
| 55 | } // namespace nrd |
| 56 | } // namespace ndn |