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