Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 74daf74 | 2018-11-23 18:14:13 -0500 | [diff] [blame] | 2 | /* |
Davide Pesavento | 152ef44 | 2023-04-22 02:02:29 -0400 | [diff] [blame] | 3 | * Copyright (c) 2013-2023 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 | |
Davide Pesavento | 7e78064 | 2018-11-24 15:51:34 -0500 | [diff] [blame] | 22 | #include "ndn-cxx/mgmt/nfd/face-event-notification.hpp" |
Davide Pesavento | 152ef44 | 2023-04-22 02:02:29 -0400 | [diff] [blame] | 23 | #include "ndn-cxx/util/concepts.hpp" |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 24 | |
Davide Pesavento | 7e78064 | 2018-11-24 15:51:34 -0500 | [diff] [blame] | 25 | #include "tests/boost-test.hpp" |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 26 | |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 27 | #include <boost/lexical_cast.hpp> |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 28 | |
Davide Pesavento | 47ce2ee | 2023-05-09 01:33:33 -0400 | [diff] [blame] | 29 | namespace ndn::tests { |
| 30 | |
| 31 | using namespace ndn::nfd; |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 32 | |
Davide Pesavento | 152ef44 | 2023-04-22 02:02:29 -0400 | [diff] [blame] | 33 | BOOST_CONCEPT_ASSERT((NotificationStreamItem<FaceEventNotification>)); |
| 34 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 35 | BOOST_AUTO_TEST_SUITE(Mgmt) |
| 36 | BOOST_AUTO_TEST_SUITE(Nfd) |
| 37 | BOOST_AUTO_TEST_SUITE(TestFaceEventNotification) |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 38 | |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 39 | BOOST_AUTO_TEST_CASE(Traits) |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 40 | { |
| 41 | FaceEventNotification notification; |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 42 | BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_NON_LOCAL); |
| 43 | BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_PERSISTENT); |
| 44 | BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_POINT_TO_POINT); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 45 | |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 46 | notification.setFaceScope(FACE_SCOPE_LOCAL); |
| 47 | BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_LOCAL); |
| 48 | BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_PERSISTENT); |
| 49 | BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_POINT_TO_POINT); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 50 | |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 51 | notification.setFacePersistency(FACE_PERSISTENCY_ON_DEMAND); |
| 52 | BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_LOCAL); |
| 53 | BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_ON_DEMAND); |
| 54 | BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_POINT_TO_POINT); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 55 | |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 56 | notification.setFacePersistency(FACE_PERSISTENCY_PERMANENT); |
| 57 | BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_LOCAL); |
| 58 | BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_PERMANENT); |
| 59 | BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_POINT_TO_POINT); |
| 60 | |
| 61 | notification.setLinkType(LINK_TYPE_MULTI_ACCESS); |
| 62 | BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_LOCAL); |
| 63 | BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_PERMANENT); |
| 64 | BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_MULTI_ACCESS); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 65 | } |
| 66 | |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 67 | BOOST_AUTO_TEST_CASE(Created) |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 68 | { |
| 69 | FaceEventNotification notification1; |
| 70 | notification1.setKind(FACE_EVENT_CREATED) |
| 71 | .setFaceId(20) |
| 72 | .setRemoteUri("tcp4://192.0.2.1:55555") |
| 73 | .setLocalUri("tcp4://192.0.2.2:6363") |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 74 | .setFaceScope(FACE_SCOPE_LOCAL) |
| 75 | .setFacePersistency(FACE_PERSISTENCY_ON_DEMAND) |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame] | 76 | .setLinkType(LINK_TYPE_MULTI_ACCESS) |
| 77 | .setFlags(0x3); |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 78 | Block wire = notification1.wireEncode(); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 79 | |
| 80 | // These octets are obtained by the snippet below. |
| 81 | // This check is intended to detect unexpected encoding change in the future. |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 82 | // for (auto it = wire.begin(); it != wire.end(); ++it) { |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 83 | // printf("0x%02x, ", *it); |
| 84 | // } |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 85 | static const uint8_t expected[] = { |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame] | 86 | 0xc0, 0x41, 0xc1, 0x01, 0x01, 0x69, 0x01, 0x14, 0x72, 0x16, |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 87 | 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, |
| 88 | 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x31, 0x3a, 0x35, 0x35, 0x35, |
| 89 | 0x35, 0x35, 0x81, 0x15, 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, |
| 90 | 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32, |
| 91 | 0x3a, 0x36, 0x33, 0x36, 0x33, 0x84, 0x01, 0x01, 0x85, 0x01, |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame] | 92 | 0x01, 0x86, 0x01, 0x01, 0x6c, 0x01, 0x03, |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 93 | }; |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 94 | BOOST_CHECK_EQUAL_COLLECTIONS(expected, expected + sizeof(expected), |
| 95 | wire.begin(), wire.end()); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 96 | |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 97 | FaceEventNotification notification2(wire); |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 98 | BOOST_CHECK_EQUAL(notification1, notification2); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 99 | |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 100 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(notification2), |
| 101 | "FaceEvent(Kind: created,\n" |
| 102 | " FaceId: 20,\n" |
| 103 | " RemoteUri: tcp4://192.0.2.1:55555,\n" |
| 104 | " LocalUri: tcp4://192.0.2.2:6363,\n" |
| 105 | " FaceScope: local,\n" |
| 106 | " FacePersistency: on-demand,\n" |
| 107 | " LinkType: multi-access,\n" |
| 108 | " Flags: 0x3\n" |
| 109 | " )"); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 112 | BOOST_AUTO_TEST_CASE(Destroyed) |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 113 | { |
| 114 | FaceEventNotification notification1; |
| 115 | notification1.setKind(FACE_EVENT_DESTROYED) |
| 116 | .setFaceId(20) |
| 117 | .setRemoteUri("tcp4://192.0.2.1:55555") |
| 118 | .setLocalUri("tcp4://192.0.2.2:6363") |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 119 | .setFaceScope(FACE_SCOPE_LOCAL) |
| 120 | .setFacePersistency(FACE_PERSISTENCY_ON_DEMAND) |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame] | 121 | .setLinkType(LINK_TYPE_MULTI_ACCESS) |
| 122 | .setFlags(0x4); |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 123 | Block wire = notification1.wireEncode(); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 124 | |
| 125 | // These octets are obtained by the snippet below. |
| 126 | // This check is intended to detect unexpected encoding change in the future. |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 127 | // for (auto it = wire.begin(); it != wire.end(); ++it) { |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 128 | // printf("0x%02x, ", *it); |
| 129 | // } |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 130 | static const uint8_t expected[] = { |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame] | 131 | 0xc0, 0x41, 0xc1, 0x01, 0x02, 0x69, 0x01, 0x14, 0x72, 0x16, |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 132 | 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, |
| 133 | 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x31, 0x3a, 0x35, 0x35, 0x35, |
| 134 | 0x35, 0x35, 0x81, 0x15, 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, |
| 135 | 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32, |
| 136 | 0x3a, 0x36, 0x33, 0x36, 0x33, 0x84, 0x01, 0x01, 0x85, 0x01, |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame] | 137 | 0x01, 0x86, 0x01, 0x01, 0x6c, 0x01, 0x04, |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 138 | }; |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 139 | BOOST_CHECK_EQUAL_COLLECTIONS(expected, expected + sizeof(expected), |
| 140 | wire.begin(), wire.end()); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 141 | |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 142 | FaceEventNotification notification2(wire); |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 143 | BOOST_CHECK_EQUAL(notification1, notification2); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 144 | |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 145 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(notification2), |
| 146 | "FaceEvent(Kind: destroyed,\n" |
| 147 | " FaceId: 20,\n" |
| 148 | " RemoteUri: tcp4://192.0.2.1:55555,\n" |
| 149 | " LocalUri: tcp4://192.0.2.2:6363,\n" |
| 150 | " FaceScope: local,\n" |
| 151 | " FacePersistency: on-demand,\n" |
| 152 | " LinkType: multi-access,\n" |
| 153 | " Flags: 0x4\n" |
| 154 | " )"); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 157 | BOOST_AUTO_TEST_CASE(Up) |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 158 | { |
| 159 | FaceEventNotification notification1; |
| 160 | notification1.setKind(FACE_EVENT_UP) |
| 161 | .setFaceId(20) |
| 162 | .setRemoteUri("tcp4://192.0.2.1:55555") |
| 163 | .setLocalUri("tcp4://192.0.2.2:6363") |
| 164 | .setFaceScope(FACE_SCOPE_LOCAL) |
| 165 | .setFacePersistency(FACE_PERSISTENCY_ON_DEMAND) |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame] | 166 | .setLinkType(LINK_TYPE_MULTI_ACCESS) |
| 167 | .setFlags(0x05); |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 168 | Block wire = notification1.wireEncode(); |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 169 | |
| 170 | // These octets are obtained by the snippet below. |
| 171 | // This check is intended to detect unexpected encoding change in the future. |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 172 | // for (auto it = wire.begin(); it != wire.end(); ++it) { |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 173 | // printf("0x%02x, ", *it); |
| 174 | // } |
| 175 | static const uint8_t expected[] = { |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame] | 176 | 0xc0, 0x41, 0xc1, 0x01, 0x03, 0x69, 0x01, 0x14, 0x72, 0x16, |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 177 | 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, |
| 178 | 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x31, 0x3a, 0x35, 0x35, 0x35, |
| 179 | 0x35, 0x35, 0x81, 0x15, 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, |
| 180 | 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32, |
| 181 | 0x3a, 0x36, 0x33, 0x36, 0x33, 0x84, 0x01, 0x01, 0x85, 0x01, |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame] | 182 | 0x01, 0x86, 0x01, 0x01, 0x6c, 0x01, 0x05, |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 183 | }; |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 184 | BOOST_CHECK_EQUAL_COLLECTIONS(expected, expected + sizeof(expected), |
| 185 | wire.begin(), wire.end()); |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 186 | |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 187 | FaceEventNotification notification2(wire); |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 188 | BOOST_CHECK_EQUAL(notification1, notification2); |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 189 | |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 190 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(notification2), |
| 191 | "FaceEvent(Kind: up,\n" |
| 192 | " FaceId: 20,\n" |
| 193 | " RemoteUri: tcp4://192.0.2.1:55555,\n" |
| 194 | " LocalUri: tcp4://192.0.2.2:6363,\n" |
| 195 | " FaceScope: local,\n" |
| 196 | " FacePersistency: on-demand,\n" |
| 197 | " LinkType: multi-access,\n" |
| 198 | " Flags: 0x5\n" |
| 199 | " )"); |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 202 | BOOST_AUTO_TEST_CASE(Down) |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 203 | { |
| 204 | FaceEventNotification notification1; |
| 205 | notification1.setKind(FACE_EVENT_DOWN) |
| 206 | .setFaceId(20) |
| 207 | .setRemoteUri("tcp4://192.0.2.1:55555") |
| 208 | .setLocalUri("tcp4://192.0.2.2:6363") |
| 209 | .setFaceScope(FACE_SCOPE_LOCAL) |
| 210 | .setFacePersistency(FACE_PERSISTENCY_ON_DEMAND) |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame] | 211 | .setLinkType(LINK_TYPE_MULTI_ACCESS) |
| 212 | .setFlags(0x06); |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 213 | Block wire = notification1.wireEncode(); |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 214 | |
| 215 | // These octets are obtained by the snippet below. |
| 216 | // This check is intended to detect unexpected encoding change in the future. |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 217 | // for (auto it = wire.begin(); it != wire.end(); ++it) { |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 218 | // printf("0x%02x, ", *it); |
| 219 | // } |
| 220 | static const uint8_t expected[] = { |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame] | 221 | 0xc0, 0x41, 0xc1, 0x01, 0x04, 0x69, 0x01, 0x14, 0x72, 0x16, |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 222 | 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, |
| 223 | 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x31, 0x3a, 0x35, 0x35, 0x35, |
| 224 | 0x35, 0x35, 0x81, 0x15, 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, |
| 225 | 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32, |
| 226 | 0x3a, 0x36, 0x33, 0x36, 0x33, 0x84, 0x01, 0x01, 0x85, 0x01, |
Eric Newberry | 1aa3e1e | 2016-09-28 20:27:45 -0700 | [diff] [blame] | 227 | 0x01, 0x86, 0x01, 0x01, 0x6c, 0x01, 0x06, |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 228 | }; |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 229 | BOOST_CHECK_EQUAL_COLLECTIONS(expected, expected + sizeof(expected), |
| 230 | wire.begin(), wire.end()); |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 231 | |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 232 | FaceEventNotification notification2(wire); |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 233 | BOOST_CHECK_EQUAL(notification1, notification2); |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 234 | |
Davide Pesavento | 88eb748 | 2017-02-18 19:25:58 -0500 | [diff] [blame] | 235 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(notification2), |
| 236 | "FaceEvent(Kind: down,\n" |
| 237 | " FaceId: 20,\n" |
| 238 | " RemoteUri: tcp4://192.0.2.1:55555,\n" |
| 239 | " LocalUri: tcp4://192.0.2.2:6363,\n" |
| 240 | " FaceScope: local,\n" |
| 241 | " FacePersistency: on-demand,\n" |
| 242 | " LinkType: multi-access,\n" |
| 243 | " Flags: 0x6\n" |
| 244 | " )"); |
| 245 | } |
| 246 | |
| 247 | BOOST_AUTO_TEST_CASE(Equality) |
| 248 | { |
| 249 | FaceEventNotification notification1, notification2; |
| 250 | BOOST_CHECK_EQUAL(notification1, notification2); |
| 251 | |
| 252 | notification1.setKind(FACE_EVENT_CREATED) |
| 253 | .setFaceId(123) |
| 254 | .setRemoteUri("tcp4://192.0.2.1:55555") |
| 255 | .setLocalUri("tcp4://192.0.2.2:6363"); |
| 256 | notification2 = notification1; |
| 257 | BOOST_CHECK_EQUAL(notification1, notification2); |
| 258 | |
| 259 | notification2.setFaceId(42); |
| 260 | BOOST_CHECK_NE(notification1, notification2); |
| 261 | |
| 262 | notification2 = notification1; |
| 263 | notification2.setKind(FACE_EVENT_DESTROYED); |
| 264 | BOOST_CHECK_NE(notification1, notification2); |
Eric Newberry | f767eba | 2016-10-07 13:37:02 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 267 | BOOST_AUTO_TEST_SUITE_END() // TestFaceEventNotification |
| 268 | BOOST_AUTO_TEST_SUITE_END() // Nfd |
| 269 | BOOST_AUTO_TEST_SUITE_END() // Mgmt |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 270 | |
Davide Pesavento | 47ce2ee | 2023-05-09 01:33:33 -0400 | [diff] [blame] | 271 | } // namespace ndn::tests |