blob: 0173af49da9246e432a54b03651362b06c11ed25 [file] [log] [blame]
Junxiao Shibb5105f2014-03-03 12:06:45 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shi4e837f82017-10-02 22:14:43 +00002/*
Junxiao Shi530cf002017-01-03 14:43:16 +00003 * Copyright (c) 2014-2017, Regents of the University of California,
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -08004 * 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.
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070010 *
11 * 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 Shiee5a4442014-07-27 17:13:43 -070024 */
Junxiao Shibb5105f2014-03-03 12:06:45 -070025
26#include "table/strategy-choice.hpp"
Junxiao Shibb5105f2014-03-03 12:06:45 -070027
28#include "tests/test-common.hpp"
Junxiao Shia49a1ab2016-07-15 18:24:36 +000029#include "../fw/dummy-strategy.hpp"
Junxiao Shibb5105f2014-03-03 12:06:45 -070030
31namespace nfd {
32namespace tests {
33
Junxiao Shi91f6ee02016-12-29 21:44:44 +000034using fw::Strategy;
35
Junxiao Shi18739c42016-12-22 08:03:00 +000036class StrategyChoiceFixture : public BaseFixture
37{
38protected:
39 StrategyChoiceFixture()
40 : sc(forwarder.getStrategyChoice())
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000041 , strategyNameP("/strategy-choice-P/%FD%00")
42 , strategyNameQ("/strategy-choice-Q/%FD%00")
Junxiao Shi18739c42016-12-22 08:03:00 +000043 {
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000044 DummyStrategy::registerAs(strategyNameP);
45 DummyStrategy::registerAs(strategyNameQ);
Junxiao Shi18739c42016-12-22 08:03:00 +000046 }
47
Junxiao Shi91f6ee02016-12-29 21:44:44 +000048 /** \brief insert StrategyChoice entry at \p prefix for \p instanceName
49 * \return constructed instance name
50 */
Junxiao Shi18739c42016-12-22 08:03:00 +000051 Name
Junxiao Shi91f6ee02016-12-29 21:44:44 +000052 insertAndGet(const Name& prefix, const Name& instanceName)
Junxiao Shi18739c42016-12-22 08:03:00 +000053 {
Junxiao Shi91f6ee02016-12-29 21:44:44 +000054 BOOST_REQUIRE(sc.insert(prefix, instanceName));
Junxiao Shi18739c42016-12-22 08:03:00 +000055 bool isFound;
56 Name foundName;
57 std::tie(isFound, foundName) = sc.get(prefix);
58 BOOST_REQUIRE(isFound);
59 return foundName;
60 }
61
Junxiao Shi91f6ee02016-12-29 21:44:44 +000062 /** \brief determine whether the effective strategy type at \p prefix is \p S
63 * \tparam S expected strategy type
64 */
65 template<typename S>
66 bool
67 isStrategyType(const Name& prefix)
68 {
69 Strategy& effectiveStrategy = sc.findEffectiveStrategy(prefix);
70 return dynamic_cast<S*>(&effectiveStrategy) != nullptr;
71 }
72
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000073 template<typename Q>
74 Name
75 findInstanceName(const Q& query)
76 {
77 return sc.findEffectiveStrategy(query).getInstanceName();
78 }
79
Junxiao Shi18739c42016-12-22 08:03:00 +000080protected:
81 Forwarder forwarder;
82 StrategyChoice& sc;
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000083
84 const Name strategyNameP;
85 const Name strategyNameQ;
Junxiao Shi18739c42016-12-22 08:03:00 +000086};
87
Junxiao Shi4370fde2016-02-24 12:20:46 -070088BOOST_AUTO_TEST_SUITE(Table)
Junxiao Shi18739c42016-12-22 08:03:00 +000089BOOST_FIXTURE_TEST_SUITE(TestStrategyChoice, StrategyChoiceFixture)
Junxiao Shibb5105f2014-03-03 12:06:45 -070090
Junxiao Shi7f566dd2016-12-27 02:28:31 +000091BOOST_AUTO_TEST_CASE(Versioning)
92{
93 const Name strategyNameV("/strategy-choice-V");
94 const Name strategyNameV0("/strategy-choice-V/%FD%00");
95 const Name strategyNameV1("/strategy-choice-V/%FD%01");
96 const Name strategyNameV2("/strategy-choice-V/%FD%02");
97 const Name strategyNameV3("/strategy-choice-V/%FD%03");
98 const Name strategyNameV4("/strategy-choice-V/%FD%04");
99 const Name strategyNameV5("/strategy-choice-V/%FD%05");
100
101 VersionedDummyStrategy<1>::registerAs(strategyNameV1);
102 VersionedDummyStrategy<3>::registerAs(strategyNameV3);
103 VersionedDummyStrategy<4>::registerAs(strategyNameV4);
104
105 // unversioned: choose latest version
106 BOOST_CHECK_EQUAL(this->insertAndGet("/A", strategyNameV), strategyNameV4);
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000107 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<4>>("/A"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000108
109 // exact version: choose same version
110 BOOST_CHECK_EQUAL(this->insertAndGet("/B", strategyNameV1), strategyNameV1);
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000111 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<1>>("/B"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000112 BOOST_CHECK_EQUAL(this->insertAndGet("/C", strategyNameV3), strategyNameV3);
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000113 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<3>>("/C"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000114 BOOST_CHECK_EQUAL(this->insertAndGet("/D", strategyNameV4), strategyNameV4);
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000115 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<4>>("/D"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000116
117 // lower version: choose next higher version
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000118 BOOST_CHECK_EQUAL(this->insertAndGet("/E", strategyNameV0), strategyNameV0);
119 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<1>>("/E"));
120 BOOST_CHECK_EQUAL(this->insertAndGet("/F", strategyNameV2), strategyNameV2);
121 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<3>>("/F"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000122
123 // higher version: failure
Junxiao Shi530cf002017-01-03 14:43:16 +0000124 StrategyChoice::InsertResult res5 = sc.insert("/G", strategyNameV5);
125 BOOST_CHECK(!res5);
126 BOOST_CHECK(!res5.isRegistered());
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000127}
128
Junxiao Shi18739c42016-12-22 08:03:00 +0000129BOOST_AUTO_TEST_CASE(Parameters)
130{
Junxiao Shi18739c42016-12-22 08:03:00 +0000131 // no parameters
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000132 BOOST_CHECK_EQUAL(this->insertAndGet("/A", strategyNameP), strategyNameP);
Junxiao Shi18739c42016-12-22 08:03:00 +0000133
134 // one parameter
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000135 Name oneParamName = Name(strategyNameP).append("param");
Junxiao Shi18739c42016-12-22 08:03:00 +0000136 BOOST_CHECK_EQUAL(this->insertAndGet("/B", oneParamName), oneParamName);
137
138 // two parameters
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000139 Name twoParamName = Name(strategyNameP).append("x").append("y");
Junxiao Shi18739c42016-12-22 08:03:00 +0000140 BOOST_CHECK_EQUAL(this->insertAndGet("/C", twoParamName), twoParamName);
141
142 // parameter without version is disallowed
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000143 Name oneParamUnversioned = strategyNameP.getPrefix(-1).append("param");
Junxiao Shi530cf002017-01-03 14:43:16 +0000144 BOOST_CHECK(!sc.insert("/D", oneParamUnversioned));
Junxiao Shi18739c42016-12-22 08:03:00 +0000145}
146
Junxiao Shi4e837f82017-10-02 22:14:43 +0000147BOOST_AUTO_TEST_CASE(InsertLongName)
148{
149 Name n1;
150 while (n1.size() < NameTree::getMaxDepth()) {
151 n1.append("A");
152 }
153 Name n2 = n1;
154 while (n2.size() < NameTree::getMaxDepth() * 2) {
155 n2.append("B");
156 }
157
158 BOOST_CHECK(sc.insert(n1, strategyNameP));
159 BOOST_CHECK(!sc.insert(n2, strategyNameP));
160}
161
Steve DiBenedetto77c87512014-10-06 14:18:22 -0600162BOOST_AUTO_TEST_CASE(Get)
163{
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000164 BOOST_CHECK(sc.insert("/", strategyNameP));
Steve DiBenedetto77c87512014-10-06 14:18:22 -0600165 // { '/'=>P }
166
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000167 auto getRoot = sc.get("/");
Junxiao Shi838c4f12014-11-03 18:55:24 -0700168 BOOST_CHECK_EQUAL(getRoot.first, true);
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000169 BOOST_CHECK_EQUAL(getRoot.second, strategyNameP);
Junxiao Shi838c4f12014-11-03 18:55:24 -0700170
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000171 auto getA = sc.get("/A");
Junxiao Shi838c4f12014-11-03 18:55:24 -0700172 BOOST_CHECK_EQUAL(getA.first, false);
Steve DiBenedetto77c87512014-10-06 14:18:22 -0600173}
174
Junxiao Shi4370fde2016-02-24 12:20:46 -0700175BOOST_AUTO_TEST_CASE(FindEffectiveStrategy)
Junxiao Shibb5105f2014-03-03 12:06:45 -0700176{
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000177 const Name strategyNameZ("/strategy-choice-Z/%FD%00"); // unregistered strategyName
Junxiao Shibb5105f2014-03-03 12:06:45 -0700178
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000179 BOOST_CHECK(sc.insert("/", strategyNameP));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700180 // { '/'=>P }
181
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000182 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
183 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
184 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700185
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000186 BOOST_CHECK(sc.insert("/A/B", strategyNameP));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700187 // { '/'=>P, '/A/B'=>P }
188
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000189 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
190 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
191 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
192 // same entry, same instance
193 BOOST_CHECK_EQUAL(&sc.findEffectiveStrategy("/"), &sc.findEffectiveStrategy("/A"));
194 // different entries, distinct instances
195 BOOST_CHECK_NE(&sc.findEffectiveStrategy("/"), &sc.findEffectiveStrategy("/A/B"));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700196
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000197 sc.erase("/A"); // no effect
Junxiao Shibb5105f2014-03-03 12:06:45 -0700198 // { '/'=>P, '/A/B'=>P }
199
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000200 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
201 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
202 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700203
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000204 BOOST_CHECK(sc.insert("/A", strategyNameQ));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700205 // { '/'=>P, '/A/B'=>P, '/A'=>Q }
206
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000207 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
208 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameQ);
209 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700210
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000211 sc.erase("/A/B");
Junxiao Shibb5105f2014-03-03 12:06:45 -0700212 // { '/'=>P, '/A'=>Q }
213
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000214 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
215 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameQ);
216 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameQ);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700217
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000218 BOOST_CHECK(!sc.insert("/", strategyNameZ)); // non existent strategy
Junxiao Shibb5105f2014-03-03 12:06:45 -0700219
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000220 BOOST_CHECK(sc.insert("/", strategyNameQ));
221 BOOST_CHECK(sc.insert("/A", strategyNameP));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700222 // { '/'=>Q, '/A'=>P }
223
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000224 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameQ);
225 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
226 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
227 BOOST_CHECK_EQUAL(this->findInstanceName("/D"), strategyNameQ);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700228}
229
Junxiao Shi4370fde2016-02-24 12:20:46 -0700230BOOST_AUTO_TEST_CASE(FindEffectiveStrategyWithPitEntry)
231{
Junxiao Shi4370fde2016-02-24 12:20:46 -0700232 shared_ptr<Data> dataABC = makeData("/A/B/C");
233 Name fullName = dataABC->getFullName();
234
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000235 BOOST_CHECK(sc.insert("/A", strategyNameP));
236 BOOST_CHECK(sc.insert(fullName, strategyNameQ));
Junxiao Shi4370fde2016-02-24 12:20:46 -0700237
238 Pit& pit = forwarder.getPit();
239 shared_ptr<Interest> interestAB = makeInterest("/A/B");
240 shared_ptr<pit::Entry> pitAB = pit.insert(*interestAB).first;
241 shared_ptr<Interest> interestFull = makeInterest(fullName);
242 shared_ptr<pit::Entry> pitFull = pit.insert(*interestFull).first;
243
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000244 BOOST_CHECK_EQUAL(this->findInstanceName(*pitAB), strategyNameP);
245 BOOST_CHECK_EQUAL(this->findInstanceName(*pitFull), strategyNameQ);
Junxiao Shi4370fde2016-02-24 12:20:46 -0700246}
247
248BOOST_AUTO_TEST_CASE(FindEffectiveStrategyWithMeasurementsEntry)
249{
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000250 BOOST_CHECK(sc.insert("/A", strategyNameP));
251 BOOST_CHECK(sc.insert("/A/B/C", strategyNameQ));
Junxiao Shi4370fde2016-02-24 12:20:46 -0700252
253 Measurements& measurements = forwarder.getMeasurements();
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000254 measurements::Entry& mAB = measurements.get("/A/B");
255 measurements::Entry& mABCD = measurements.get("/A/B/C/D");
Junxiao Shi4370fde2016-02-24 12:20:46 -0700256
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000257 BOOST_CHECK_EQUAL(this->findInstanceName(mAB), strategyNameP);
258 BOOST_CHECK_EQUAL(this->findInstanceName(mABCD), strategyNameQ);
259}
260
261BOOST_AUTO_TEST_CASE(Erase)
262{
263 NameTree& nameTree = forwarder.getNameTree();
264
265 sc.insert("/", strategyNameP);
266
267 size_t nNameTreeEntriesBefore = nameTree.size();
268
269 sc.insert("/A/B", strategyNameQ);
270 sc.erase("/A/B");
271 BOOST_CHECK_EQUAL(nameTree.size(), nNameTreeEntriesBefore);
Junxiao Shi4370fde2016-02-24 12:20:46 -0700272}
273
Junxiao Shib5888d22014-05-26 07:35:22 -0700274BOOST_AUTO_TEST_CASE(Enumerate)
275{
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000276 sc.insert("/", strategyNameP);
277 sc.insert("/A/B", strategyNameQ);
278 sc.insert("/A/B/C", strategyNameP);
279 sc.insert("/D", strategyNameP);
280 sc.insert("/E", strategyNameQ);
Junxiao Shib5888d22014-05-26 07:35:22 -0700281
Junxiao Shi18739c42016-12-22 08:03:00 +0000282 BOOST_CHECK_EQUAL(sc.size(), 5);
Junxiao Shib5888d22014-05-26 07:35:22 -0700283
284 std::map<Name, Name> map; // namespace=>strategyName
Junxiao Shi18739c42016-12-22 08:03:00 +0000285 for (StrategyChoice::const_iterator it = sc.begin(); it != sc.end(); ++it) {
Junxiao Shi4cb74312016-12-25 20:48:47 +0000286 map[it->getPrefix()] = it->getStrategyInstanceName();
Junxiao Shib5888d22014-05-26 07:35:22 -0700287 }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000288
289 BOOST_CHECK_EQUAL(map.at("/"), strategyNameP);
290 BOOST_CHECK_EQUAL(map.at("/A/B"), strategyNameQ);
291 BOOST_CHECK_EQUAL(map.at("/A/B/C"), strategyNameP);
292 BOOST_CHECK_EQUAL(map.at("/D"), strategyNameP);
293 BOOST_CHECK_EQUAL(map.at("/E"), strategyNameQ);
Junxiao Shib5888d22014-05-26 07:35:22 -0700294 BOOST_CHECK_EQUAL(map.size(), 5);
295}
296
Junxiao Shie349ea12014-03-12 01:32:42 -0700297class PStrategyInfo : public fw::StrategyInfo
298{
Junxiao Shi39ef2612014-11-29 20:35:19 -0700299public:
300 static constexpr int
301 getTypeId()
302 {
303 return 10;
304 }
Junxiao Shie349ea12014-03-12 01:32:42 -0700305};
306
307BOOST_AUTO_TEST_CASE(ClearStrategyInfo)
308{
Junxiao Shie349ea12014-03-12 01:32:42 -0700309 Measurements& measurements = forwarder.getMeasurements();
310
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000311 BOOST_CHECK(sc.insert("/", strategyNameP));
Junxiao Shie349ea12014-03-12 01:32:42 -0700312 // { '/'=>P }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000313 measurements.get("/").insertStrategyInfo<PStrategyInfo>();
314 measurements.get("/A").insertStrategyInfo<PStrategyInfo>();
315 measurements.get("/A/B").insertStrategyInfo<PStrategyInfo>();
316 measurements.get("/A/C").insertStrategyInfo<PStrategyInfo>();
Junxiao Shie349ea12014-03-12 01:32:42 -0700317
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000318 BOOST_CHECK(sc.insert("/A/B", strategyNameP));
Junxiao Shie349ea12014-03-12 01:32:42 -0700319 // { '/'=>P, '/A/B'=>P }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000320 BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr);
321 BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() != nullptr);
Junxiao Shi55e21b92017-01-23 03:27:47 +0000322 BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() != nullptr);
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000323 BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() != nullptr);
Junxiao Shie349ea12014-03-12 01:32:42 -0700324
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000325 BOOST_CHECK(sc.insert("/A", strategyNameQ));
Junxiao Shie349ea12014-03-12 01:32:42 -0700326 // { '/'=>P, '/A/B'=>P, '/A'=>Q }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000327 BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr);
328 BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() == nullptr);
Junxiao Shi55e21b92017-01-23 03:27:47 +0000329 BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() != nullptr);
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000330 BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() == nullptr);
Junxiao Shie349ea12014-03-12 01:32:42 -0700331
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000332 sc.erase("/A/B");
Junxiao Shie349ea12014-03-12 01:32:42 -0700333 // { '/'=>P, '/A'=>Q }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000334 BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr);
335 BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() == nullptr);
336 BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() == nullptr);
337 BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() == nullptr);
Junxiao Shie93d6a32014-09-07 16:13:22 -0700338}
339
Junxiao Shi4370fde2016-02-24 12:20:46 -0700340BOOST_AUTO_TEST_SUITE_END() // TestStrategyChoice
341BOOST_AUTO_TEST_SUITE_END() // Table
Junxiao Shibb5105f2014-03-03 12:06:45 -0700342
343} // namespace tests
344} // namespace nfd