blob: 6d69eda10a55bb0ea9669c1352acf50aee12a8b3 [file] [log] [blame]
Junxiao Shi0fcb41e2014-01-24 10:29:43 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shifc206962015-01-16 11:12:22 -07003 * Copyright (c) 2014-2015, Regents of the University of California,
4 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080010 *
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070011 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Junxiao Shia9388182014-12-13 23:16:09 -070024 */
Junxiao Shi0fcb41e2014-01-24 10:29:43 -070025
26#include "table/cs.hpp"
Junxiao Shia9388182014-12-13 23:16:09 -070027#include <ndn-cxx/util/crypto.hpp>
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -080028
Junxiao Shid9ee45c2014-02-27 15:38:11 -070029#include "tests/test-common.hpp"
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -080030
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080031namespace nfd {
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -080032namespace cs {
Junxiao Shid9ee45c2014-02-27 15:38:11 -070033namespace tests {
Junxiao Shi0fcb41e2014-01-24 10:29:43 -070034
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -080035using namespace nfd::tests;
36
Junxiao Shid9ee45c2014-02-27 15:38:11 -070037BOOST_FIXTURE_TEST_SUITE(TableCs, BaseFixture)
Junxiao Shi0fcb41e2014-01-24 10:29:43 -070038
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080039class FindFixture : protected BaseFixture
40{
41protected:
Junxiao Shia9388182014-12-13 23:16:09 -070042 Name
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080043 insert(uint32_t id, const Name& name)
44 {
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -040045 shared_ptr<Data> data = makeData(name);
Alexander Afanasyeveb3197f2014-03-17 19:28:18 -070046 data->setFreshnessPeriod(time::milliseconds(99999));
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080047 data->setContent(reinterpret_cast<const uint8_t*>(&id), sizeof(id));
Junxiao Shia9388182014-12-13 23:16:09 -070048 data->wireEncode();
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070049
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080050 m_cs.insert(*data);
Junxiao Shia9388182014-12-13 23:16:09 -070051
52 return data->getFullName();
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080053 }
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070054
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080055 Interest&
56 startInterest(const Name& name)
57 {
58 m_interest = make_shared<Interest>(name);
59 return *m_interest;
60 }
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070061
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080062 uint32_t
63 find()
64 {
Junxiao Shia9388182014-12-13 23:16:09 -070065 // m_cs.dump();
66
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080067 const Data* found = m_cs.find(*m_interest);
Junxiao Shia9388182014-12-13 23:16:09 -070068 if (found == nullptr) {
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080069 return 0;
70 }
71 const Block& content = found->getContent();
72 if (content.value_size() != sizeof(uint32_t)) {
73 return 0;
74 }
75 return *reinterpret_cast<const uint32_t*>(content.value());
76 }
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070077
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080078protected:
79 Cs m_cs;
80 shared_ptr<Interest> m_interest;
81};
82
83BOOST_FIXTURE_TEST_SUITE(Find, FindFixture)
84
85BOOST_AUTO_TEST_CASE(EmptyDataName)
86{
87 insert(1, "ndn:/");
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070088
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080089 startInterest("ndn:/");
90 BOOST_CHECK_EQUAL(find(), 1);
91}
92
93BOOST_AUTO_TEST_CASE(EmptyInterestName)
94{
95 insert(1, "ndn:/A");
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070096
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080097 startInterest("ndn:/");
98 BOOST_CHECK_EQUAL(find(), 1);
99}
100
Junxiao Shia9388182014-12-13 23:16:09 -0700101BOOST_AUTO_TEST_CASE(ExactName)
102{
103 insert(1, "ndn:/");
104 insert(2, "ndn:/A");
105 insert(3, "ndn:/A/B");
106 insert(4, "ndn:/A/C");
107 insert(5, "ndn:/D");
108
109 startInterest("ndn:/A");
110 BOOST_CHECK_EQUAL(find(), 2);
111}
112
113BOOST_AUTO_TEST_CASE(FullName)
114{
115 Name n1 = insert(1, "ndn:/A");
116 Name n2 = insert(2, "ndn:/A");
117
118 startInterest(n1);
119 BOOST_CHECK_EQUAL(find(), 1);
120
121 startInterest(n2);
122 BOOST_CHECK_EQUAL(find(), 2);
123}
124
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800125BOOST_AUTO_TEST_CASE(Leftmost)
126{
127 insert(1, "ndn:/A");
128 insert(2, "ndn:/B/p/1");
129 insert(3, "ndn:/B/p/2");
130 insert(4, "ndn:/B/q/1");
131 insert(5, "ndn:/B/q/2");
132 insert(6, "ndn:/C");
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700133
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800134 startInterest("ndn:/B");
135 BOOST_CHECK_EQUAL(find(), 2);
136}
137
138BOOST_AUTO_TEST_CASE(Rightmost)
139{
140 insert(1, "ndn:/A");
141 insert(2, "ndn:/B/p/1");
142 insert(3, "ndn:/B/p/2");
143 insert(4, "ndn:/B/q/1");
144 insert(5, "ndn:/B/q/2");
145 insert(6, "ndn:/C");
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700146
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800147 startInterest("ndn:/B")
148 .setChildSelector(1);
149 BOOST_CHECK_EQUAL(find(), 4);
150}
151
Junxiao Shia9388182014-12-13 23:16:09 -0700152BOOST_AUTO_TEST_CASE(MinSuffixComponents)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800153{
154 insert(1, "ndn:/");
155 insert(2, "ndn:/A");
Junxiao Shia9388182014-12-13 23:16:09 -0700156 insert(3, "ndn:/B/1");
157 insert(4, "ndn:/C/1/2");
158 insert(5, "ndn:/D/1/2/3");
159 insert(6, "ndn:/E/1/2/3/4");
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700160
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800161 startInterest("ndn:/")
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800162 .setMinSuffixComponents(0);
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800163 BOOST_CHECK_EQUAL(find(), 1);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700164
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800165 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700166 .setMinSuffixComponents(1);
167 BOOST_CHECK_EQUAL(find(), 1);
168
169 startInterest("ndn:/")
170 .setMinSuffixComponents(2);
171 BOOST_CHECK_EQUAL(find(), 2);
172
173 startInterest("ndn:/")
174 .setMinSuffixComponents(3);
175 BOOST_CHECK_EQUAL(find(), 3);
176
177 startInterest("ndn:/")
178 .setMinSuffixComponents(4);
179 BOOST_CHECK_EQUAL(find(), 4);
180
181 startInterest("ndn:/")
182 .setMinSuffixComponents(5);
183 BOOST_CHECK_EQUAL(find(), 5);
184
185 startInterest("ndn:/")
186 .setMinSuffixComponents(6);
187 BOOST_CHECK_EQUAL(find(), 6);
188
189 startInterest("ndn:/")
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800190 .setMinSuffixComponents(7);
191 BOOST_CHECK_EQUAL(find(), 0);
192}
193
194BOOST_AUTO_TEST_CASE(MaxSuffixComponents)
195{
196 insert(1, "ndn:/");
197 insert(2, "ndn:/A");
Junxiao Shia9388182014-12-13 23:16:09 -0700198 insert(3, "ndn:/B/2");
199 insert(4, "ndn:/C/2/3");
200 insert(5, "ndn:/D/2/3/4");
201 insert(6, "ndn:/E/2/3/4/5");
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700202
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800203 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700204 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800205 .setMaxSuffixComponents(0);
206 BOOST_CHECK_EQUAL(find(), 0);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700207
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800208 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700209 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800210 .setMaxSuffixComponents(1);
211 BOOST_CHECK_EQUAL(find(), 1);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700212
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800213 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700214 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800215 .setMaxSuffixComponents(2);
216 BOOST_CHECK_EQUAL(find(), 2);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700217
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800218 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700219 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800220 .setMaxSuffixComponents(3);
221 BOOST_CHECK_EQUAL(find(), 3);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700222
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800223 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700224 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800225 .setMaxSuffixComponents(4);
226 BOOST_CHECK_EQUAL(find(), 4);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700227
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800228 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700229 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800230 .setMaxSuffixComponents(5);
231 BOOST_CHECK_EQUAL(find(), 5);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700232
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800233 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700234 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800235 .setMaxSuffixComponents(6);
236 BOOST_CHECK_EQUAL(find(), 6);
Junxiao Shia9388182014-12-13 23:16:09 -0700237
238 startInterest("ndn:/")
239 .setChildSelector(1)
240 .setMaxSuffixComponents(7);
241 BOOST_CHECK_EQUAL(find(), 6);
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800242}
243
244BOOST_AUTO_TEST_CASE(DigestOrder)
245{
246 insert(1, "ndn:/A");
247 insert(2, "ndn:/A");
248 // We don't know which comes first, but there must be some order
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700249
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800250 startInterest("ndn:/A")
251 .setChildSelector(0);
252 uint32_t leftmost = find();
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700253
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800254 startInterest("ndn:/A")
255 .setChildSelector(1);
256 uint32_t rightmost = find();
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700257
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800258 BOOST_CHECK_NE(leftmost, rightmost);
259}
260
261BOOST_AUTO_TEST_CASE(DigestExclude)
262{
Junxiao Shia9388182014-12-13 23:16:09 -0700263 insert(1, "ndn:/A");
264 Name n2 = insert(2, "ndn:/A");
265 insert(3, "ndn:/A/B");
266
267 uint8_t digest00[ndn::crypto::SHA256_DIGEST_SIZE];
268 std::fill_n(digest00, sizeof(digest00), 0x00);
269 uint8_t digestFF[ndn::crypto::SHA256_DIGEST_SIZE];
270 std::fill_n(digestFF, sizeof(digestFF), 0xFF);
271
272 Exclude excludeDigest;
273 excludeDigest.excludeRange(
274 name::Component::fromImplicitSha256Digest(digest00, sizeof(digest00)),
275 name::Component::fromImplicitSha256Digest(digestFF, sizeof(digestFF)));
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700276
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800277 startInterest("ndn:/A")
Junxiao Shia9388182014-12-13 23:16:09 -0700278 .setChildSelector(0)
279 .setExclude(excludeDigest);
280 BOOST_CHECK_EQUAL(find(), 3);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700281
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800282 startInterest("ndn:/A")
283 .setChildSelector(1)
Junxiao Shia9388182014-12-13 23:16:09 -0700284 .setExclude(excludeDigest);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400285 BOOST_CHECK_EQUAL(find(), 3);
286
Junxiao Shia9388182014-12-13 23:16:09 -0700287 Exclude excludeGeneric;
288 excludeGeneric.excludeAfter(name::Component(static_cast<uint8_t*>(nullptr), 0));
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400289
Junxiao Shia9388182014-12-13 23:16:09 -0700290 startInterest("ndn:/A")
291 .setChildSelector(0)
292 .setExclude(excludeGeneric);
293 int found1 = find();
294 BOOST_CHECK(found1 == 1 || found1 == 2);
295
296 startInterest("ndn:/A")
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400297 .setChildSelector(1)
Junxiao Shia9388182014-12-13 23:16:09 -0700298 .setExclude(excludeGeneric);
299 int found2 = find();
300 BOOST_CHECK(found2 == 1 || found2 == 2);
301
302 Exclude exclude2 = excludeGeneric;
303 exclude2.excludeOne(n2.get(-1));
304
305 startInterest("ndn:/A")
306 .setChildSelector(0)
307 .setExclude(exclude2);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400308 BOOST_CHECK_EQUAL(find(), 1);
309
Junxiao Shia9388182014-12-13 23:16:09 -0700310 startInterest("ndn:/A")
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400311 .setChildSelector(1)
Junxiao Shia9388182014-12-13 23:16:09 -0700312 .setExclude(exclude2);
313 BOOST_CHECK_EQUAL(find(), 1);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400314}
315
Junxiao Shia9388182014-12-13 23:16:09 -0700316BOOST_AUTO_TEST_SUITE_END()
317
318BOOST_FIXTURE_TEST_CASE(Evict, UnitTestTimeFixture)
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400319{
Junxiao Shia9388182014-12-13 23:16:09 -0700320 Cs cs(3);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400321
Junxiao Shia9388182014-12-13 23:16:09 -0700322 shared_ptr<Data> dataA = makeData("ndn:/A");
323 dataA->setFreshnessPeriod(time::milliseconds(99999));
324 dataA->wireEncode();
325 cs.insert(*dataA);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400326
Junxiao Shia9388182014-12-13 23:16:09 -0700327 shared_ptr<Data> dataB = makeData("ndn:/B");
328 dataB->setFreshnessPeriod(time::milliseconds(10));
329 dataB->wireEncode();
330 cs.insert(*dataB);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400331
Junxiao Shia9388182014-12-13 23:16:09 -0700332 shared_ptr<Data> dataC = makeData("ndn:/C");
333 dataC->setFreshnessPeriod(time::milliseconds(99999));
334 dataC->wireEncode();
335 cs.insert(*dataC, true);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400336
Junxiao Shia9388182014-12-13 23:16:09 -0700337 this->advanceClocks(time::milliseconds(11));
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400338
Junxiao Shia9388182014-12-13 23:16:09 -0700339 // evict unsolicited
340 shared_ptr<Data> dataD = makeData("ndn:/D");
341 dataD->setFreshnessPeriod(time::milliseconds(99999));
342 dataD->wireEncode();
343 cs.insert(*dataD);
344 BOOST_CHECK_EQUAL(cs.size(), 3);
345 BOOST_CHECK(cs.find(Interest("ndn:/C")) == nullptr);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400346
Junxiao Shia9388182014-12-13 23:16:09 -0700347 // evict stale
348 shared_ptr<Data> dataE = makeData("ndn:/E");
349 dataE->setFreshnessPeriod(time::milliseconds(99999));
350 dataE->wireEncode();
351 cs.insert(*dataE);
352 BOOST_CHECK_EQUAL(cs.size(), 3);
353 BOOST_CHECK(cs.find(Interest("ndn:/B")) == nullptr);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400354
Junxiao Shia9388182014-12-13 23:16:09 -0700355 // evict fifo
356 shared_ptr<Data> dataF = makeData("ndn:/F");
357 dataF->setFreshnessPeriod(time::milliseconds(99999));
358 dataF->wireEncode();
359 cs.insert(*dataF);
360 BOOST_CHECK_EQUAL(cs.size(), 3);
361 BOOST_CHECK(cs.find(Interest("ndn:/A")) == nullptr);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400362}
363
Junxiao Shia9388182014-12-13 23:16:09 -0700364BOOST_FIXTURE_TEST_CASE(Refresh, UnitTestTimeFixture)
365{
366 Cs cs(3);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400367
Junxiao Shia9388182014-12-13 23:16:09 -0700368 shared_ptr<Data> dataA = makeData("ndn:/A");
369 dataA->setFreshnessPeriod(time::milliseconds(99999));
370 dataA->wireEncode();
371 cs.insert(*dataA);
372
373 shared_ptr<Data> dataB = makeData("ndn:/B");
374 dataB->setFreshnessPeriod(time::milliseconds(10));
375 dataB->wireEncode();
376 cs.insert(*dataB);
377
378 shared_ptr<Data> dataC = makeData("ndn:/C");
379 dataC->setFreshnessPeriod(time::milliseconds(10));
380 dataC->wireEncode();
381 cs.insert(*dataC);
382
383 this->advanceClocks(time::milliseconds(11));
384
385 // refresh dataB
386 shared_ptr<Data> dataB2 = make_shared<Data>(*dataB);
387 dataB2->wireEncode();
388 cs.insert(*dataB2);
389 BOOST_CHECK_EQUAL(cs.size(), 3);
390 BOOST_CHECK(cs.find(Interest("ndn:/A")) != nullptr);
391 BOOST_CHECK(cs.find(Interest("ndn:/B")) != nullptr);
392 BOOST_CHECK(cs.find(Interest("ndn:/C")) != nullptr);
393
394 // evict dataC stale
395 shared_ptr<Data> dataD = makeData("ndn:/D");
396 dataD->setFreshnessPeriod(time::milliseconds(99999));
397 dataD->wireEncode();
398 cs.insert(*dataD);
399 BOOST_CHECK_EQUAL(cs.size(), 3);
400 BOOST_CHECK(cs.find(Interest("ndn:/C")) == nullptr);
401}
402
Junxiao Shifc206962015-01-16 11:12:22 -0700403BOOST_AUTO_TEST_CASE(Enumeration)
404{
405 Cs cs;
406
407 Name nameA("/A");
408 Name nameAB("/A/B");
409 Name nameABC("/A/B/C");
410 Name nameD("/D");
411
412 BOOST_CHECK_EQUAL(cs.size(), 0);
413 BOOST_CHECK(cs.begin() == cs.end());
414
415 cs.insert(*makeData(nameABC));
416 BOOST_CHECK_EQUAL(cs.size(), 1);
417 BOOST_CHECK(cs.begin() != cs.end());
418 BOOST_CHECK(cs.begin()->getName() == nameABC);
419 BOOST_CHECK((*cs.begin()).getName() == nameABC);
420
421 auto i = cs.begin();
422 auto j = cs.begin();
423 BOOST_CHECK(++i == cs.end());
424 BOOST_CHECK(j++ == cs.begin());
425 BOOST_CHECK(j == cs.end());
426
427 cs.insert(*makeData(nameA));
428 cs.insert(*makeData(nameAB));
429 cs.insert(*makeData(nameD));
430
431 std::set<Name> expected = {nameA, nameAB, nameABC, nameD};
432 std::set<Name> actual;
433 for (const auto& csEntry : cs) {
434 actual.insert(csEntry.getName());
435 }
436 BOOST_CHECK_EQUAL_COLLECTIONS(actual.begin(), actual.end(), expected.begin(), expected.end());
437}
438
Junxiao Shia9388182014-12-13 23:16:09 -0700439BOOST_AUTO_TEST_SUITE_END()
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -0800440
Junxiao Shid9ee45c2014-02-27 15:38:11 -0700441} // namespace tests
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -0800442} // namespace cs
Alexander Afanasyev18bbf812014-01-29 01:40:23 -0800443} // namespace nfd