blob: 339903e631a2d767c21d32f5ce6945ce1584c4bf [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()
39 : sc(forwarder.getStrategyChoice())
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000040 , strategyNameP("/strategy-choice-P/%FD%00")
41 , strategyNameQ("/strategy-choice-Q/%FD%00")
Junxiao Shi18739c42016-12-22 08:03:00 +000042 {
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000043 DummyStrategy::registerAs(strategyNameP);
44 DummyStrategy::registerAs(strategyNameQ);
Junxiao Shi18739c42016-12-22 08:03:00 +000045 }
46
Junxiao Shi91f6ee02016-12-29 21:44:44 +000047 /** \brief insert StrategyChoice entry at \p prefix for \p instanceName
48 * \return constructed instance name
49 */
Junxiao Shi18739c42016-12-22 08:03:00 +000050 Name
Junxiao Shi91f6ee02016-12-29 21:44:44 +000051 insertAndGet(const Name& prefix, const Name& instanceName)
Junxiao Shi18739c42016-12-22 08:03:00 +000052 {
Junxiao Shi91f6ee02016-12-29 21:44:44 +000053 BOOST_REQUIRE(sc.insert(prefix, instanceName));
Junxiao Shi18739c42016-12-22 08:03:00 +000054 bool isFound;
55 Name foundName;
56 std::tie(isFound, foundName) = sc.get(prefix);
57 BOOST_REQUIRE(isFound);
58 return foundName;
59 }
60
Junxiao Shi91f6ee02016-12-29 21:44:44 +000061 /** \brief determine whether the effective strategy type at \p prefix is \p S
62 * \tparam S expected strategy type
63 */
64 template<typename S>
65 bool
66 isStrategyType(const Name& prefix)
67 {
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040068 auto& effectiveStrategy = sc.findEffectiveStrategy(prefix);
Junxiao Shi91f6ee02016-12-29 21:44:44 +000069 return dynamic_cast<S*>(&effectiveStrategy) != nullptr;
70 }
71
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000072 template<typename Q>
73 Name
74 findInstanceName(const Q& query)
75 {
76 return sc.findEffectiveStrategy(query).getInstanceName();
77 }
78
Junxiao Shi18739c42016-12-22 08:03:00 +000079protected:
80 Forwarder forwarder;
81 StrategyChoice& sc;
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000082
83 const Name strategyNameP;
84 const Name strategyNameQ;
Junxiao Shi18739c42016-12-22 08:03:00 +000085};
86
Junxiao Shi4370fde2016-02-24 12:20:46 -070087BOOST_AUTO_TEST_SUITE(Table)
Junxiao Shi18739c42016-12-22 08:03:00 +000088BOOST_FIXTURE_TEST_SUITE(TestStrategyChoice, StrategyChoiceFixture)
Junxiao Shibb5105f2014-03-03 12:06:45 -070089
Junxiao Shi7f566dd2016-12-27 02:28:31 +000090BOOST_AUTO_TEST_CASE(Versioning)
91{
92 const Name strategyNameV("/strategy-choice-V");
93 const Name strategyNameV0("/strategy-choice-V/%FD%00");
94 const Name strategyNameV1("/strategy-choice-V/%FD%01");
95 const Name strategyNameV2("/strategy-choice-V/%FD%02");
96 const Name strategyNameV3("/strategy-choice-V/%FD%03");
97 const Name strategyNameV4("/strategy-choice-V/%FD%04");
98 const Name strategyNameV5("/strategy-choice-V/%FD%05");
99
100 VersionedDummyStrategy<1>::registerAs(strategyNameV1);
101 VersionedDummyStrategy<3>::registerAs(strategyNameV3);
102 VersionedDummyStrategy<4>::registerAs(strategyNameV4);
103
104 // unversioned: choose latest version
105 BOOST_CHECK_EQUAL(this->insertAndGet("/A", strategyNameV), strategyNameV4);
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000106 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<4>>("/A"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000107
108 // exact version: choose same version
109 BOOST_CHECK_EQUAL(this->insertAndGet("/B", strategyNameV1), strategyNameV1);
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000110 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<1>>("/B"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000111 BOOST_CHECK_EQUAL(this->insertAndGet("/C", strategyNameV3), strategyNameV3);
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000112 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<3>>("/C"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000113 BOOST_CHECK_EQUAL(this->insertAndGet("/D", strategyNameV4), strategyNameV4);
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000114 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<4>>("/D"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000115
116 // lower version: choose next higher version
Junxiao Shi91f6ee02016-12-29 21:44:44 +0000117 BOOST_CHECK_EQUAL(this->insertAndGet("/E", strategyNameV0), strategyNameV0);
118 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<1>>("/E"));
119 BOOST_CHECK_EQUAL(this->insertAndGet("/F", strategyNameV2), strategyNameV2);
120 BOOST_CHECK(this->isStrategyType<VersionedDummyStrategy<3>>("/F"));
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000121
122 // higher version: failure
Junxiao Shi530cf002017-01-03 14:43:16 +0000123 StrategyChoice::InsertResult res5 = sc.insert("/G", strategyNameV5);
124 BOOST_CHECK(!res5);
125 BOOST_CHECK(!res5.isRegistered());
Junxiao Shi7f566dd2016-12-27 02:28:31 +0000126}
127
Junxiao Shi18739c42016-12-22 08:03:00 +0000128BOOST_AUTO_TEST_CASE(Parameters)
129{
Junxiao Shi18739c42016-12-22 08:03:00 +0000130 // no parameters
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000131 BOOST_CHECK_EQUAL(this->insertAndGet("/A", strategyNameP), strategyNameP);
Junxiao Shi18739c42016-12-22 08:03:00 +0000132
133 // one parameter
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000134 Name oneParamName = Name(strategyNameP).append("param");
Junxiao Shi18739c42016-12-22 08:03:00 +0000135 BOOST_CHECK_EQUAL(this->insertAndGet("/B", oneParamName), oneParamName);
136
137 // two parameters
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000138 Name twoParamName = Name(strategyNameP).append("x").append("y");
Junxiao Shi18739c42016-12-22 08:03:00 +0000139 BOOST_CHECK_EQUAL(this->insertAndGet("/C", twoParamName), twoParamName);
140
141 // parameter without version is disallowed
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000142 Name oneParamUnversioned = strategyNameP.getPrefix(-1).append("param");
Junxiao Shi530cf002017-01-03 14:43:16 +0000143 BOOST_CHECK(!sc.insert("/D", oneParamUnversioned));
Junxiao Shi18739c42016-12-22 08:03:00 +0000144}
145
Junxiao Shi4e837f82017-10-02 22:14:43 +0000146BOOST_AUTO_TEST_CASE(InsertLongName)
147{
148 Name n1;
149 while (n1.size() < NameTree::getMaxDepth()) {
150 n1.append("A");
151 }
152 Name n2 = n1;
153 while (n2.size() < NameTree::getMaxDepth() * 2) {
154 n2.append("B");
155 }
156
157 BOOST_CHECK(sc.insert(n1, strategyNameP));
158 BOOST_CHECK(!sc.insert(n2, strategyNameP));
159}
160
Steve DiBenedetto77c87512014-10-06 14:18:22 -0600161BOOST_AUTO_TEST_CASE(Get)
162{
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000163 BOOST_CHECK(sc.insert("/", strategyNameP));
Steve DiBenedetto77c87512014-10-06 14:18:22 -0600164 // { '/'=>P }
165
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000166 auto getRoot = sc.get("/");
Junxiao Shi838c4f12014-11-03 18:55:24 -0700167 BOOST_CHECK_EQUAL(getRoot.first, true);
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000168 BOOST_CHECK_EQUAL(getRoot.second, strategyNameP);
Junxiao Shi838c4f12014-11-03 18:55:24 -0700169
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000170 auto getA = sc.get("/A");
Junxiao Shi838c4f12014-11-03 18:55:24 -0700171 BOOST_CHECK_EQUAL(getA.first, false);
Steve DiBenedetto77c87512014-10-06 14:18:22 -0600172}
173
Junxiao Shi4370fde2016-02-24 12:20:46 -0700174BOOST_AUTO_TEST_CASE(FindEffectiveStrategy)
Junxiao Shibb5105f2014-03-03 12:06:45 -0700175{
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000176 const Name strategyNameZ("/strategy-choice-Z/%FD%00"); // unregistered strategyName
Junxiao Shibb5105f2014-03-03 12:06:45 -0700177
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000178 BOOST_CHECK(sc.insert("/", strategyNameP));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700179 // { '/'=>P }
180
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000181 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
182 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
183 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700184
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000185 BOOST_CHECK(sc.insert("/A/B", strategyNameP));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700186 // { '/'=>P, '/A/B'=>P }
187
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000188 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
189 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
190 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
191 // same entry, same instance
192 BOOST_CHECK_EQUAL(&sc.findEffectiveStrategy("/"), &sc.findEffectiveStrategy("/A"));
193 // different entries, distinct instances
194 BOOST_CHECK_NE(&sc.findEffectiveStrategy("/"), &sc.findEffectiveStrategy("/A/B"));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700195
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000196 sc.erase("/A"); // no effect
Junxiao Shibb5105f2014-03-03 12:06:45 -0700197 // { '/'=>P, '/A/B'=>P }
198
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000199 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
200 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
201 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700202
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000203 BOOST_CHECK(sc.insert("/A", strategyNameQ));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700204 // { '/'=>P, '/A/B'=>P, '/A'=>Q }
205
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000206 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
207 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameQ);
208 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700209
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000210 sc.erase("/A/B");
Junxiao Shibb5105f2014-03-03 12:06:45 -0700211 // { '/'=>P, '/A'=>Q }
212
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000213 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
214 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameQ);
215 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameQ);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700216
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000217 BOOST_CHECK(!sc.insert("/", strategyNameZ)); // non existent strategy
Junxiao Shibb5105f2014-03-03 12:06:45 -0700218
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000219 BOOST_CHECK(sc.insert("/", strategyNameQ));
220 BOOST_CHECK(sc.insert("/A", strategyNameP));
Junxiao Shibb5105f2014-03-03 12:06:45 -0700221 // { '/'=>Q, '/A'=>P }
222
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000223 BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameQ);
224 BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
225 BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
226 BOOST_CHECK_EQUAL(this->findInstanceName("/D"), strategyNameQ);
Junxiao Shibb5105f2014-03-03 12:06:45 -0700227}
228
Junxiao Shi4370fde2016-02-24 12:20:46 -0700229BOOST_AUTO_TEST_CASE(FindEffectiveStrategyWithPitEntry)
230{
Junxiao Shi4370fde2016-02-24 12:20:46 -0700231 shared_ptr<Data> dataABC = makeData("/A/B/C");
232 Name fullName = dataABC->getFullName();
233
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000234 BOOST_CHECK(sc.insert("/A", strategyNameP));
235 BOOST_CHECK(sc.insert(fullName, strategyNameQ));
Junxiao Shi4370fde2016-02-24 12:20:46 -0700236
237 Pit& pit = forwarder.getPit();
238 shared_ptr<Interest> interestAB = makeInterest("/A/B");
239 shared_ptr<pit::Entry> pitAB = pit.insert(*interestAB).first;
240 shared_ptr<Interest> interestFull = makeInterest(fullName);
241 shared_ptr<pit::Entry> pitFull = pit.insert(*interestFull).first;
242
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000243 BOOST_CHECK_EQUAL(this->findInstanceName(*pitAB), strategyNameP);
244 BOOST_CHECK_EQUAL(this->findInstanceName(*pitFull), strategyNameQ);
Junxiao Shi4370fde2016-02-24 12:20:46 -0700245}
246
247BOOST_AUTO_TEST_CASE(FindEffectiveStrategyWithMeasurementsEntry)
248{
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000249 BOOST_CHECK(sc.insert("/A", strategyNameP));
250 BOOST_CHECK(sc.insert("/A/B/C", strategyNameQ));
Junxiao Shi4370fde2016-02-24 12:20:46 -0700251
252 Measurements& measurements = forwarder.getMeasurements();
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000253 measurements::Entry& mAB = measurements.get("/A/B");
254 measurements::Entry& mABCD = measurements.get("/A/B/C/D");
Junxiao Shi4370fde2016-02-24 12:20:46 -0700255
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000256 BOOST_CHECK_EQUAL(this->findInstanceName(mAB), strategyNameP);
257 BOOST_CHECK_EQUAL(this->findInstanceName(mABCD), strategyNameQ);
258}
259
260BOOST_AUTO_TEST_CASE(Erase)
261{
262 NameTree& nameTree = forwarder.getNameTree();
263
264 sc.insert("/", strategyNameP);
265
266 size_t nNameTreeEntriesBefore = nameTree.size();
267
268 sc.insert("/A/B", strategyNameQ);
269 sc.erase("/A/B");
270 BOOST_CHECK_EQUAL(nameTree.size(), nNameTreeEntriesBefore);
Junxiao Shi4370fde2016-02-24 12:20:46 -0700271}
272
Junxiao Shib5888d22014-05-26 07:35:22 -0700273BOOST_AUTO_TEST_CASE(Enumerate)
274{
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000275 sc.insert("/", strategyNameP);
276 sc.insert("/A/B", strategyNameQ);
277 sc.insert("/A/B/C", strategyNameP);
278 sc.insert("/D", strategyNameP);
279 sc.insert("/E", strategyNameQ);
Junxiao Shib5888d22014-05-26 07:35:22 -0700280
Junxiao Shi18739c42016-12-22 08:03:00 +0000281 BOOST_CHECK_EQUAL(sc.size(), 5);
Junxiao Shib5888d22014-05-26 07:35:22 -0700282
283 std::map<Name, Name> map; // namespace=>strategyName
Junxiao Shi18739c42016-12-22 08:03:00 +0000284 for (StrategyChoice::const_iterator it = sc.begin(); it != sc.end(); ++it) {
Junxiao Shi4cb74312016-12-25 20:48:47 +0000285 map[it->getPrefix()] = it->getStrategyInstanceName();
Junxiao Shib5888d22014-05-26 07:35:22 -0700286 }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000287
288 BOOST_CHECK_EQUAL(map.at("/"), strategyNameP);
289 BOOST_CHECK_EQUAL(map.at("/A/B"), strategyNameQ);
290 BOOST_CHECK_EQUAL(map.at("/A/B/C"), strategyNameP);
291 BOOST_CHECK_EQUAL(map.at("/D"), strategyNameP);
292 BOOST_CHECK_EQUAL(map.at("/E"), strategyNameQ);
Junxiao Shib5888d22014-05-26 07:35:22 -0700293 BOOST_CHECK_EQUAL(map.size(), 5);
294}
295
Junxiao Shie349ea12014-03-12 01:32:42 -0700296class PStrategyInfo : public fw::StrategyInfo
297{
Junxiao Shi39ef2612014-11-29 20:35:19 -0700298public:
299 static constexpr int
300 getTypeId()
301 {
302 return 10;
303 }
Junxiao Shie349ea12014-03-12 01:32:42 -0700304};
305
306BOOST_AUTO_TEST_CASE(ClearStrategyInfo)
307{
Junxiao Shie349ea12014-03-12 01:32:42 -0700308 Measurements& measurements = forwarder.getMeasurements();
309
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000310 BOOST_CHECK(sc.insert("/", strategyNameP));
Junxiao Shie349ea12014-03-12 01:32:42 -0700311 // { '/'=>P }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000312 measurements.get("/").insertStrategyInfo<PStrategyInfo>();
313 measurements.get("/A").insertStrategyInfo<PStrategyInfo>();
314 measurements.get("/A/B").insertStrategyInfo<PStrategyInfo>();
315 measurements.get("/A/C").insertStrategyInfo<PStrategyInfo>();
Junxiao Shie349ea12014-03-12 01:32:42 -0700316
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000317 BOOST_CHECK(sc.insert("/A/B", strategyNameP));
Junxiao Shie349ea12014-03-12 01:32:42 -0700318 // { '/'=>P, '/A/B'=>P }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000319 BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr);
320 BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() != nullptr);
Junxiao Shi55e21b92017-01-23 03:27:47 +0000321 BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() != nullptr);
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000322 BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() != nullptr);
Junxiao Shie349ea12014-03-12 01:32:42 -0700323
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000324 BOOST_CHECK(sc.insert("/A", strategyNameQ));
Junxiao Shie349ea12014-03-12 01:32:42 -0700325 // { '/'=>P, '/A/B'=>P, '/A'=>Q }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000326 BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr);
327 BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() == nullptr);
Junxiao Shi55e21b92017-01-23 03:27:47 +0000328 BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() != nullptr);
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000329 BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() == nullptr);
Junxiao Shie349ea12014-03-12 01:32:42 -0700330
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000331 sc.erase("/A/B");
Junxiao Shie349ea12014-03-12 01:32:42 -0700332 // { '/'=>P, '/A'=>Q }
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000333 BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr);
334 BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() == nullptr);
335 BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() == nullptr);
336 BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() == nullptr);
Junxiao Shie93d6a32014-09-07 16:13:22 -0700337}
338
Junxiao Shi4370fde2016-02-24 12:20:46 -0700339BOOST_AUTO_TEST_SUITE_END() // TestStrategyChoice
340BOOST_AUTO_TEST_SUITE_END() // Table
Junxiao Shibb5105f2014-03-03 12:06:45 -0700341
342} // namespace tests
343} // namespace nfd