Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014-2016, Regents of the University of California, |
Spyridon Mastorakis | d0381c0 | 2015-02-19 10:29:41 -0800 | [diff] [blame] | 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. |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 10 | * |
| 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 Shi | ee5a444 | 2014-07-27 17:13:43 -0700 | [diff] [blame] | 24 | */ |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 25 | |
| 26 | #include "table/strategy-choice.hpp" |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 27 | |
| 28 | #include "tests/test-common.hpp" |
Junxiao Shi | a49a1ab | 2016-07-15 18:24:36 +0000 | [diff] [blame] | 29 | #include "../fw/dummy-strategy.hpp" |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 30 | |
| 31 | namespace nfd { |
| 32 | namespace tests { |
| 33 | |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 34 | class StrategyChoiceFixture : public BaseFixture |
| 35 | { |
| 36 | protected: |
| 37 | StrategyChoiceFixture() |
| 38 | : sc(forwarder.getStrategyChoice()) |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 39 | , strategyNameP("/strategy-choice-P/%FD%00") |
| 40 | , strategyNameQ("/strategy-choice-Q/%FD%00") |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 41 | { |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 42 | DummyStrategy::registerAs(strategyNameP); |
| 43 | DummyStrategy::registerAs(strategyNameQ); |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | Name |
| 47 | insertAndGet(const Name& prefix, const Name& strategyName) |
| 48 | { |
| 49 | BOOST_REQUIRE(sc.insert(prefix, strategyName)); |
| 50 | bool isFound; |
| 51 | Name foundName; |
| 52 | std::tie(isFound, foundName) = sc.get(prefix); |
| 53 | BOOST_REQUIRE(isFound); |
| 54 | return foundName; |
| 55 | } |
| 56 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 57 | template<typename Q> |
| 58 | Name |
| 59 | findInstanceName(const Q& query) |
| 60 | { |
| 61 | return sc.findEffectiveStrategy(query).getInstanceName(); |
| 62 | } |
| 63 | |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 64 | protected: |
| 65 | Forwarder forwarder; |
| 66 | StrategyChoice& sc; |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 67 | |
| 68 | const Name strategyNameP; |
| 69 | const Name strategyNameQ; |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 70 | }; |
| 71 | |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 72 | BOOST_AUTO_TEST_SUITE(Table) |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 73 | BOOST_FIXTURE_TEST_SUITE(TestStrategyChoice, StrategyChoiceFixture) |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 74 | |
| 75 | using fw::Strategy; |
| 76 | |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 77 | BOOST_AUTO_TEST_CASE(Parameters) |
| 78 | { |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 79 | // no parameters |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 80 | BOOST_CHECK_EQUAL(this->insertAndGet("/A", strategyNameP), strategyNameP); |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 81 | |
| 82 | // one parameter |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 83 | Name oneParamName = Name(strategyNameP).append("param"); |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 84 | BOOST_CHECK_EQUAL(this->insertAndGet("/B", oneParamName), oneParamName); |
| 85 | |
| 86 | // two parameters |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 87 | Name twoParamName = Name(strategyNameP).append("x").append("y"); |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 88 | BOOST_CHECK_EQUAL(this->insertAndGet("/C", twoParamName), twoParamName); |
| 89 | |
| 90 | // parameter without version is disallowed |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 91 | Name oneParamUnversioned = strategyNameP.getPrefix(-1).append("param"); |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 92 | BOOST_CHECK_EQUAL(sc.insert("/D", oneParamUnversioned), false); |
| 93 | } |
| 94 | |
Steve DiBenedetto | 77c8751 | 2014-10-06 14:18:22 -0600 | [diff] [blame] | 95 | BOOST_AUTO_TEST_CASE(Get) |
| 96 | { |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 97 | BOOST_CHECK(sc.insert("/", strategyNameP)); |
Steve DiBenedetto | 77c8751 | 2014-10-06 14:18:22 -0600 | [diff] [blame] | 98 | // { '/'=>P } |
| 99 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 100 | auto getRoot = sc.get("/"); |
Junxiao Shi | 838c4f1 | 2014-11-03 18:55:24 -0700 | [diff] [blame] | 101 | BOOST_CHECK_EQUAL(getRoot.first, true); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 102 | BOOST_CHECK_EQUAL(getRoot.second, strategyNameP); |
Junxiao Shi | 838c4f1 | 2014-11-03 18:55:24 -0700 | [diff] [blame] | 103 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 104 | auto getA = sc.get("/A"); |
Junxiao Shi | 838c4f1 | 2014-11-03 18:55:24 -0700 | [diff] [blame] | 105 | BOOST_CHECK_EQUAL(getA.first, false); |
Steve DiBenedetto | 77c8751 | 2014-10-06 14:18:22 -0600 | [diff] [blame] | 106 | } |
| 107 | |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 108 | BOOST_AUTO_TEST_CASE(FindEffectiveStrategy) |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 109 | { |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 110 | const Name strategyNameZ("/strategy-choice-Z/%FD%00"); // unregistered strategyName |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 111 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 112 | BOOST_CHECK(sc.insert("/", strategyNameP)); |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 113 | // { '/'=>P } |
| 114 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 115 | BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP); |
| 116 | BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP); |
| 117 | BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP); |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 118 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 119 | BOOST_CHECK(sc.insert("/A/B", strategyNameP)); |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 120 | // { '/'=>P, '/A/B'=>P } |
| 121 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 122 | BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP); |
| 123 | BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP); |
| 124 | BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP); |
| 125 | // same entry, same instance |
| 126 | BOOST_CHECK_EQUAL(&sc.findEffectiveStrategy("/"), &sc.findEffectiveStrategy("/A")); |
| 127 | // different entries, distinct instances |
| 128 | BOOST_CHECK_NE(&sc.findEffectiveStrategy("/"), &sc.findEffectiveStrategy("/A/B")); |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 129 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 130 | sc.erase("/A"); // no effect |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 131 | // { '/'=>P, '/A/B'=>P } |
| 132 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 133 | BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP); |
| 134 | BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP); |
| 135 | BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP); |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 136 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 137 | BOOST_CHECK(sc.insert("/A", strategyNameQ)); |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 138 | // { '/'=>P, '/A/B'=>P, '/A'=>Q } |
| 139 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 140 | BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP); |
| 141 | BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameQ); |
| 142 | BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP); |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 143 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 144 | sc.erase("/A/B"); |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 145 | // { '/'=>P, '/A'=>Q } |
| 146 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 147 | BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP); |
| 148 | BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameQ); |
| 149 | BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameQ); |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 150 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 151 | BOOST_CHECK(!sc.insert("/", strategyNameZ)); // non existent strategy |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 152 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 153 | BOOST_CHECK(sc.insert("/", strategyNameQ)); |
| 154 | BOOST_CHECK(sc.insert("/A", strategyNameP)); |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 155 | // { '/'=>Q, '/A'=>P } |
| 156 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 157 | BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameQ); |
| 158 | BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP); |
| 159 | BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP); |
| 160 | BOOST_CHECK_EQUAL(this->findInstanceName("/D"), strategyNameQ); |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 163 | BOOST_AUTO_TEST_CASE(FindEffectiveStrategyWithPitEntry) |
| 164 | { |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 165 | shared_ptr<Data> dataABC = makeData("/A/B/C"); |
| 166 | Name fullName = dataABC->getFullName(); |
| 167 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 168 | BOOST_CHECK(sc.insert("/A", strategyNameP)); |
| 169 | BOOST_CHECK(sc.insert(fullName, strategyNameQ)); |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 170 | |
| 171 | Pit& pit = forwarder.getPit(); |
| 172 | shared_ptr<Interest> interestAB = makeInterest("/A/B"); |
| 173 | shared_ptr<pit::Entry> pitAB = pit.insert(*interestAB).first; |
| 174 | shared_ptr<Interest> interestFull = makeInterest(fullName); |
| 175 | shared_ptr<pit::Entry> pitFull = pit.insert(*interestFull).first; |
| 176 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 177 | BOOST_CHECK_EQUAL(this->findInstanceName(*pitAB), strategyNameP); |
| 178 | BOOST_CHECK_EQUAL(this->findInstanceName(*pitFull), strategyNameQ); |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | BOOST_AUTO_TEST_CASE(FindEffectiveStrategyWithMeasurementsEntry) |
| 182 | { |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 183 | BOOST_CHECK(sc.insert("/A", strategyNameP)); |
| 184 | BOOST_CHECK(sc.insert("/A/B/C", strategyNameQ)); |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 185 | |
| 186 | Measurements& measurements = forwarder.getMeasurements(); |
Junxiao Shi | 80f9fcd | 2016-07-23 02:48:36 +0000 | [diff] [blame] | 187 | measurements::Entry& mAB = measurements.get("/A/B"); |
| 188 | measurements::Entry& mABCD = measurements.get("/A/B/C/D"); |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 189 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 190 | BOOST_CHECK_EQUAL(this->findInstanceName(mAB), strategyNameP); |
| 191 | BOOST_CHECK_EQUAL(this->findInstanceName(mABCD), strategyNameQ); |
| 192 | } |
| 193 | |
| 194 | BOOST_AUTO_TEST_CASE(Erase) |
| 195 | { |
| 196 | NameTree& nameTree = forwarder.getNameTree(); |
| 197 | |
| 198 | sc.insert("/", strategyNameP); |
| 199 | |
| 200 | size_t nNameTreeEntriesBefore = nameTree.size(); |
| 201 | |
| 202 | sc.insert("/A/B", strategyNameQ); |
| 203 | sc.erase("/A/B"); |
| 204 | BOOST_CHECK_EQUAL(nameTree.size(), nNameTreeEntriesBefore); |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 205 | } |
| 206 | |
Junxiao Shi | b5888d2 | 2014-05-26 07:35:22 -0700 | [diff] [blame] | 207 | BOOST_AUTO_TEST_CASE(Enumerate) |
| 208 | { |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 209 | sc.insert("/", strategyNameP); |
| 210 | sc.insert("/A/B", strategyNameQ); |
| 211 | sc.insert("/A/B/C", strategyNameP); |
| 212 | sc.insert("/D", strategyNameP); |
| 213 | sc.insert("/E", strategyNameQ); |
Junxiao Shi | b5888d2 | 2014-05-26 07:35:22 -0700 | [diff] [blame] | 214 | |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 215 | BOOST_CHECK_EQUAL(sc.size(), 5); |
Junxiao Shi | b5888d2 | 2014-05-26 07:35:22 -0700 | [diff] [blame] | 216 | |
| 217 | std::map<Name, Name> map; // namespace=>strategyName |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 218 | for (StrategyChoice::const_iterator it = sc.begin(); it != sc.end(); ++it) { |
Junxiao Shi | 4cb7431 | 2016-12-25 20:48:47 +0000 | [diff] [blame] | 219 | map[it->getPrefix()] = it->getStrategyInstanceName(); |
Junxiao Shi | b5888d2 | 2014-05-26 07:35:22 -0700 | [diff] [blame] | 220 | } |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 221 | |
| 222 | BOOST_CHECK_EQUAL(map.at("/"), strategyNameP); |
| 223 | BOOST_CHECK_EQUAL(map.at("/A/B"), strategyNameQ); |
| 224 | BOOST_CHECK_EQUAL(map.at("/A/B/C"), strategyNameP); |
| 225 | BOOST_CHECK_EQUAL(map.at("/D"), strategyNameP); |
| 226 | BOOST_CHECK_EQUAL(map.at("/E"), strategyNameQ); |
Junxiao Shi | b5888d2 | 2014-05-26 07:35:22 -0700 | [diff] [blame] | 227 | BOOST_CHECK_EQUAL(map.size(), 5); |
| 228 | } |
| 229 | |
Junxiao Shi | e349ea1 | 2014-03-12 01:32:42 -0700 | [diff] [blame] | 230 | class PStrategyInfo : public fw::StrategyInfo |
| 231 | { |
Junxiao Shi | 39ef261 | 2014-11-29 20:35:19 -0700 | [diff] [blame] | 232 | public: |
| 233 | static constexpr int |
| 234 | getTypeId() |
| 235 | { |
| 236 | return 10; |
| 237 | } |
Junxiao Shi | e349ea1 | 2014-03-12 01:32:42 -0700 | [diff] [blame] | 238 | }; |
| 239 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 240 | BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(ClearStrategyInfo, 2) |
Junxiao Shi | e349ea1 | 2014-03-12 01:32:42 -0700 | [diff] [blame] | 241 | BOOST_AUTO_TEST_CASE(ClearStrategyInfo) |
| 242 | { |
Junxiao Shi | e349ea1 | 2014-03-12 01:32:42 -0700 | [diff] [blame] | 243 | Measurements& measurements = forwarder.getMeasurements(); |
| 244 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 245 | BOOST_CHECK(sc.insert("/", strategyNameP)); |
Junxiao Shi | e349ea1 | 2014-03-12 01:32:42 -0700 | [diff] [blame] | 246 | // { '/'=>P } |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 247 | measurements.get("/").insertStrategyInfo<PStrategyInfo>(); |
| 248 | measurements.get("/A").insertStrategyInfo<PStrategyInfo>(); |
| 249 | measurements.get("/A/B").insertStrategyInfo<PStrategyInfo>(); |
| 250 | measurements.get("/A/C").insertStrategyInfo<PStrategyInfo>(); |
Junxiao Shi | e349ea1 | 2014-03-12 01:32:42 -0700 | [diff] [blame] | 251 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 252 | BOOST_CHECK(sc.insert("/A/B", strategyNameP)); |
Junxiao Shi | e349ea1 | 2014-03-12 01:32:42 -0700 | [diff] [blame] | 253 | // { '/'=>P, '/A/B'=>P } |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 254 | BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr); |
| 255 | BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() != nullptr); |
| 256 | BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() != nullptr); // expected failure |
| 257 | BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() != nullptr); |
Junxiao Shi | e349ea1 | 2014-03-12 01:32:42 -0700 | [diff] [blame] | 258 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 259 | BOOST_CHECK(sc.insert("/A", strategyNameQ)); |
Junxiao Shi | e349ea1 | 2014-03-12 01:32:42 -0700 | [diff] [blame] | 260 | // { '/'=>P, '/A/B'=>P, '/A'=>Q } |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 261 | BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr); |
| 262 | BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() == nullptr); |
| 263 | BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() != nullptr); // expected failure |
| 264 | BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() == nullptr); |
Junxiao Shi | e349ea1 | 2014-03-12 01:32:42 -0700 | [diff] [blame] | 265 | |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 266 | sc.erase("/A/B"); |
Junxiao Shi | e349ea1 | 2014-03-12 01:32:42 -0700 | [diff] [blame] | 267 | // { '/'=>P, '/A'=>Q } |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 268 | BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr); |
| 269 | BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() == nullptr); |
| 270 | BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() == nullptr); |
| 271 | BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() == nullptr); |
Junxiao Shi | e93d6a3 | 2014-09-07 16:13:22 -0700 | [diff] [blame] | 272 | } |
| 273 | |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 274 | BOOST_AUTO_TEST_SUITE_END() // TestStrategyChoice |
| 275 | BOOST_AUTO_TEST_SUITE_END() // Table |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 276 | |
| 277 | } // namespace tests |
| 278 | } // namespace nfd |