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