Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (C) 2013 Regents of the University of California. |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 3 | * See COPYING for copyright and distribution information. |
| 4 | */ |
| 5 | |
| 6 | #include <boost/test/unit_test.hpp> |
| 7 | |
Alexander Afanasyev | 09c613f | 2014-01-29 00:23:58 -0800 | [diff] [blame] | 8 | #include "interest.hpp" |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 9 | |
| 10 | using namespace std; |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 11 | namespace ndn { |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 12 | |
| 13 | BOOST_AUTO_TEST_SUITE(TestInterest) |
| 14 | |
| 15 | const uint8_t Interest1[] = { |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 16 | 0x05, 0x59, // NDN Interest |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 17 | 0x07, 0x14, // Name |
| 18 | 0x08, 0x5, // NameComponent |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 19 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 20 | 0x08, 0x3, // NameComponent |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 21 | 0x6e, 0x64, 0x6e, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 22 | 0x08, 0x6, // NameComponent |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 23 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 24 | 0x09, 0x37, // Selectors |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 25 | 0x0d, 0x1, 0x1, // MinSuffix |
| 26 | 0x0e, 0x1, 0x1, // MaxSuffix |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 27 | 0x1c, 0x16, // KeyLocator |
| 28 | 0x07, 0x14, // Name |
| 29 | 0x08, 0x04, |
| 30 | 0x74, 0x65, 0x73, 0x74, |
| 31 | 0x08, 0x03, |
| 32 | 0x6b, 0x65, 0x79, |
| 33 | 0x08, 0x07, |
| 34 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 35 | 0x10, 0x14, // Exclude |
| 36 | 0x08, 0x4, // NameComponent |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 37 | 0x61, 0x6c, 0x65, 0x78, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 38 | 0x08, 0x4, // NameComponent |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 39 | 0x78, 0x78, 0x78, 0x78, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 40 | 0x13, 0x0, // Any |
| 41 | 0x08, 0x4, // NameComponent |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 42 | 0x79, 0x79, 0x79, 0x79, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 43 | 0x11, 0x1, // ChildSelector |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 44 | 0x1, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 45 | 0x0a, 0x1, // Nonce |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 46 | 0x1, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 47 | 0x0b, 0x1, // Scope |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 48 | 0x1, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 49 | 0x0c, // InterestLifetime |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 50 | 0x2, 0x3, 0xe8 |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 51 | }; |
| 52 | |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 53 | const uint8_t InterestWithLocalControlHeader[] = { |
| 54 | 0x50, 0x22, 0x51, 0x01, 0x0a, 0x05, 0x1d, 0x07, 0x14, 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, |
| 55 | 0x6c, 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x09, |
| 56 | 0x02, 0x12, 0x00, 0x0a, 0x01, 0x01 |
| 57 | }; |
| 58 | |
| 59 | const uint8_t InterestWithoutLocalControlHeader[] = { |
| 60 | 0x05, 0x1d, 0x07, 0x14, 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, |
| 61 | 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x09, 0x02, 0x12, 0x00, 0x0a, 0x01, |
| 62 | 0x01 |
| 63 | }; |
| 64 | |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 65 | BOOST_AUTO_TEST_CASE (Decode) |
| 66 | { |
| 67 | Block interestBlock(Interest1, sizeof(Interest1)); |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 68 | |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 69 | ndn::Interest i; |
Alexander Afanasyev | 049f8f7 | 2013-12-26 19:07:15 -0800 | [diff] [blame] | 70 | BOOST_REQUIRE_NO_THROW(i.wireDecode(interestBlock)); |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 71 | |
Alexander Afanasyev | 049f8f7 | 2013-12-26 19:07:15 -0800 | [diff] [blame] | 72 | BOOST_REQUIRE_EQUAL(i.getName().toUri(), "/local/ndn/prefix"); |
| 73 | BOOST_REQUIRE_EQUAL(i.getScope(), 1); |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 74 | BOOST_REQUIRE_EQUAL(i.getInterestLifetime(), time::milliseconds(1000)); |
Alexander Afanasyev | 049f8f7 | 2013-12-26 19:07:15 -0800 | [diff] [blame] | 75 | BOOST_REQUIRE_EQUAL(i.getMinSuffixComponents(), 1); |
| 76 | BOOST_REQUIRE_EQUAL(i.getMaxSuffixComponents(), 1); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 77 | BOOST_REQUIRE_EQUAL(i.getPublisherPublicKeyLocator().getType(), |
| 78 | static_cast<uint32_t>(KeyLocator::KeyLocator_Name)); |
| 79 | BOOST_REQUIRE_EQUAL(i.getPublisherPublicKeyLocator().getName(), "ndn:/test/key/locator"); |
Alexander Afanasyev | 049f8f7 | 2013-12-26 19:07:15 -0800 | [diff] [blame] | 80 | BOOST_REQUIRE_EQUAL(i.getChildSelector(), 1); |
| 81 | BOOST_REQUIRE_EQUAL(i.getMustBeFresh(), false); |
| 82 | BOOST_REQUIRE_EQUAL(i.getExclude().toUri(), "alex,xxxx,*,yyyy"); |
Alexander Afanasyev | 840139f | 2013-12-28 15:02:50 -0800 | [diff] [blame] | 83 | BOOST_REQUIRE_EQUAL(i.getNonce(), 1); |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 84 | } |
| 85 | |
Alexander Afanasyev | 6835ad8 | 2014-02-12 10:07:20 -0800 | [diff] [blame] | 86 | BOOST_AUTO_TEST_CASE (DecodeFromStream) |
| 87 | { |
| 88 | boost::iostreams::stream<boost::iostreams::array_source> is (reinterpret_cast<const char *>(Interest1), sizeof(Interest1)); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 89 | |
Alexander Afanasyev | 6835ad8 | 2014-02-12 10:07:20 -0800 | [diff] [blame] | 90 | Block interestBlock(is); |
| 91 | |
| 92 | ndn::Interest i; |
| 93 | BOOST_REQUIRE_NO_THROW(i.wireDecode(interestBlock)); |
| 94 | |
| 95 | BOOST_REQUIRE_EQUAL(i.getName().toUri(), "/local/ndn/prefix"); |
| 96 | BOOST_REQUIRE_EQUAL(i.getScope(), 1); |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 97 | BOOST_REQUIRE_EQUAL(i.getInterestLifetime(), time::milliseconds(1000)); |
Alexander Afanasyev | 6835ad8 | 2014-02-12 10:07:20 -0800 | [diff] [blame] | 98 | BOOST_REQUIRE_EQUAL(i.getMinSuffixComponents(), 1); |
| 99 | BOOST_REQUIRE_EQUAL(i.getMaxSuffixComponents(), 1); |
| 100 | BOOST_REQUIRE_EQUAL(i.getChildSelector(), 1); |
| 101 | BOOST_REQUIRE_EQUAL(i.getMustBeFresh(), false); |
| 102 | BOOST_REQUIRE_EQUAL(i.getExclude().toUri(), "alex,xxxx,*,yyyy"); |
| 103 | BOOST_REQUIRE_EQUAL(i.getNonce(), 1); |
| 104 | } |
| 105 | |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 106 | BOOST_AUTO_TEST_CASE (Encode) |
| 107 | { |
| 108 | ndn::Interest i(ndn::Name("/local/ndn/prefix")); |
| 109 | i.setScope(1); |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 110 | i.setInterestLifetime(time::milliseconds(1000)); |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 111 | i.setMinSuffixComponents(1); |
| 112 | i.setMaxSuffixComponents(1); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 113 | i.setPublisherPublicKeyLocator(KeyLocator("ndn:/test/key/locator")); |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 114 | i.setChildSelector(1); |
| 115 | i.setMustBeFresh(false); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 116 | Exclude exclude; |
| 117 | exclude |
Alexander Afanasyev | 52eb20d | 2014-02-06 18:25:54 -0800 | [diff] [blame] | 118 | .excludeOne(name::Component("alex")) |
| 119 | .excludeRange(name::Component("xxxx"), name::Component("yyyy")); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 120 | i.setExclude(exclude); |
Alexander Afanasyev | 840139f | 2013-12-28 15:02:50 -0800 | [diff] [blame] | 121 | i.setNonce(1); |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 122 | |
| 123 | const Block &wire = i.wireEncode(); |
Alexander Afanasyev | 809805d | 2014-02-17 17:20:33 -0800 | [diff] [blame] | 124 | |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 125 | BOOST_CHECK_EQUAL_COLLECTIONS(Interest1, Interest1+sizeof(Interest1), |
| 126 | wire.begin(), wire.end()); |
| 127 | } |
| 128 | |
| 129 | |
| 130 | BOOST_AUTO_TEST_CASE(EncodeWithLocalHeader) |
| 131 | { |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 132 | ndn::Interest interest(ndn::Name("/local/ndn/prefix")); |
| 133 | interest.setMustBeFresh(true); |
| 134 | interest.setIncomingFaceId(10); |
| 135 | interest.setNonce(1); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 136 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 137 | BOOST_CHECK(!interest.hasWire()); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 138 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 139 | Block headerBlock = interest.getLocalControlHeader().wireEncode(interest, true, true); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 140 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 141 | BOOST_CHECK(interest.hasWire()); |
| 142 | BOOST_CHECK(headerBlock.hasWire()); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 143 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 144 | BOOST_CHECK_NE(headerBlock.wire(), interest.wireEncode().wire()); |
| 145 | BOOST_CHECK_NE(headerBlock.size(), interest.wireEncode().size()); |
| 146 | BOOST_CHECK_EQUAL(headerBlock.size(), 5); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 147 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 148 | BOOST_CHECK_EQUAL_COLLECTIONS(InterestWithLocalControlHeader, |
| 149 | InterestWithLocalControlHeader+5, |
| 150 | headerBlock.begin(), headerBlock.end()); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 151 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 152 | interest.setNonce(1000); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 153 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 154 | Block updatedHeaderBlock = interest.getLocalControlHeader().wireEncode(interest, true, true); |
| 155 | BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 5); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 156 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 157 | // only length should have changed |
| 158 | BOOST_CHECK_EQUAL_COLLECTIONS(updatedHeaderBlock.begin()+2, updatedHeaderBlock.end(), |
| 159 | headerBlock.begin()+2, headerBlock.end()); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 160 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 161 | // updating IncomingFaceId that keeps the length |
| 162 | interest.setIncomingFaceId(100); |
| 163 | updatedHeaderBlock = interest.getLocalControlHeader().wireEncode(interest, true, true); |
| 164 | BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 5); |
| 165 | BOOST_CHECK_NE(*(updatedHeaderBlock.begin()+4), *(headerBlock.begin()+4)); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 166 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 167 | // updating IncomingFaceId that increases the length by 2 |
| 168 | interest.setIncomingFaceId(1000); |
| 169 | updatedHeaderBlock = interest.getLocalControlHeader().wireEncode(interest, true, true); |
| 170 | BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 6); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 171 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 172 | // adding NextHopId |
| 173 | interest.setNextHopFaceId(1); |
| 174 | updatedHeaderBlock = interest.getLocalControlHeader().wireEncode(interest, true, true); |
| 175 | BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 9); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 176 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 177 | // masking IncomingFaceId |
| 178 | updatedHeaderBlock = interest.getLocalControlHeader().wireEncode(interest, false, true); |
| 179 | BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 5); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 180 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 181 | // masking NextHopId |
| 182 | updatedHeaderBlock = interest.getLocalControlHeader().wireEncode(interest, true, false); |
| 183 | BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 6); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 184 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 185 | // masking everything |
| 186 | BOOST_CHECK_THROW(interest.getLocalControlHeader().wireEncode(interest, false, false), |
| 187 | nfd::LocalControlHeader::Error); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 188 | } |
| 189 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 190 | |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 191 | BOOST_AUTO_TEST_CASE (DecodeWithLocalHeader) |
| 192 | { |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 193 | Block wireBlock(InterestWithLocalControlHeader, sizeof(InterestWithLocalControlHeader)); |
| 194 | const Block& payload = nfd::LocalControlHeader::getPayload(wireBlock); |
| 195 | BOOST_REQUIRE_NE(&payload, &wireBlock); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 196 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 197 | BOOST_CHECK_EQUAL(payload.type(), (uint32_t)Tlv::Interest); |
| 198 | BOOST_CHECK_EQUAL(wireBlock.type(), (uint32_t)tlv::nfd::LocalControlHeader); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 199 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 200 | Interest interest(payload); |
| 201 | BOOST_CHECK(!interest.getLocalControlHeader().hasIncomingFaceId()); |
| 202 | BOOST_CHECK(!interest.getLocalControlHeader().hasNextHopFaceId()); |
| 203 | |
| 204 | BOOST_REQUIRE_NO_THROW(interest.getLocalControlHeader().wireDecode(wireBlock)); |
| 205 | |
| 206 | BOOST_CHECK_EQUAL(interest.getLocalControlHeader().wireEncode(interest, true, true).size(), 5); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 207 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 208 | BOOST_CHECK_EQUAL(interest.getIncomingFaceId(), 10); |
| 209 | BOOST_CHECK(!interest.getLocalControlHeader().hasNextHopFaceId()); |
| 210 | |
| 211 | BOOST_CHECK_THROW(interest.getLocalControlHeader().wireEncode(interest, false, false), |
| 212 | nfd::LocalControlHeader::Error); |
| 213 | |
| 214 | BOOST_CHECK_THROW(interest.getLocalControlHeader().wireEncode(interest, false, true), |
| 215 | nfd::LocalControlHeader::Error); |
| 216 | |
| 217 | BOOST_CHECK_NO_THROW(interest.getLocalControlHeader().wireEncode(interest, true, false)); |
| 218 | BOOST_CHECK_NO_THROW(interest.getLocalControlHeader().wireEncode(interest, true, true)); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 219 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 220 | BOOST_CHECK_NE((void*)interest.getLocalControlHeader().wireEncode(interest, true, true).wire(), |
| 221 | (void*)wireBlock.wire()); |
| 222 | |
| 223 | BOOST_CHECK_EQUAL(interest.getLocalControlHeader().wireEncode(interest, true, true).size(), 5); |
| 224 | } |
| 225 | |
| 226 | BOOST_AUTO_TEST_CASE (DecodeWithoutLocalHeader) |
| 227 | { |
| 228 | Block wireBlock(InterestWithoutLocalControlHeader, sizeof(InterestWithoutLocalControlHeader)); |
| 229 | const Block& payload = nfd::LocalControlHeader::getPayload(wireBlock); |
| 230 | BOOST_CHECK_EQUAL(&payload, &wireBlock); |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | BOOST_AUTO_TEST_SUITE_END() |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 234 | |
| 235 | } // namespace ndn |