blob: 8c52b5410dc0615c165d088b9d5f32e9af4cc111 [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/*
Davide Pesaventocf7db2f2019-03-24 23:17:28 -04003 * Copyright (c) 2014-2019, 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"
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040029#include "tests/daemon/global-io-fixture.hpp"
30#include "tests/daemon/fw/dummy-strategy.hpp"
Junxiao Shibb5105f2014-03-03 12:06:45 -070031
32namespace nfd {
33namespace tests {
34
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040035class StrategyChoiceFixture : public GlobalIoFixture
Junxiao Shi18739c42016-12-22 08:03:00 +000036{
37protected:
38 StrategyChoiceFixture()
Junxiao Shi18739c42016-12-22 08:03:00 +000039 {
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000040 DummyStrategy::registerAs(strategyNameP);
41 DummyStrategy::registerAs(strategyNameQ);
Junxiao Shi18739c42016-12-22 08:03:00 +000042 }
43
Junxiao Shi91f6ee02016-12-29 21:44:44 +000044 /** \brief insert StrategyChoice entry at \p prefix for \p instanceName
45 * \return constructed instance name
46 */
Junxiao Shi18739c42016-12-22 08:03:00 +000047 Name
Junxiao Shi91f6ee02016-12-29 21:44:44 +000048 insertAndGet(const Name& prefix, const Name& instanceName)
Junxiao Shi18739c42016-12-22 08:03:00 +000049 {
Junxiao Shi91f6ee02016-12-29 21:44:44 +000050 BOOST_REQUIRE(sc.insert(prefix, instanceName));
Junxiao Shi18739c42016-12-22 08:03:00 +000051 bool isFound;
52 Name foundName;
53 std::tie(isFound, foundName) = sc.get(prefix);
54 BOOST_REQUIRE(isFound);
55 return foundName;
56 }
57
Junxiao Shi91f6ee02016-12-29 21:44:44 +000058 /** \brief determine whether the effective strategy type at \p prefix is \p S
59 * \tparam S expected strategy type
60 */
61 template<typename S>
62 bool
63 isStrategyType(const Name& prefix)
64 {
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040065 auto& effectiveStrategy = sc.findEffectiveStrategy(prefix);
Junxiao Shi91f6ee02016-12-29 21:44:44 +000066 return dynamic_cast<S*>(&effectiveStrategy) != nullptr;
67 }
68
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000069 template<typename Q>
70 Name
71 findInstanceName(const Q& query)
72 {
73 return sc.findEffectiveStrategy(query).getInstanceName();
74 }
75
Junxiao Shi18739c42016-12-22 08:03:00 +000076protected:
Davide Pesaventoa4abfb02019-10-06 16:02:56 -040077 FaceTable faceTable;
78 Forwarder forwarder{faceTable};
79 StrategyChoice& sc{forwarder.getStrategyChoice()};
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000080
Davide Pesaventoa4abfb02019-10-06 16:02:56 -040081 const Name strategyNameP = "/strategy-choice-P/%FD%00";
82 const Name strategyNameQ = "/strategy-choice-Q/%FD%00";
Junxiao Shi18739c42016-12-22 08:03:00 +000083};
84
Junxiao Shi4370fde2016-02-24 12:20:46 -070085BOOST_AUTO_TEST_SUITE(Table)
Junxiao Shi18739c42016-12-22 08:03:00 +000086BOOST_FIXTURE_TEST_SUITE(TestStrategyChoice, StrategyChoiceFixture)
Junxiao Shibb5105f2014-03-03 12:06:45 -070087
Junxiao Shi7f566dd2016-12-27 02:28:31 +000088BOOST_AUTO_TEST_CASE(Versioning)
89{
90 const Name strategyNameV("/strategy-choice-V");
91 const Name strategyNameV0("/strategy-choice-V/%FD%00");
92 const Name strategyNameV1("/strategy-choice-V/%FD%01");
93 const Name strategyNameV2("/strategy-choice-V/%FD%02");
94 const Name strategyNameV3("/strategy-choice-V/%FD%03");
95 const Name strategyNameV4("/strategy-choice-V/%FD%04");
96 const Name strategyNameV5("/strategy-choice-V/%FD%05");
97
98 VersionedDummyStrategy<1>::registerAs(strategyNameV1);
99 VersionedDummyStrategy<3>::registerAs(strategyNameV3);
100 VersionedDummyStrategy<4>::registerAs(strategyNameV4);
101
102 // unversioned: choose latest version
103 BOOST_CHECK_EQUAL(this->insertAndGet("/A", strategyNameV), strategyNameV4);
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000104 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<4>>("/A"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000105
106 // exact version: choose same version
107 BOOST_CHECK_EQUAL(this->insertAndGet("/B", strategyNameV1), strategyNameV1);
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000108 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<1>>("/B"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000109 BOOST_CHECK_EQUAL(this->insertAndGet("/C", strategyNameV3), strategyNameV3);
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000110 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<3>>("/C"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000111 BOOST_CHECK_EQUAL(this->insertAndGet("/D", strategyNameV4), strategyNameV4);
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000112 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<4>>("/D"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000113
114 // lower version: choose next higher version
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000115 BOOST_CHECK_EQUAL(this->insertAndGet("/E", strategyNameV0), strategyNameV0);
116 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<1>>("/E"));
117 BOOST_CHECK_EQUAL(this->insertAndGet("/F", strategyNameV2), strategyNameV2);
118 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<3>>("/F"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000119
120 // higher version: failure
Junxiao Shi530cf002017-01-03 14:43:16 +0000121 StrategyChoice::InsertResult res5 = sc.insert("/G", strategyNameV5);
122 BOOST_CHECK(!res5);
123 BOOST_CHECK(!res5.isRegistered());
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000124}
125
Junxiao Shi18739c42016-12-22 08:03:00 +0000126BOOST_AUTO_TEST_CASE(Parameters)
127{
Junxiao Shi18739c42016-12-22 08:03:00 +0000128 // no parameters
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000129 BOOST_CHECK_EQUAL(this->insertAndGet("/A", strategyNameP), strategyNameP);
Junxiao Shi18739c42016-12-22 08:03:00 +0000130
131 // one parameter
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000132 Name oneParamName = Name(strategyNameP).append("param");
Junxiao Shi18739c42016-12-22 08:03:00 +0000133 BOOST_CHECK_EQUAL(this->insertAndGet("/B", oneParamName), oneParamName);
134
135 // two parameters
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000136 Name twoParamName = Name(strategyNameP).append("x").append("y");
Junxiao Shi18739c42016-12-22 08:03:00 +0000137 BOOST_CHECK_EQUAL(this->insertAndGet("/C", twoParamName), twoParamName);
138
139 // parameter without version is disallowed
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000140 Name oneParamUnversioned = strategyNameP.getPrefix(-1).append("param");
Junxiao Shi530cf002017-01-03 14:43:16 +0000141 BOOST_CHECK(!sc.insert("/D", oneParamUnversioned));
Junxiao Shi18739c42016-12-22 08:03:00 +0000142}
143
Junxiao Shi4e837f82017-10-02 22:14:43 +0000144BOOST_AUTO_TEST_CASE(InsertLongName)
145{
146 Name n1;
147 while (n1.size() < NameTree::getMaxDepth()) {
148 n1.append("A");
149 }
150 Name n2 = n1;
151 while (n2.size() < NameTree::getMaxDepth() * 2) {
152 n2.append("B");
153 }
154
155 BOOST_CHECK(sc.insert(n1, strategyNameP));
156 BOOST_CHECK(!sc.insert(n2, strategyNameP));
157}
158
Steve DiBenedetto77c87512014-10-06 14:18:22 -0600159BOOST_AUTO_TEST_CASE(Get)
160{
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000161 BOOST_CHECK(sc.insert("/", strategyNameP));
Steve DiBenedetto77c87512014-10-06 14:18:22 -0600162 // { '/'=>P }
163
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000164 auto getRoot = sc.get("/");
Junxiao Shi838c4f12014-11-03 18:55:24 -0700165 BOOST_CHECK_EQUAL(getRoot.first, true);
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000166 BOOST_CHECK_EQUAL(getRoot.second, strategyNameP);
Junxiao Shi838c4f12014-11-03 18:55:24 -0700167
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000168 auto getA = sc.get("/A");
Junxiao Shi838c4f12014-11-03 18:55:24 -0700169 BOOST_CHECK_EQUAL(getA.first, false);
Steve DiBenedetto77c87512014-10-06 14:18:22 -0600170}
171
Junxiao Shi4370fde2016-02-24 12:20:46 -0700172BOOST_AUTO_TEST_CASE(FindEffectiveStrategy)
Junxiao Shibb5105f2014-03-03 12:06:45 -0700173{
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000174 const Name strategyNameZ("/strategy-choice-Z/%FD%00"); // unregistered strategyName
Junxiao Shibb5105f2014-03-03 12:06:45 -0700175
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000176 BOOST_CHECK(sc.insert("/", strategyNameP));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700177 // { '/'=>P }
178
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000179 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
180 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
181 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700182
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000183 BOOST_CHECK(sc.insert("/A/B", strategyNameP));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700184 // { '/'=>P, '/A/B'=>P }
185
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000186 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
187 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
188 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
189 // same entry, same instance
190 BOOST_CHECK_EQUAL(&sc.findEffectiveStrategy("/"), &sc.findEffectiveStrategy("/A"));
191 // different entries, distinct instances
192 BOOST_CHECK_NE(&sc.findEffectiveStrategy("/"), &sc.findEffectiveStrategy("/A/B"));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700193
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000194 sc.erase("/A"); // no effect
Junxiao Shibb5105f2014-03-03 12:06:45 -0700195 // { '/'=>P, '/A/B'=>P }
196
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000197 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
198 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
199 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700200
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000201 BOOST_CHECK(sc.insert("/A", strategyNameQ));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700202 // { '/'=>P, '/A/B'=>P, '/A'=>Q }
203
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000204 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
205 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameQ);
206 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700207
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000208 sc.erase("/A/B");
Junxiao Shibb5105f2014-03-03 12:06:45 -0700209 // { '/'=>P, '/A'=>Q }
210
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000211 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
212 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameQ);
213 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameQ);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700214
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000215 BOOST_CHECK(!sc.insert("/", strategyNameZ)); // non existent strategy
Junxiao Shibb5105f2014-03-03 12:06:45 -0700216
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000217 BOOST_CHECK(sc.insert("/", strategyNameQ));
218 BOOST_CHECK(sc.insert("/A", strategyNameP));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700219 // { '/'=>Q, '/A'=>P }
220
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000221 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameQ);
222 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
223 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
224 BOOST_CHECK_EQUAL(this->findInstanceName("/D"), strategyNameQ);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700225}
226
Junxiao Shi4370fde2016-02-24 12:20:46 -0700227BOOST_AUTO_TEST_CASE(FindEffectiveStrategyWithPitEntry)
228{
Junxiao Shi4370fde2016-02-24 12:20:46 -0700229 shared_ptr<Data> dataABC = makeData("/A/B/C");
230 Name fullName = dataABC->getFullName();
231
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000232 BOOST_CHECK(sc.insert("/A", strategyNameP));
233 BOOST_CHECK(sc.insert(fullName, strategyNameQ));
Junxiao Shi4370fde2016-02-24 12:20:46 -0700234
235 Pit& pit = forwarder.getPit();
236 shared_ptr<Interest> interestAB = makeInterest("/A/B");
237 shared_ptr<pit::Entry> pitAB = pit.insert(*interestAB).first;
238 shared_ptr<Interest> interestFull = makeInterest(fullName);
239 shared_ptr<pit::Entry> pitFull = pit.insert(*interestFull).first;
240
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000241 BOOST_CHECK_EQUAL(this->findInstanceName(*pitAB), strategyNameP);
242 BOOST_CHECK_EQUAL(this->findInstanceName(*pitFull), strategyNameQ);
Junxiao Shi4370fde2016-02-24 12:20:46 -0700243}
244
245BOOST_AUTO_TEST_CASE(FindEffectiveStrategyWithMeasurementsEntry)
246{
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000247 BOOST_CHECK(sc.insert("/A", strategyNameP));
248 BOOST_CHECK(sc.insert("/A/B/C", strategyNameQ));
Junxiao Shi4370fde2016-02-24 12:20:46 -0700249
250 Measurements& measurements = forwarder.getMeasurements();
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000251 measurements::Entry& mAB = measurements.get("/A/B");
252 measurements::Entry& mABCD = measurements.get("/A/B/C/D");
Junxiao Shi4370fde2016-02-24 12:20:46 -0700253
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000254 BOOST_CHECK_EQUAL(this->findInstanceName(mAB), strategyNameP);
255 BOOST_CHECK_EQUAL(this->findInstanceName(mABCD), strategyNameQ);
256}
257
258BOOST_AUTO_TEST_CASE(Erase)
259{
260 NameTree& nameTree = forwarder.getNameTree();
261
262 sc.insert("/", strategyNameP);
263
264 size_t nNameTreeEntriesBefore = nameTree.size();
265
266 sc.insert("/A/B", strategyNameQ);
267 sc.erase("/A/B");
268 BOOST_CHECK_EQUAL(nameTree.size(), nNameTreeEntriesBefore);
Junxiao Shi4370fde2016-02-24 12:20:46 -0700269}
270
Junxiao Shib5888d22014-05-26 07:35:22 -0700271BOOST_AUTO_TEST_CASE(Enumerate)
272{
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000273 sc.insert("/", strategyNameP);
274 sc.insert("/A/B", strategyNameQ);
275 sc.insert("/A/B/C", strategyNameP);
276 sc.insert("/D", strategyNameP);
277 sc.insert("/E", strategyNameQ);
Junxiao Shib5888d22014-05-26 07:35:22 -0700278
Junxiao Shi18739c42016-12-22 08:03:00 +0000279 BOOST_CHECK_EQUAL(sc.size(), 5);
Junxiao Shib5888d22014-05-26 07:35:22 -0700280
281 std::map<Name, Name> map; // namespace=>strategyName
Junxiao Shi18739c42016-12-22 08:03:00 +0000282 for (StrategyChoice::const_iterator it = sc.begin(); it != sc.end(); ++it) {
Junxiao Shi4cb74312016-12-25 20:48:47 +0000283 map[it->getPrefix()] = it->getStrategyInstanceName();
Junxiao Shib5888d22014-05-26 07:35:22 -0700284 }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000285
286 BOOST_CHECK_EQUAL(map.at("/"), strategyNameP);
287 BOOST_CHECK_EQUAL(map.at("/A/B"), strategyNameQ);
288 BOOST_CHECK_EQUAL(map.at("/A/B/C"), strategyNameP);
289 BOOST_CHECK_EQUAL(map.at("/D"), strategyNameP);
290 BOOST_CHECK_EQUAL(map.at("/E"), strategyNameQ);
Junxiao Shib5888d22014-05-26 07:35:22 -0700291 BOOST_CHECK_EQUAL(map.size(), 5);
292}
293
Junxiao Shie349ea12014-03-12 01:32:42 -0700294class PStrategyInfo : public fw::StrategyInfo
295{
Junxiao Shi39ef2612014-11-29 20:35:19 -0700296public:
297 static constexpr int
298 getTypeId()
299 {
300 return 10;
301 }
Junxiao Shie349ea12014-03-12 01:32:42 -0700302};
303
304BOOST_AUTO_TEST_CASE(ClearStrategyInfo)
305{
Junxiao Shie349ea12014-03-12 01:32:42 -0700306 Measurements& measurements = forwarder.getMeasurements();
307
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000308 BOOST_CHECK(sc.insert("/", strategyNameP));
Junxiao Shie349ea12014-03-12 01:32:42 -0700309 // { '/'=>P }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000310 measurements.get("/").insertStrategyInfo<PStrategyInfo>();
311 measurements.get("/A").insertStrategyInfo<PStrategyInfo>();
312 measurements.get("/A/B").insertStrategyInfo<PStrategyInfo>();
313 measurements.get("/A/C").insertStrategyInfo<PStrategyInfo>();
Junxiao Shie349ea12014-03-12 01:32:42 -0700314
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000315 BOOST_CHECK(sc.insert("/A/B", strategyNameP));
Junxiao Shie349ea12014-03-12 01:32:42 -0700316 // { '/'=>P, '/A/B'=>P }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000317 BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr);
318 BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() != nullptr);
Junxiao Shi55e21b92017-01-23 03:27:47 +0000319 BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() != nullptr);
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000320 BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() != nullptr);
Junxiao Shie349ea12014-03-12 01:32:42 -0700321
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000322 BOOST_CHECK(sc.insert("/A", strategyNameQ));
Junxiao Shie349ea12014-03-12 01:32:42 -0700323 // { '/'=>P, '/A/B'=>P, '/A'=>Q }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000324 BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr);
325 BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() == nullptr);
Junxiao Shi55e21b92017-01-23 03:27:47 +0000326 BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() != nullptr);
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000327 BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() == nullptr);
Junxiao Shie349ea12014-03-12 01:32:42 -0700328
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000329 sc.erase("/A/B");
Junxiao Shie349ea12014-03-12 01:32:42 -0700330 // { '/'=>P, '/A'=>Q }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000331 BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr);
332 BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() == nullptr);
333 BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() == nullptr);
334 BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() == nullptr);
Junxiao Shie93d6a32014-09-07 16:13:22 -0700335}
336
Junxiao Shi4370fde2016-02-24 12:20:46 -0700337BOOST_AUTO_TEST_SUITE_END() // TestStrategyChoice
338BOOST_AUTO_TEST_SUITE_END() // Table
Junxiao Shibb5105f2014-03-03 12:06:45 -0700339
340} // namespace tests
341} // namespace nfd