Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | eaf105c | 2014-01-30 17:40:24 -0800 | [diff] [blame] | 2 | /** |
| 3 | * Copyright (C) 2013 Regents of the University of California. |
Alexander Afanasyev | eaf105c | 2014-01-30 17:40:24 -0800 | [diff] [blame] | 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 7 | #include "management/nfd-control-response.hpp" |
| 8 | #include "management/nfd-fib-management-options.hpp" |
Yingdi Yu | d337049 | 2014-02-12 17:17:11 -0800 | [diff] [blame] | 9 | #include "management/nfd-face-management-options.hpp" |
Alexander Afanasyev | 44b438a | 2014-03-19 12:51:49 -0700 | [diff] [blame] | 10 | #include "management/nfd-face-event-notification.hpp" |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 11 | #include "management/nfd-face-status.hpp" |
Alexander Afanasyev | 1c5a1a9 | 2014-03-21 13:32:36 -0700 | [diff] [blame] | 12 | #include "management/nfd-status.hpp" |
| 13 | #include "data.hpp" |
Alexander Afanasyev | eaf105c | 2014-01-30 17:40:24 -0800 | [diff] [blame] | 14 | |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 15 | #include <boost/test/unit_test.hpp> |
Alexander Afanasyev | eaf105c | 2014-01-30 17:40:24 -0800 | [diff] [blame] | 16 | #include <boost/test/output_test_stream.hpp> |
| 17 | |
| 18 | using namespace std; |
| 19 | |
| 20 | namespace ndn { |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 21 | namespace nfd { |
Alexander Afanasyev | eaf105c | 2014-01-30 17:40:24 -0800 | [diff] [blame] | 22 | |
| 23 | BOOST_AUTO_TEST_SUITE(TestNfdControl) |
| 24 | |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 25 | const uint8_t TestControlResponse[] = {0x65, 0x17, |
| 26 | 0x66, 0x02, 0x01, 0x94, 0x67, 0x11, 0x4e, 0x6f, 0x74, |
| 27 | 0x68, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x6f, 0x74, 0x20, |
| 28 | 0x66, 0x6f, 0x75, 0x6e, 0x64}; |
Alexander Afanasyev | eaf105c | 2014-01-30 17:40:24 -0800 | [diff] [blame] | 29 | |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 30 | const uint8_t TestFibManagementOptions[] = { |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 31 | 0x68, 0x49, 0x07, 0x16, 0x08, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 32 | 0x6f, 0x73, 0x74, 0x08, 0x03, 0x72, 0x65, 0x67, 0x08, 0x04, 0x74, 0x65, |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 33 | 0x73, 0x74, 0x69, 0x01, 0x00, 0x6a, 0x01, 0x01, 0x6b, 0x29, 0x07, 0x27, |
| 34 | 0x08, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x08, |
| 35 | 0x03, 0x6e, 0x66, 0x64, 0x08, 0x08, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, |
| 36 | 0x67, 0x79, 0x08, 0x0b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2d, 0x77, 0x6f, |
| 37 | 0x72, 0x6c, 0x64 |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 38 | }; |
| 39 | |
Yingdi Yu | d337049 | 2014-02-12 17:17:11 -0800 | [diff] [blame] | 40 | const uint8_t TestFaceManagementOptions[] = { |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame^] | 41 | 0x68, 0x1e, 0x69, 0x01, 0x0a, 0x72, 0x19, 0x74, 0x63, 0x70, 0x3a, 0x2f, |
Yingdi Yu | d337049 | 2014-02-12 17:17:11 -0800 | [diff] [blame] | 42 | 0x2f, 0x31, 0x2e, 0x31, 0x2e, 0x31, 0x2e, 0x31, 0x2f, 0x68, 0x65, 0x6c, |
| 43 | 0x6c, 0x6f, 0x2f, 0x77, 0x6f, 0x72, 0x6c, 0x64 |
| 44 | }; |
| 45 | |
Alexander Afanasyev | 44b438a | 2014-03-19 12:51:49 -0700 | [diff] [blame] | 46 | const uint8_t TestFaceEventNotification[] = { |
Alexander Afanasyev | 2c75331 | 2014-03-20 17:31:01 -0700 | [diff] [blame] | 47 | 0xc0, 0x20, 0xc1, 0x01, 0x01, 0x69, 0x01, 0x64, 0x72, 0x15, 0x74, 0x63, |
Alexander Afanasyev | 44b438a | 2014-03-19 12:51:49 -0700 | [diff] [blame] | 48 | 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, |
Alexander Afanasyev | 2c75331 | 2014-03-20 17:31:01 -0700 | [diff] [blame] | 49 | 0x2e, 0x31, 0x3a, 0x36, 0x33, 0x36, 0x33, 0xc2, 0x01, 0x03 |
Alexander Afanasyev | 44b438a | 2014-03-19 12:51:49 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 52 | const uint8_t TestFaceStatus[] = { |
| 53 | 0x80, 0x27, 0x69, 0x01, 0x64, 0x72, 0x15, 0x74, 0x63, 0x70, 0x34, 0x3a, |
| 54 | 0x2f, 0x2f, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x3a, |
| 55 | 0x36, 0x33, 0x36, 0x33, 0x91, 0x01, 0x0a, 0x90, 0x01, 0x14, 0x92, 0x01, |
| 56 | 0x1e, 0x93, 0x02, 0x01, 0x90 |
| 57 | }; |
| 58 | |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 59 | // ControlResponse |
| 60 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 61 | BOOST_AUTO_TEST_CASE(ControlResponseEncode) |
Alexander Afanasyev | eaf105c | 2014-01-30 17:40:24 -0800 | [diff] [blame] | 62 | { |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 63 | ControlResponse controlResponse(404, "Nothing not found"); |
Alexander Afanasyev | eaf105c | 2014-01-30 17:40:24 -0800 | [diff] [blame] | 64 | const Block &wire = controlResponse.wireEncode(); |
| 65 | |
| 66 | BOOST_REQUIRE_EQUAL_COLLECTIONS(TestControlResponse, TestControlResponse+sizeof(TestControlResponse), |
| 67 | wire.begin(), wire.end()); |
| 68 | } |
| 69 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 70 | BOOST_AUTO_TEST_CASE(ControlResponseDecode) |
Alexander Afanasyev | eaf105c | 2014-01-30 17:40:24 -0800 | [diff] [blame] | 71 | { |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 72 | ControlResponse controlResponse; |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 73 | |
Alexander Afanasyev | eaf105c | 2014-01-30 17:40:24 -0800 | [diff] [blame] | 74 | BOOST_REQUIRE_NO_THROW(controlResponse.wireDecode(Block(TestControlResponse, sizeof(TestControlResponse)))); |
| 75 | |
| 76 | BOOST_REQUIRE_EQUAL(controlResponse.getCode(), 404); |
| 77 | BOOST_REQUIRE_EQUAL(controlResponse.getText(), "Nothing not found"); |
| 78 | } |
| 79 | |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 80 | // FibManagementOptions |
| 81 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 82 | BOOST_AUTO_TEST_CASE(FibManagementOptionsEncoding) |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 83 | { |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 84 | Name n("/localhost/reg/test"); |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 85 | FibManagementOptions opt; |
| 86 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 87 | opt.setName(n); |
| 88 | opt.setFaceId(0); |
| 89 | opt.setCost(1); |
| 90 | opt.setStrategy("/localhost/nfd/strategy/hello-world"); |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 91 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 92 | const Block& blk = opt.wireEncode(); |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 93 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 94 | BOOST_REQUIRE_EQUAL_COLLECTIONS(TestFibManagementOptions, |
| 95 | TestFibManagementOptions + sizeof(TestFibManagementOptions), |
| 96 | blk.begin(), blk.end()); |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 97 | } |
| 98 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 99 | BOOST_AUTO_TEST_CASE(FibManagementOptionsFastEncoding) |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 100 | { |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 101 | Name n("/localhost/reg/test"); |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 102 | FibManagementOptions opt; |
| 103 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 104 | opt.setName(n); |
| 105 | opt.setFaceId(0); |
| 106 | opt.setCost(1); |
| 107 | opt.setStrategy("/localhost/nfd/strategy/hello-world"); |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 108 | |
| 109 | EncodingBuffer blk; |
| 110 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 111 | BOOST_REQUIRE_NO_THROW(opt.wireEncode(blk)); |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 112 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 113 | BOOST_REQUIRE_EQUAL_COLLECTIONS(TestFibManagementOptions, |
| 114 | TestFibManagementOptions + sizeof(TestFibManagementOptions), |
| 115 | blk.begin(), blk.end()); |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 116 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 117 | EncodingBuffer blk2(4); |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 118 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 119 | BOOST_REQUIRE_NO_THROW(opt.wireEncode(blk2)); |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 120 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 121 | BOOST_REQUIRE_EQUAL_COLLECTIONS(TestFibManagementOptions, |
| 122 | TestFibManagementOptions + sizeof(TestFibManagementOptions), |
| 123 | blk2.begin(), blk2.end()); |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 124 | } |
| 125 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 126 | BOOST_AUTO_TEST_CASE(FibManagementOptionsDecoding) |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 127 | { |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 128 | Block blk(TestFibManagementOptions, sizeof(TestFibManagementOptions)); |
| 129 | Name n("/localhost/reg/test"); |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 130 | FibManagementOptions opt; |
| 131 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 132 | BOOST_REQUIRE_NO_THROW(opt.wireDecode(blk)); |
| 133 | |
| 134 | BOOST_CHECK_EQUAL(opt.getName(), n); |
| 135 | BOOST_CHECK_EQUAL(opt.getFaceId(), 0); |
| 136 | BOOST_CHECK_EQUAL(opt.getCost(), 1); |
| 137 | BOOST_CHECK_EQUAL(opt.getStrategy().toUri(), "/localhost/nfd/strategy/hello-world"); |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 138 | } |
| 139 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 140 | BOOST_AUTO_TEST_CASE(FaceManagementOptionsFastEncoding) |
Yingdi Yu | d337049 | 2014-02-12 17:17:11 -0800 | [diff] [blame] | 141 | { |
| 142 | FaceManagementOptions opt; |
| 143 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 144 | opt.setFaceId(10); |
| 145 | opt.setUri("tcp://1.1.1.1/hello/world"); |
Yingdi Yu | d337049 | 2014-02-12 17:17:11 -0800 | [diff] [blame] | 146 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 147 | BOOST_REQUIRE_NO_THROW(opt.wireEncode ()); |
Yingdi Yu | d337049 | 2014-02-12 17:17:11 -0800 | [diff] [blame] | 148 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 149 | BOOST_REQUIRE_EQUAL_COLLECTIONS(TestFaceManagementOptions, |
| 150 | TestFaceManagementOptions + sizeof(TestFaceManagementOptions), |
| 151 | opt.wireEncode().begin(), opt.wireEncode().end()); |
Yingdi Yu | d337049 | 2014-02-12 17:17:11 -0800 | [diff] [blame] | 152 | } |
| 153 | |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 154 | BOOST_AUTO_TEST_CASE(FaceManagementOptionsDecoding) |
Yingdi Yu | d337049 | 2014-02-12 17:17:11 -0800 | [diff] [blame] | 155 | { |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 156 | Block blk(TestFaceManagementOptions, sizeof(TestFaceManagementOptions)); |
Yingdi Yu | d337049 | 2014-02-12 17:17:11 -0800 | [diff] [blame] | 157 | FaceManagementOptions opt; |
| 158 | |
Alexander Afanasyev | 44b438a | 2014-03-19 12:51:49 -0700 | [diff] [blame] | 159 | BOOST_REQUIRE_NO_THROW(opt.wireDecode(blk)); |
Alexander Afanasyev | c5ad119 | 2014-02-25 14:17:47 -0800 | [diff] [blame] | 160 | |
| 161 | BOOST_CHECK_EQUAL(opt.getFaceId(), 10); |
| 162 | BOOST_CHECK_EQUAL(opt.getUri(), "tcp://1.1.1.1/hello/world"); |
Yingdi Yu | d337049 | 2014-02-12 17:17:11 -0800 | [diff] [blame] | 163 | } |
Wentao Shang | 4d5e1de | 2014-01-28 21:00:03 -0800 | [diff] [blame] | 164 | |
Alexander Afanasyev | 44b438a | 2014-03-19 12:51:49 -0700 | [diff] [blame] | 165 | |
| 166 | BOOST_AUTO_TEST_CASE(FaceEventNotificationEncodingDecoding) |
| 167 | { |
| 168 | FaceEventKind expectedKind = FACE_EVENT_CREATED; |
| 169 | std::string expectedUri("tcp4://127.0.0.1:6363"); |
| 170 | uint64_t expectedFaceId = 100; |
Alexander Afanasyev | 2c75331 | 2014-03-20 17:31:01 -0700 | [diff] [blame] | 171 | uint64_t expectedFlags = 3; |
Alexander Afanasyev | 44b438a | 2014-03-19 12:51:49 -0700 | [diff] [blame] | 172 | |
| 173 | { |
Alexander Afanasyev | 2c75331 | 2014-03-20 17:31:01 -0700 | [diff] [blame] | 174 | FaceEventNotification faceEvent(expectedKind, expectedFaceId, expectedUri, expectedFlags); |
Alexander Afanasyev | 44b438a | 2014-03-19 12:51:49 -0700 | [diff] [blame] | 175 | BOOST_REQUIRE_NO_THROW(faceEvent.wireEncode()); |
| 176 | |
| 177 | BOOST_REQUIRE_EQUAL_COLLECTIONS(TestFaceEventNotification, |
| 178 | TestFaceEventNotification + sizeof(TestFaceEventNotification), |
| 179 | faceEvent.wireEncode().begin(), faceEvent.wireEncode().end()); |
| 180 | |
| 181 | std::ostringstream os; |
| 182 | os << faceEvent; |
Alexander Afanasyev | 2c75331 | 2014-03-20 17:31:01 -0700 | [diff] [blame] | 183 | BOOST_CHECK_EQUAL(os.str(), "FaceEventNotification(Kind: created, FaceID: 100, Uri: tcp4://127.0.0.1:6363, Flags: 3)"); |
Alexander Afanasyev | 44b438a | 2014-03-19 12:51:49 -0700 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | { |
| 187 | Block blk(TestFaceEventNotification, sizeof(TestFaceEventNotification)); |
| 188 | FaceEventNotification faceEvent(blk); |
| 189 | |
| 190 | BOOST_CHECK_EQUAL(faceEvent.getEventKind(), expectedKind); |
| 191 | BOOST_CHECK_EQUAL(faceEvent.getFaceId(), expectedFaceId); |
| 192 | BOOST_CHECK_EQUAL(faceEvent.getUri(), expectedUri); |
Alexander Afanasyev | 2c75331 | 2014-03-20 17:31:01 -0700 | [diff] [blame] | 193 | BOOST_CHECK_EQUAL(faceEvent.getFlags(), expectedFlags); |
| 194 | BOOST_CHECK(faceEvent.isLocal()); |
| 195 | BOOST_CHECK(faceEvent.isOnDemand()); |
Alexander Afanasyev | 44b438a | 2014-03-19 12:51:49 -0700 | [diff] [blame] | 196 | } |
| 197 | } |
| 198 | |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 199 | BOOST_AUTO_TEST_CASE(FaceStatusEncodingDecoding) |
| 200 | { |
| 201 | { |
| 202 | FaceStatus faceStatus(100, "tcp4://127.0.0.1:6363", 10, 20, 30, 400); |
| 203 | BOOST_REQUIRE_NO_THROW(faceStatus.wireEncode()); |
| 204 | |
| 205 | BOOST_CHECK_EQUAL_COLLECTIONS(TestFaceStatus, |
| 206 | TestFaceStatus + sizeof(TestFaceStatus), |
| 207 | faceStatus.wireEncode().begin(), faceStatus.wireEncode().end()); |
| 208 | |
| 209 | std::ostringstream os; |
| 210 | os << faceStatus; |
| 211 | BOOST_CHECK_EQUAL(os.str(), "FaceStatus(FaceID: 100, Uri: tcp4://127.0.0.1:6363, " |
| 212 | "Counters: 10|20|30|400)"); |
| 213 | } |
| 214 | |
| 215 | { |
| 216 | Block block(TestFaceStatus, sizeof(TestFaceStatus)); |
| 217 | BOOST_REQUIRE_NO_THROW((FaceStatus(block))); |
| 218 | |
| 219 | FaceStatus faceStatus(block); |
| 220 | |
| 221 | BOOST_CHECK_EQUAL(faceStatus.getFaceId(), 100); |
| 222 | BOOST_CHECK_EQUAL(faceStatus.getUri(), "tcp4://127.0.0.1:6363"); |
| 223 | |
| 224 | BOOST_CHECK_EQUAL(faceStatus.getInInterest(), 10); |
| 225 | BOOST_CHECK_EQUAL(faceStatus.getInData(), 20); |
| 226 | BOOST_CHECK_EQUAL(faceStatus.getOutInterest(), 30); |
| 227 | BOOST_CHECK_EQUAL(faceStatus.getOutData(), 400); |
| 228 | } |
| 229 | } |
| 230 | |
Alexander Afanasyev | 1c5a1a9 | 2014-03-21 13:32:36 -0700 | [diff] [blame] | 231 | BOOST_AUTO_TEST_CASE(NfdStatusEncode) |
| 232 | { |
| 233 | Status status1; |
| 234 | status1.setNfdVersion(1014210635); |
| 235 | status1.setStartTimestamp(time::fromUnixTimestamp(time::seconds(375193249))); |
| 236 | status1.setCurrentTimestamp(time::fromUnixTimestamp(time::seconds(1886109034))); |
| 237 | status1.setNNameTreeEntries(1849943160); |
| 238 | status1.setNFibEntries(621739748); |
| 239 | status1.setNPitEntries(482129741); |
| 240 | status1.setNMeasurementsEntries(1771725298); |
| 241 | status1.setNCsEntries(1264968688); |
| 242 | status1.setNInInterests(612811615); |
| 243 | status1.setNOutInterests(952144445); |
| 244 | status1.setNInDatas(1843576050); |
| 245 | status1.setNOutDatas(138198826); |
| 246 | |
| 247 | EncodingBuffer buffer; |
| 248 | status1.wireEncode(buffer); |
| 249 | |
| 250 | Data data; |
| 251 | data.setContent(buffer.buf(), buffer.size()); |
| 252 | |
| 253 | Status status2(data.getContent()); |
| 254 | BOOST_CHECK_EQUAL(status1.getNfdVersion(), status2.getNfdVersion()); |
| 255 | BOOST_CHECK_EQUAL(status1.getStartTimestamp(), status2.getStartTimestamp()); |
| 256 | BOOST_CHECK_EQUAL(status1.getCurrentTimestamp(), status2.getCurrentTimestamp()); |
| 257 | BOOST_CHECK_EQUAL(status1.getNNameTreeEntries(), status2.getNNameTreeEntries()); |
| 258 | BOOST_CHECK_EQUAL(status1.getNFibEntries(), status2.getNFibEntries()); |
| 259 | BOOST_CHECK_EQUAL(status1.getNPitEntries(), status2.getNPitEntries()); |
| 260 | BOOST_CHECK_EQUAL(status1.getNMeasurementsEntries(), status2.getNMeasurementsEntries()); |
| 261 | BOOST_CHECK_EQUAL(status1.getNCsEntries(), status2.getNCsEntries()); |
| 262 | BOOST_CHECK_EQUAL(status1.getNInInterests(), status2.getNInInterests()); |
| 263 | BOOST_CHECK_EQUAL(status1.getNOutInterests(), status2.getNOutInterests()); |
| 264 | BOOST_CHECK_EQUAL(status1.getNInDatas(), status2.getNInDatas()); |
| 265 | BOOST_CHECK_EQUAL(status1.getNOutDatas(), status2.getNOutDatas()); |
| 266 | } |
| 267 | |
Alexander Afanasyev | eaf105c | 2014-01-30 17:40:24 -0800 | [diff] [blame] | 268 | BOOST_AUTO_TEST_SUITE_END() |
| 269 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 270 | } // namespace nfd |
Alexander Afanasyev | eaf105c | 2014-01-30 17:40:24 -0800 | [diff] [blame] | 271 | } // namespace ndn |