Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 2 | /** |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 3 | * Copyright (c) 2013-2016 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 22 | #include "mgmt/nfd/face-event-notification.hpp" |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 23 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 24 | #include "boost-test.hpp" |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 25 | |
| 26 | namespace ndn { |
| 27 | namespace nfd { |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 28 | namespace tests { |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 29 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 30 | BOOST_AUTO_TEST_SUITE(Mgmt) |
| 31 | BOOST_AUTO_TEST_SUITE(Nfd) |
| 32 | BOOST_AUTO_TEST_SUITE(TestFaceEventNotification) |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 33 | |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 34 | BOOST_AUTO_TEST_CASE(Traits) |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 35 | { |
| 36 | FaceEventNotification notification; |
| 37 | |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 38 | BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_NON_LOCAL); |
| 39 | BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_PERSISTENT); |
| 40 | BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_POINT_TO_POINT); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 41 | |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 42 | notification.setFaceScope(FACE_SCOPE_LOCAL); |
| 43 | BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_LOCAL); |
| 44 | BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_PERSISTENT); |
| 45 | BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_POINT_TO_POINT); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 46 | |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 47 | notification.setFacePersistency(FACE_PERSISTENCY_ON_DEMAND); |
| 48 | BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_LOCAL); |
| 49 | BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_ON_DEMAND); |
| 50 | BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_POINT_TO_POINT); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 51 | |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 52 | notification.setFacePersistency(FACE_PERSISTENCY_PERMANENT); |
| 53 | BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_LOCAL); |
| 54 | BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_PERMANENT); |
| 55 | BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_POINT_TO_POINT); |
| 56 | |
| 57 | notification.setLinkType(LINK_TYPE_MULTI_ACCESS); |
| 58 | BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_LOCAL); |
| 59 | BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_PERMANENT); |
| 60 | BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_MULTI_ACCESS); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | BOOST_AUTO_TEST_CASE(EncodeCreated) |
| 64 | { |
| 65 | FaceEventNotification notification1; |
| 66 | notification1.setKind(FACE_EVENT_CREATED) |
| 67 | .setFaceId(20) |
| 68 | .setRemoteUri("tcp4://192.0.2.1:55555") |
| 69 | .setLocalUri("tcp4://192.0.2.2:6363") |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 70 | .setFaceScope(FACE_SCOPE_LOCAL) |
| 71 | .setFacePersistency(FACE_PERSISTENCY_ON_DEMAND) |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 72 | .setLinkType(LINK_TYPE_MULTI_ACCESS) |
| 73 | .setFlags(0x3); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 74 | Block wire; |
| 75 | BOOST_REQUIRE_NO_THROW(wire = notification1.wireEncode()); |
| 76 | |
| 77 | // These octets are obtained by the snippet below. |
| 78 | // This check is intended to detect unexpected encoding change in the future. |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 79 | // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) { |
| 80 | // printf("0x%02x, ", *it); |
| 81 | // } |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 82 | static const uint8_t expected[] = { |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 83 | 0xc0, 0x41, 0xc1, 0x01, 0x01, 0x69, 0x01, 0x14, 0x72, 0x16, |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 84 | 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, |
| 85 | 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x31, 0x3a, 0x35, 0x35, 0x35, |
| 86 | 0x35, 0x35, 0x81, 0x15, 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, |
| 87 | 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32, |
| 88 | 0x3a, 0x36, 0x33, 0x36, 0x33, 0x84, 0x01, 0x01, 0x85, 0x01, |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 89 | 0x01, 0x86, 0x01, 0x01, 0x6c, 0x01, 0x03, |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 90 | }; |
| 91 | BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected), |
| 92 | wire.begin(), wire.end()); |
| 93 | |
| 94 | BOOST_REQUIRE_NO_THROW(FaceEventNotification(wire)); |
| 95 | FaceEventNotification notification2(wire); |
| 96 | BOOST_CHECK_EQUAL(notification1.getKind(), notification2.getKind()); |
| 97 | BOOST_CHECK_EQUAL(notification1.getFaceId(), notification2.getFaceId()); |
| 98 | BOOST_CHECK_EQUAL(notification1.getRemoteUri(), notification2.getRemoteUri()); |
| 99 | BOOST_CHECK_EQUAL(notification1.getLocalUri(), notification2.getLocalUri()); |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 100 | BOOST_CHECK_EQUAL(notification1.getFaceScope(), notification2.getFaceScope()); |
| 101 | BOOST_CHECK_EQUAL(notification1.getFacePersistency(), notification2.getFacePersistency()); |
| 102 | BOOST_CHECK_EQUAL(notification1.getLinkType(), notification2.getLinkType()); |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 103 | BOOST_CHECK_EQUAL(notification1.getFlags(), notification2.getFlags()); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 104 | |
| 105 | std::ostringstream os; |
| 106 | os << notification2; |
| 107 | BOOST_CHECK_EQUAL(os.str(), "FaceEventNotification(" |
| 108 | "Kind: created, " |
| 109 | "FaceID: 20, " |
| 110 | "RemoteUri: tcp4://192.0.2.1:55555, " |
| 111 | "LocalUri: tcp4://192.0.2.2:6363, " |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 112 | "FaceScope: local, " |
| 113 | "FacePersistency: on-demand, " |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 114 | "LinkType: multi-access, " |
| 115 | "Flags: 0x3)"); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | BOOST_AUTO_TEST_CASE(EncodeDestroyed) |
| 119 | { |
| 120 | FaceEventNotification notification1; |
| 121 | notification1.setKind(FACE_EVENT_DESTROYED) |
| 122 | .setFaceId(20) |
| 123 | .setRemoteUri("tcp4://192.0.2.1:55555") |
| 124 | .setLocalUri("tcp4://192.0.2.2:6363") |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 125 | .setFaceScope(FACE_SCOPE_LOCAL) |
| 126 | .setFacePersistency(FACE_PERSISTENCY_ON_DEMAND) |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 127 | .setLinkType(LINK_TYPE_MULTI_ACCESS) |
| 128 | .setFlags(0x4); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 129 | Block wire; |
| 130 | BOOST_REQUIRE_NO_THROW(wire = notification1.wireEncode()); |
| 131 | |
| 132 | // These octets are obtained by the snippet below. |
| 133 | // This check is intended to detect unexpected encoding change in the future. |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 134 | // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) { |
| 135 | // printf("0x%02x, ", *it); |
| 136 | // } |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 137 | static const uint8_t expected[] = { |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 138 | 0xc0, 0x41, 0xc1, 0x01, 0x02, 0x69, 0x01, 0x14, 0x72, 0x16, |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 139 | 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, |
| 140 | 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x31, 0x3a, 0x35, 0x35, 0x35, |
| 141 | 0x35, 0x35, 0x81, 0x15, 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, |
| 142 | 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32, |
| 143 | 0x3a, 0x36, 0x33, 0x36, 0x33, 0x84, 0x01, 0x01, 0x85, 0x01, |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 144 | 0x01, 0x86, 0x01, 0x01, 0x6c, 0x01, 0x04, |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 145 | }; |
| 146 | BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected), |
| 147 | wire.begin(), wire.end()); |
| 148 | |
| 149 | BOOST_REQUIRE_NO_THROW(FaceEventNotification(wire)); |
| 150 | FaceEventNotification notification2(wire); |
| 151 | BOOST_CHECK_EQUAL(notification1.getKind(), notification2.getKind()); |
| 152 | BOOST_CHECK_EQUAL(notification1.getFaceId(), notification2.getFaceId()); |
| 153 | BOOST_CHECK_EQUAL(notification1.getRemoteUri(), notification2.getRemoteUri()); |
| 154 | BOOST_CHECK_EQUAL(notification1.getLocalUri(), notification2.getLocalUri()); |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 155 | BOOST_CHECK_EQUAL(notification1.getFaceScope(), notification2.getFaceScope()); |
| 156 | BOOST_CHECK_EQUAL(notification1.getFacePersistency(), notification2.getFacePersistency()); |
| 157 | BOOST_CHECK_EQUAL(notification1.getLinkType(), notification2.getLinkType()); |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 158 | BOOST_CHECK_EQUAL(notification1.getFlags(), notification2.getFlags()); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 159 | |
| 160 | std::ostringstream os; |
| 161 | os << notification2; |
| 162 | BOOST_CHECK_EQUAL(os.str(), "FaceEventNotification(" |
| 163 | "Kind: destroyed, " |
| 164 | "FaceID: 20, " |
| 165 | "RemoteUri: tcp4://192.0.2.1:55555, " |
| 166 | "LocalUri: tcp4://192.0.2.2:6363, " |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 167 | "FaceScope: local, " |
| 168 | "FacePersistency: on-demand, " |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 169 | "LinkType: multi-access, " |
| 170 | "Flags: 0x4)"); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 171 | } |
| 172 | |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 173 | BOOST_AUTO_TEST_CASE(EncodeUp) |
| 174 | { |
| 175 | FaceEventNotification notification1; |
| 176 | notification1.setKind(FACE_EVENT_UP) |
| 177 | .setFaceId(20) |
| 178 | .setRemoteUri("tcp4://192.0.2.1:55555") |
| 179 | .setLocalUri("tcp4://192.0.2.2:6363") |
| 180 | .setFaceScope(FACE_SCOPE_LOCAL) |
| 181 | .setFacePersistency(FACE_PERSISTENCY_ON_DEMAND) |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 182 | .setLinkType(LINK_TYPE_MULTI_ACCESS) |
| 183 | .setFlags(0x05); |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 184 | Block wire; |
| 185 | BOOST_REQUIRE_NO_THROW(wire = notification1.wireEncode()); |
| 186 | |
| 187 | // These octets are obtained by the snippet below. |
| 188 | // This check is intended to detect unexpected encoding change in the future. |
| 189 | // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) { |
| 190 | // printf("0x%02x, ", *it); |
| 191 | // } |
| 192 | static const uint8_t expected[] = { |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 193 | 0xc0, 0x41, 0xc1, 0x01, 0x03, 0x69, 0x01, 0x14, 0x72, 0x16, |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 194 | 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, |
| 195 | 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x31, 0x3a, 0x35, 0x35, 0x35, |
| 196 | 0x35, 0x35, 0x81, 0x15, 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, |
| 197 | 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32, |
| 198 | 0x3a, 0x36, 0x33, 0x36, 0x33, 0x84, 0x01, 0x01, 0x85, 0x01, |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 199 | 0x01, 0x86, 0x01, 0x01, 0x6c, 0x01, 0x05, |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 200 | }; |
| 201 | BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected), |
| 202 | wire.begin(), wire.end()); |
| 203 | |
| 204 | BOOST_REQUIRE_NO_THROW(FaceEventNotification(wire)); |
| 205 | FaceEventNotification notification2(wire); |
| 206 | BOOST_CHECK_EQUAL(notification1.getKind(), notification2.getKind()); |
| 207 | BOOST_CHECK_EQUAL(notification1.getFaceId(), notification2.getFaceId()); |
| 208 | BOOST_CHECK_EQUAL(notification1.getRemoteUri(), notification2.getRemoteUri()); |
| 209 | BOOST_CHECK_EQUAL(notification1.getLocalUri(), notification2.getLocalUri()); |
| 210 | BOOST_CHECK_EQUAL(notification1.getFaceScope(), notification2.getFaceScope()); |
| 211 | BOOST_CHECK_EQUAL(notification1.getFacePersistency(), notification2.getFacePersistency()); |
| 212 | BOOST_CHECK_EQUAL(notification1.getLinkType(), notification2.getLinkType()); |
| 213 | |
| 214 | std::ostringstream os; |
| 215 | os << notification2; |
| 216 | BOOST_CHECK_EQUAL(os.str(), "FaceEventNotification(" |
| 217 | "Kind: up, " |
| 218 | "FaceID: 20, " |
| 219 | "RemoteUri: tcp4://192.0.2.1:55555, " |
| 220 | "LocalUri: tcp4://192.0.2.2:6363, " |
| 221 | "FaceScope: local, " |
| 222 | "FacePersistency: on-demand, " |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 223 | "LinkType: multi-access, " |
| 224 | "Flags: 0x5)"); |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | BOOST_AUTO_TEST_CASE(EncodeDown) |
| 228 | { |
| 229 | FaceEventNotification notification1; |
| 230 | notification1.setKind(FACE_EVENT_DOWN) |
| 231 | .setFaceId(20) |
| 232 | .setRemoteUri("tcp4://192.0.2.1:55555") |
| 233 | .setLocalUri("tcp4://192.0.2.2:6363") |
| 234 | .setFaceScope(FACE_SCOPE_LOCAL) |
| 235 | .setFacePersistency(FACE_PERSISTENCY_ON_DEMAND) |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 236 | .setLinkType(LINK_TYPE_MULTI_ACCESS) |
| 237 | .setFlags(0x06); |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 238 | Block wire; |
| 239 | BOOST_REQUIRE_NO_THROW(wire = notification1.wireEncode()); |
| 240 | |
| 241 | // These octets are obtained by the snippet below. |
| 242 | // This check is intended to detect unexpected encoding change in the future. |
| 243 | // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) { |
| 244 | // printf("0x%02x, ", *it); |
| 245 | // } |
| 246 | static const uint8_t expected[] = { |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 247 | 0xc0, 0x41, 0xc1, 0x01, 0x04, 0x69, 0x01, 0x14, 0x72, 0x16, |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 248 | 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, |
| 249 | 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x31, 0x3a, 0x35, 0x35, 0x35, |
| 250 | 0x35, 0x35, 0x81, 0x15, 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, |
| 251 | 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32, |
| 252 | 0x3a, 0x36, 0x33, 0x36, 0x33, 0x84, 0x01, 0x01, 0x85, 0x01, |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 253 | 0x01, 0x86, 0x01, 0x01, 0x6c, 0x01, 0x06, |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 254 | }; |
| 255 | BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected), |
| 256 | wire.begin(), wire.end()); |
| 257 | |
| 258 | BOOST_REQUIRE_NO_THROW(FaceEventNotification(wire)); |
| 259 | FaceEventNotification notification2(wire); |
| 260 | BOOST_CHECK_EQUAL(notification1.getKind(), notification2.getKind()); |
| 261 | BOOST_CHECK_EQUAL(notification1.getFaceId(), notification2.getFaceId()); |
| 262 | BOOST_CHECK_EQUAL(notification1.getRemoteUri(), notification2.getRemoteUri()); |
| 263 | BOOST_CHECK_EQUAL(notification1.getLocalUri(), notification2.getLocalUri()); |
| 264 | BOOST_CHECK_EQUAL(notification1.getFaceScope(), notification2.getFaceScope()); |
| 265 | BOOST_CHECK_EQUAL(notification1.getFacePersistency(), notification2.getFacePersistency()); |
| 266 | BOOST_CHECK_EQUAL(notification1.getLinkType(), notification2.getLinkType()); |
| 267 | |
| 268 | std::ostringstream os; |
| 269 | os << notification2; |
| 270 | BOOST_CHECK_EQUAL(os.str(), "FaceEventNotification(" |
| 271 | "Kind: down, " |
| 272 | "FaceID: 20, " |
| 273 | "RemoteUri: tcp4://192.0.2.1:55555, " |
| 274 | "LocalUri: tcp4://192.0.2.2:6363, " |
| 275 | "FaceScope: local, " |
| 276 | "FacePersistency: on-demand, " |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame^] | 277 | "LinkType: multi-access, " |
| 278 | "Flags: 0x6)"); |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 281 | BOOST_AUTO_TEST_SUITE_END() // TestFaceEventNotification |
| 282 | BOOST_AUTO_TEST_SUITE_END() // Nfd |
| 283 | BOOST_AUTO_TEST_SUITE_END() // Mgmt |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 284 | |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 285 | } // namespace tests |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 286 | } // namespace nfd |
| 287 | } // namespace ndn |