blob: 8c9bbf555570ff29ec9dc8c33527a5e82b39d594 [file] [log] [blame]
Junxiao Shi0fcb41e2014-01-24 10:29:43 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Minsheng Zhangffe8bbb2016-03-10 13:40:37 -07003 * Copyright (c) 2014-2016, Regents of the University of California,
Junxiao Shifc206962015-01-16 11:12:22 -07004 * 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 Shicbc8e942016-09-06 03:17:45 +000027#include <ndn-cxx/lp/tags.hpp>
Junxiao Shia9388182014-12-13 23:16:09 -070028#include <ndn-cxx/util/crypto.hpp>
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -080029
Junxiao Shid9ee45c2014-02-27 15:38:11 -070030#include "tests/test-common.hpp"
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -080031
mzhang4eab72492015-02-25 11:16:09 -060032#define CHECK_CS_FIND(expected) find([&] (uint32_t found) { BOOST_CHECK_EQUAL(expected, found); });
33
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080034namespace nfd {
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -080035namespace cs {
Junxiao Shid9ee45c2014-02-27 15:38:11 -070036namespace tests {
Junxiao Shi0fcb41e2014-01-24 10:29:43 -070037
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -080038using namespace nfd::tests;
39
Minsheng Zhangffe8bbb2016-03-10 13:40:37 -070040BOOST_AUTO_TEST_SUITE(Table)
41BOOST_FIXTURE_TEST_SUITE(TestCs, BaseFixture)
Junxiao Shi0fcb41e2014-01-24 10:29:43 -070042
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080043class FindFixture : protected BaseFixture
44{
45protected:
Junxiao Shia9388182014-12-13 23:16:09 -070046 Name
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080047 insert(uint32_t id, const Name& name)
48 {
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -040049 shared_ptr<Data> data = makeData(name);
Alexander Afanasyeveb3197f2014-03-17 19:28:18 -070050 data->setFreshnessPeriod(time::milliseconds(99999));
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080051 data->setContent(reinterpret_cast<const uint8_t*>(&id), sizeof(id));
Junxiao Shia9388182014-12-13 23:16:09 -070052 data->wireEncode();
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070053
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080054 m_cs.insert(*data);
Junxiao Shia9388182014-12-13 23:16:09 -070055
56 return data->getFullName();
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080057 }
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070058
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080059 Interest&
60 startInterest(const Name& name)
61 {
62 m_interest = make_shared<Interest>(name);
63 return *m_interest;
64 }
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070065
mzhang4eab72492015-02-25 11:16:09 -060066 void
67 find(const std::function<void(uint32_t)>& check)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080068 {
mzhang4eab72492015-02-25 11:16:09 -060069 m_cs.find(*m_interest,
70 [&] (const Interest& interest, const Data& data) {
71 const Block& content = data.getContent();
72 uint32_t found = *reinterpret_cast<const uint32_t*>(content.value());
73 check(found); },
74 bind([&] { check(0); }));
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080075 }
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070076
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080077protected:
78 Cs m_cs;
79 shared_ptr<Interest> m_interest;
80};
81
82BOOST_FIXTURE_TEST_SUITE(Find, FindFixture)
83
84BOOST_AUTO_TEST_CASE(EmptyDataName)
85{
86 insert(1, "ndn:/");
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070087
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080088 startInterest("ndn:/");
mzhang4eab72492015-02-25 11:16:09 -060089 CHECK_CS_FIND(1);
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080090}
91
92BOOST_AUTO_TEST_CASE(EmptyInterestName)
93{
94 insert(1, "ndn:/A");
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070095
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080096 startInterest("ndn:/");
mzhang4eab72492015-02-25 11:16:09 -060097 CHECK_CS_FIND(1);
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080098}
99
Junxiao Shia9388182014-12-13 23:16:09 -0700100BOOST_AUTO_TEST_CASE(ExactName)
101{
102 insert(1, "ndn:/");
103 insert(2, "ndn:/A");
104 insert(3, "ndn:/A/B");
105 insert(4, "ndn:/A/C");
106 insert(5, "ndn:/D");
107
108 startInterest("ndn:/A");
mzhang4eab72492015-02-25 11:16:09 -0600109 CHECK_CS_FIND(2);
Junxiao Shia9388182014-12-13 23:16:09 -0700110}
111
112BOOST_AUTO_TEST_CASE(FullName)
113{
114 Name n1 = insert(1, "ndn:/A");
115 Name n2 = insert(2, "ndn:/A");
116
117 startInterest(n1);
mzhang4eab72492015-02-25 11:16:09 -0600118 CHECK_CS_FIND(1);
Junxiao Shia9388182014-12-13 23:16:09 -0700119
120 startInterest(n2);
mzhang4eab72492015-02-25 11:16:09 -0600121 CHECK_CS_FIND(2);
Junxiao Shia9388182014-12-13 23:16:09 -0700122}
123
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800124BOOST_AUTO_TEST_CASE(Leftmost)
125{
126 insert(1, "ndn:/A");
127 insert(2, "ndn:/B/p/1");
128 insert(3, "ndn:/B/p/2");
129 insert(4, "ndn:/B/q/1");
130 insert(5, "ndn:/B/q/2");
131 insert(6, "ndn:/C");
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700132
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800133 startInterest("ndn:/B");
mzhang4eab72492015-02-25 11:16:09 -0600134 CHECK_CS_FIND(2);
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800135}
136
137BOOST_AUTO_TEST_CASE(Rightmost)
138{
139 insert(1, "ndn:/A");
140 insert(2, "ndn:/B/p/1");
141 insert(3, "ndn:/B/p/2");
142 insert(4, "ndn:/B/q/1");
143 insert(5, "ndn:/B/q/2");
144 insert(6, "ndn:/C");
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700145
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800146 startInterest("ndn:/B")
147 .setChildSelector(1);
mzhang4eab72492015-02-25 11:16:09 -0600148 CHECK_CS_FIND(4);
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800149}
150
Junxiao Shia9388182014-12-13 23:16:09 -0700151BOOST_AUTO_TEST_CASE(MinSuffixComponents)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800152{
153 insert(1, "ndn:/");
154 insert(2, "ndn:/A");
Junxiao Shia9388182014-12-13 23:16:09 -0700155 insert(3, "ndn:/B/1");
156 insert(4, "ndn:/C/1/2");
157 insert(5, "ndn:/D/1/2/3");
158 insert(6, "ndn:/E/1/2/3/4");
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700159
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800160 startInterest("ndn:/")
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800161 .setMinSuffixComponents(0);
mzhang4eab72492015-02-25 11:16:09 -0600162 CHECK_CS_FIND(1);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700163
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800164 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700165 .setMinSuffixComponents(1);
mzhang4eab72492015-02-25 11:16:09 -0600166 CHECK_CS_FIND(1);
Junxiao Shia9388182014-12-13 23:16:09 -0700167
168 startInterest("ndn:/")
169 .setMinSuffixComponents(2);
mzhang4eab72492015-02-25 11:16:09 -0600170 CHECK_CS_FIND(2);
Junxiao Shia9388182014-12-13 23:16:09 -0700171
172 startInterest("ndn:/")
173 .setMinSuffixComponents(3);
mzhang4eab72492015-02-25 11:16:09 -0600174 CHECK_CS_FIND(3);
Junxiao Shia9388182014-12-13 23:16:09 -0700175
176 startInterest("ndn:/")
177 .setMinSuffixComponents(4);
mzhang4eab72492015-02-25 11:16:09 -0600178 CHECK_CS_FIND(4);
Junxiao Shia9388182014-12-13 23:16:09 -0700179
180 startInterest("ndn:/")
181 .setMinSuffixComponents(5);
mzhang4eab72492015-02-25 11:16:09 -0600182 CHECK_CS_FIND(5);
Junxiao Shia9388182014-12-13 23:16:09 -0700183
184 startInterest("ndn:/")
185 .setMinSuffixComponents(6);
mzhang4eab72492015-02-25 11:16:09 -0600186 CHECK_CS_FIND(6);
Junxiao Shia9388182014-12-13 23:16:09 -0700187
188 startInterest("ndn:/")
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800189 .setMinSuffixComponents(7);
mzhang4eab72492015-02-25 11:16:09 -0600190 CHECK_CS_FIND(0);
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800191}
192
193BOOST_AUTO_TEST_CASE(MaxSuffixComponents)
194{
195 insert(1, "ndn:/");
196 insert(2, "ndn:/A");
Junxiao Shia9388182014-12-13 23:16:09 -0700197 insert(3, "ndn:/B/2");
198 insert(4, "ndn:/C/2/3");
199 insert(5, "ndn:/D/2/3/4");
200 insert(6, "ndn:/E/2/3/4/5");
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700201
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800202 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700203 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800204 .setMaxSuffixComponents(0);
mzhang4eab72492015-02-25 11:16:09 -0600205 CHECK_CS_FIND(0);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700206
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800207 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700208 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800209 .setMaxSuffixComponents(1);
mzhang4eab72492015-02-25 11:16:09 -0600210 CHECK_CS_FIND(1);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700211
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800212 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700213 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800214 .setMaxSuffixComponents(2);
mzhang4eab72492015-02-25 11:16:09 -0600215 CHECK_CS_FIND(2);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700216
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800217 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700218 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800219 .setMaxSuffixComponents(3);
mzhang4eab72492015-02-25 11:16:09 -0600220 CHECK_CS_FIND(3);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700221
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800222 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700223 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800224 .setMaxSuffixComponents(4);
mzhang4eab72492015-02-25 11:16:09 -0600225 CHECK_CS_FIND(4);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700226
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800227 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700228 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800229 .setMaxSuffixComponents(5);
mzhang4eab72492015-02-25 11:16:09 -0600230 CHECK_CS_FIND(5);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700231
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800232 startInterest("ndn:/")
Junxiao Shia9388182014-12-13 23:16:09 -0700233 .setChildSelector(1)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800234 .setMaxSuffixComponents(6);
mzhang4eab72492015-02-25 11:16:09 -0600235 CHECK_CS_FIND(6);
Junxiao Shia9388182014-12-13 23:16:09 -0700236
237 startInterest("ndn:/")
238 .setChildSelector(1)
239 .setMaxSuffixComponents(7);
mzhang4eab72492015-02-25 11:16:09 -0600240 CHECK_CS_FIND(6);
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800241}
242
243BOOST_AUTO_TEST_CASE(DigestOrder)
244{
245 insert(1, "ndn:/A");
246 insert(2, "ndn:/A");
247 // We don't know which comes first, but there must be some order
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700248
mzhang4eab72492015-02-25 11:16:09 -0600249 int leftmost = 0, rightmost = 0;
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800250 startInterest("ndn:/A")
251 .setChildSelector(0);
mzhang4eab72492015-02-25 11:16:09 -0600252 m_cs.find(*m_interest,
253 [&leftmost] (const Interest& interest, const Data& data) {
254 leftmost = *reinterpret_cast<const uint32_t*>(data.getContent().value());},
255 bind([] { BOOST_CHECK(false); }));
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800256 startInterest("ndn:/A")
257 .setChildSelector(1);
mzhang4eab72492015-02-25 11:16:09 -0600258 m_cs.find(*m_interest,
259 [&rightmost] (const Interest, const Data& data) {
260 rightmost = *reinterpret_cast<const uint32_t*>(data.getContent().value()); },
261 bind([] { BOOST_CHECK(false); }));
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800262 BOOST_CHECK_NE(leftmost, rightmost);
263}
264
265BOOST_AUTO_TEST_CASE(DigestExclude)
266{
Junxiao Shia9388182014-12-13 23:16:09 -0700267 insert(1, "ndn:/A");
268 Name n2 = insert(2, "ndn:/A");
269 insert(3, "ndn:/A/B");
270
271 uint8_t digest00[ndn::crypto::SHA256_DIGEST_SIZE];
272 std::fill_n(digest00, sizeof(digest00), 0x00);
273 uint8_t digestFF[ndn::crypto::SHA256_DIGEST_SIZE];
274 std::fill_n(digestFF, sizeof(digestFF), 0xFF);
275
276 Exclude excludeDigest;
277 excludeDigest.excludeRange(
278 name::Component::fromImplicitSha256Digest(digest00, sizeof(digest00)),
279 name::Component::fromImplicitSha256Digest(digestFF, sizeof(digestFF)));
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700280
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800281 startInterest("ndn:/A")
Junxiao Shia9388182014-12-13 23:16:09 -0700282 .setChildSelector(0)
283 .setExclude(excludeDigest);
mzhang4eab72492015-02-25 11:16:09 -0600284 CHECK_CS_FIND(3);
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -0700285
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -0800286 startInterest("ndn:/A")
287 .setChildSelector(1)
Junxiao Shia9388182014-12-13 23:16:09 -0700288 .setExclude(excludeDigest);
mzhang4eab72492015-02-25 11:16:09 -0600289 CHECK_CS_FIND(3);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400290
Junxiao Shia9388182014-12-13 23:16:09 -0700291 Exclude excludeGeneric;
292 excludeGeneric.excludeAfter(name::Component(static_cast<uint8_t*>(nullptr), 0));
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400293
Junxiao Shia9388182014-12-13 23:16:09 -0700294 startInterest("ndn:/A")
295 .setChildSelector(0)
296 .setExclude(excludeGeneric);
mzhang4eab72492015-02-25 11:16:09 -0600297 find([] (uint32_t found) { BOOST_CHECK(found == 1 || found == 2); });
Junxiao Shia9388182014-12-13 23:16:09 -0700298
299 startInterest("ndn:/A")
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400300 .setChildSelector(1)
Junxiao Shia9388182014-12-13 23:16:09 -0700301 .setExclude(excludeGeneric);
mzhang4eab72492015-02-25 11:16:09 -0600302 find([] (uint32_t found) { BOOST_CHECK(found == 1 || found == 2); });
Junxiao Shia9388182014-12-13 23:16:09 -0700303
304 Exclude exclude2 = excludeGeneric;
305 exclude2.excludeOne(n2.get(-1));
306
307 startInterest("ndn:/A")
308 .setChildSelector(0)
309 .setExclude(exclude2);
mzhang4eab72492015-02-25 11:16:09 -0600310 CHECK_CS_FIND(1);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400311
Junxiao Shia9388182014-12-13 23:16:09 -0700312 startInterest("ndn:/A")
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400313 .setChildSelector(1)
Junxiao Shia9388182014-12-13 23:16:09 -0700314 .setExclude(exclude2);
mzhang4eab72492015-02-25 11:16:09 -0600315 CHECK_CS_FIND(1);
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400316}
317
Minsheng Zhangffe8bbb2016-03-10 13:40:37 -0700318/// \todo test MustBeFresh
319
320BOOST_AUTO_TEST_SUITE_END() // Find
321
322// When the capacity limit is set to zero, Data cannot be inserted;
323// this test case covers this situation.
324// The behavior of non-zero capacity limit depends on the eviction policy,
325// and is tested in policy test suites.
326BOOST_FIXTURE_TEST_CASE(ZeroCapacity, FindFixture)
327{
328 m_cs.setLimit(0);
329
330 BOOST_CHECK_EQUAL(m_cs.getLimit(), 0);
331 BOOST_CHECK_EQUAL(m_cs.size(), 0);
332 BOOST_CHECK(m_cs.begin() == m_cs.end());
333
334 insert(1, "ndn:/A");
335 BOOST_CHECK_EQUAL(m_cs.size(), 0);
336
337 startInterest("ndn:/A");
338 CHECK_CS_FIND(0);
339}
Junxiao Shia9388182014-12-13 23:16:09 -0700340
Junxiao Shi0de23a22015-12-03 20:07:02 +0000341BOOST_AUTO_TEST_CASE(CachePolicyNoCache)
Junxiao Shi35b16b12015-02-16 22:14:57 -0700342{
343 Cs cs(3);
344
345 shared_ptr<Data> dataA = makeData("ndn:/A");
Junxiao Shi35b16b12015-02-16 22:14:57 -0700346 dataA->wireEncode();
Junxiao Shi0de23a22015-12-03 20:07:02 +0000347 dataA->setTag(make_shared<lp::CachePolicyTag>(
348 lp::CachePolicy().setPolicy(lp::CachePolicyType::NO_CACHE)));
Minsheng Zhangffe8bbb2016-03-10 13:40:37 -0700349 cs.insert(*dataA);
Junxiao Shi0de23a22015-12-03 20:07:02 +0000350
Minsheng Zhangffe8bbb2016-03-10 13:40:37 -0700351 BOOST_CHECK_EQUAL(cs.size(), 0);
mzhang4eab72492015-02-25 11:16:09 -0600352 cs.find(Interest("ndn:/A"),
353 bind([] { BOOST_CHECK(false); }),
354 bind([] { BOOST_CHECK(true); }));
Junxiao Shi35b16b12015-02-16 22:14:57 -0700355}
356
Junxiao Shifc206962015-01-16 11:12:22 -0700357BOOST_AUTO_TEST_CASE(Enumeration)
358{
359 Cs cs;
360
361 Name nameA("/A");
362 Name nameAB("/A/B");
363 Name nameABC("/A/B/C");
364 Name nameD("/D");
365
366 BOOST_CHECK_EQUAL(cs.size(), 0);
367 BOOST_CHECK(cs.begin() == cs.end());
368
369 cs.insert(*makeData(nameABC));
370 BOOST_CHECK_EQUAL(cs.size(), 1);
371 BOOST_CHECK(cs.begin() != cs.end());
372 BOOST_CHECK(cs.begin()->getName() == nameABC);
373 BOOST_CHECK((*cs.begin()).getName() == nameABC);
374
375 auto i = cs.begin();
376 auto j = cs.begin();
377 BOOST_CHECK(++i == cs.end());
378 BOOST_CHECK(j++ == cs.begin());
379 BOOST_CHECK(j == cs.end());
380
381 cs.insert(*makeData(nameA));
382 cs.insert(*makeData(nameAB));
383 cs.insert(*makeData(nameD));
384
385 std::set<Name> expected = {nameA, nameAB, nameABC, nameD};
386 std::set<Name> actual;
387 for (const auto& csEntry : cs) {
388 actual.insert(csEntry.getName());
389 }
390 BOOST_CHECK_EQUAL_COLLECTIONS(actual.begin(), actual.end(), expected.begin(), expected.end());
391}
392
Minsheng Zhangffe8bbb2016-03-10 13:40:37 -0700393BOOST_AUTO_TEST_SUITE_END() // TestCs
394BOOST_AUTO_TEST_SUITE_END() // Table
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -0800395
Junxiao Shid9ee45c2014-02-27 15:38:11 -0700396} // namespace tests
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -0800397} // namespace cs
Alexander Afanasyev18bbf812014-01-29 01:40:23 -0800398} // namespace nfd