Junxiao Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | bb6146e | 2017-07-26 23:07:52 +0000 | [diff] [blame] | 2 | /* |
Davide Pesavento | a3a7a4e | 2022-05-29 16:06:22 -0400 | [diff] [blame] | 3 | * Copyright (c) 2014-2022, Regents of the University of California, |
Junxiao Shi | fc20696 | 2015-01-16 11:12:22 -0700 | [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. |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 10 | * |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 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 | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame] | 24 | */ |
Junxiao Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 25 | |
| 26 | #include "table/cs.hpp" |
Alexander Afanasyev | b927a3a | 2014-01-24 10:41:47 -0800 | [diff] [blame] | 27 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 28 | #include "tests/daemon/table/cs-fixture.hpp" |
Alexander Afanasyev | b927a3a | 2014-01-24 10:41:47 -0800 | [diff] [blame] | 29 | |
Junxiao Shi | 4e1b6ee | 2017-08-03 02:20:50 +0000 | [diff] [blame] | 30 | #include <ndn-cxx/lp/tags.hpp> |
Junxiao Shi | 4e1b6ee | 2017-08-03 02:20:50 +0000 | [diff] [blame] | 31 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 32 | namespace nfd::tests { |
Junxiao Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 33 | |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 34 | BOOST_AUTO_TEST_SUITE(Table) |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 35 | BOOST_FIXTURE_TEST_SUITE(TestCs, CsFixture) |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 36 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 37 | BOOST_AUTO_TEST_SUITE(Find) |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 38 | |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame] | 39 | BOOST_AUTO_TEST_CASE(ExactName) |
| 40 | { |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 41 | insert(1, "/"); |
| 42 | insert(2, "/A"); |
| 43 | insert(3, "/A/B"); |
| 44 | insert(4, "/A/C"); |
| 45 | insert(5, "/D"); |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame] | 46 | |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 47 | startInterest("/A"); |
mzhang4 | eab7249 | 2015-02-25 11:16:09 -0600 | [diff] [blame] | 48 | CHECK_CS_FIND(2); |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 51 | BOOST_AUTO_TEST_CASE(ExactName_CanBePrefix) |
| 52 | { |
| 53 | insert(1, "/"); |
| 54 | insert(2, "/A"); |
| 55 | insert(3, "/A/B"); |
| 56 | insert(4, "/A/C"); |
| 57 | insert(5, "/D"); |
| 58 | |
| 59 | startInterest("/A") |
| 60 | .setCanBePrefix(true); |
| 61 | CHECK_CS_FIND(2); |
| 62 | } |
| 63 | |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame] | 64 | BOOST_AUTO_TEST_CASE(FullName) |
| 65 | { |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 66 | Name n1 = insert(1, "/A"); |
| 67 | Name n2 = insert(2, "/A"); |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame] | 68 | |
| 69 | startInterest(n1); |
mzhang4 | eab7249 | 2015-02-25 11:16:09 -0600 | [diff] [blame] | 70 | CHECK_CS_FIND(1); |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame] | 71 | |
| 72 | startInterest(n2); |
mzhang4 | eab7249 | 2015-02-25 11:16:09 -0600 | [diff] [blame] | 73 | CHECK_CS_FIND(2); |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame] | 74 | } |
| 75 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 76 | BOOST_AUTO_TEST_CASE(FullName_EmptyDataName) |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 77 | { |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 78 | Name n1 = insert(1, "/"); |
| 79 | Name n2 = insert(2, "/"); |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 80 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 81 | startInterest(n1); |
| 82 | CHECK_CS_FIND(1); |
| 83 | |
| 84 | startInterest(n2); |
mzhang4 | eab7249 | 2015-02-25 11:16:09 -0600 | [diff] [blame] | 85 | CHECK_CS_FIND(2); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 86 | } |
| 87 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 88 | BOOST_AUTO_TEST_CASE(PrefixName) |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 89 | { |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 90 | insert(1, "/A"); |
| 91 | insert(2, "/B/p/1"); |
| 92 | insert(3, "/B/p/2"); |
| 93 | insert(4, "/B/q/1"); |
| 94 | insert(5, "/B/q/2"); |
| 95 | insert(6, "/C"); |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 96 | |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 97 | startInterest("/B") |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 98 | .setCanBePrefix(true); |
| 99 | CHECK_CS_FIND(2); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 100 | } |
| 101 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 102 | BOOST_AUTO_TEST_CASE(PrefixName_NoCanBePrefix) |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 103 | { |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 104 | insert(1, "/B/p/1"); |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 105 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 106 | startInterest("/B"); |
mzhang4 | eab7249 | 2015-02-25 11:16:09 -0600 | [diff] [blame] | 107 | CHECK_CS_FIND(0); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 108 | } |
| 109 | |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 110 | BOOST_AUTO_TEST_CASE(MustBeFresh) |
| 111 | { |
Eric Newberry | f4056d0 | 2017-05-26 17:31:53 +0000 | [diff] [blame] | 112 | insert(1, "/A/1"); // omitted FreshnessPeriod means FreshnessPeriod = 0 ms |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 113 | insert(2, "/A/2", [] (Data& data) { data.setFreshnessPeriod(0_s); }); |
| 114 | insert(3, "/A/3", [] (Data& data) { data.setFreshnessPeriod(1_s); }); |
| 115 | insert(4, "/A/4", [] (Data& data) { data.setFreshnessPeriod(1_h); }); |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 116 | |
| 117 | // lookup at exact same moment as insertion is not tested because this won't happen in reality |
| 118 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 119 | advanceClocks(500_ms); // @500ms |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 120 | startInterest("/A") |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 121 | .setCanBePrefix(true) |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 122 | .setMustBeFresh(true); |
| 123 | CHECK_CS_FIND(3); |
| 124 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 125 | advanceClocks(1500_ms); // @2s |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 126 | startInterest("/A") |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 127 | .setCanBePrefix(true) |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 128 | .setMustBeFresh(true); |
| 129 | CHECK_CS_FIND(4); |
| 130 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 131 | advanceClocks(3500_s); // @3502s |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 132 | startInterest("/A") |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 133 | .setCanBePrefix(true) |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 134 | .setMustBeFresh(true); |
| 135 | CHECK_CS_FIND(4); |
| 136 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 137 | advanceClocks(3500_s); // @7002s |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 138 | startInterest("/A") |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 139 | .setCanBePrefix(true) |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 140 | .setMustBeFresh(true); |
Eric Newberry | f4056d0 | 2017-05-26 17:31:53 +0000 | [diff] [blame] | 141 | CHECK_CS_FIND(0); |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Minsheng Zhang | ffe8bbb | 2016-03-10 13:40:37 -0700 | [diff] [blame] | 144 | BOOST_AUTO_TEST_SUITE_END() // Find |
| 145 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 146 | BOOST_AUTO_TEST_CASE(Erase) |
Junxiao Shi | 30c37ab | 2018-04-09 14:26:47 +0000 | [diff] [blame] | 147 | { |
| 148 | insert(1, "/A/B/1"); |
| 149 | insert(2, "/A/B/2"); |
| 150 | insert(3, "/A/C/3"); |
| 151 | insert(4, "/A/C/4"); |
| 152 | insert(5, "/D/5"); |
| 153 | insert(6, "/E/6"); |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 154 | BOOST_CHECK_EQUAL(cs.size(), 6); |
Junxiao Shi | 30c37ab | 2018-04-09 14:26:47 +0000 | [diff] [blame] | 155 | |
| 156 | BOOST_CHECK_EQUAL(erase("/A", 3), 3); |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 157 | BOOST_CHECK_EQUAL(cs.size(), 3); |
Junxiao Shi | 30c37ab | 2018-04-09 14:26:47 +0000 | [diff] [blame] | 158 | int nDataUnderA = 0; |
| 159 | startInterest("/A/B/1"); |
| 160 | find([&] (uint32_t found) { nDataUnderA += static_cast<int>(found > 0); }); |
| 161 | startInterest("/A/B/2"); |
| 162 | find([&] (uint32_t found) { nDataUnderA += static_cast<int>(found > 0); }); |
| 163 | startInterest("/A/C/3"); |
| 164 | find([&] (uint32_t found) { nDataUnderA += static_cast<int>(found > 0); }); |
| 165 | startInterest("/A/C/4"); |
| 166 | find([&] (uint32_t found) { nDataUnderA += static_cast<int>(found > 0); }); |
| 167 | BOOST_CHECK_EQUAL(nDataUnderA, 1); |
| 168 | |
| 169 | BOOST_CHECK_EQUAL(erase("/D", 2), 1); |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 170 | BOOST_CHECK_EQUAL(cs.size(), 2); |
Junxiao Shi | 30c37ab | 2018-04-09 14:26:47 +0000 | [diff] [blame] | 171 | startInterest("/D/5"); |
| 172 | CHECK_CS_FIND(0); |
| 173 | |
| 174 | BOOST_CHECK_EQUAL(erase("/F", 2), 0); |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 175 | BOOST_CHECK_EQUAL(cs.size(), 2); |
Junxiao Shi | 30c37ab | 2018-04-09 14:26:47 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Minsheng Zhang | ffe8bbb | 2016-03-10 13:40:37 -0700 | [diff] [blame] | 178 | // When the capacity limit is set to zero, Data cannot be inserted; |
| 179 | // this test case covers this situation. |
| 180 | // The behavior of non-zero capacity limit depends on the eviction policy, |
| 181 | // and is tested in policy test suites. |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 182 | BOOST_AUTO_TEST_CASE(ZeroCapacity) |
Minsheng Zhang | ffe8bbb | 2016-03-10 13:40:37 -0700 | [diff] [blame] | 183 | { |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 184 | cs.setLimit(0); |
Minsheng Zhang | ffe8bbb | 2016-03-10 13:40:37 -0700 | [diff] [blame] | 185 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 186 | BOOST_CHECK_EQUAL(cs.getLimit(), 0); |
| 187 | BOOST_CHECK_EQUAL(cs.size(), 0); |
| 188 | BOOST_CHECK(cs.begin() == cs.end()); |
Minsheng Zhang | ffe8bbb | 2016-03-10 13:40:37 -0700 | [diff] [blame] | 189 | |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 190 | insert(1, "/A"); |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 191 | BOOST_CHECK_EQUAL(cs.size(), 0); |
Minsheng Zhang | ffe8bbb | 2016-03-10 13:40:37 -0700 | [diff] [blame] | 192 | |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 193 | startInterest("/A"); |
Minsheng Zhang | ffe8bbb | 2016-03-10 13:40:37 -0700 | [diff] [blame] | 194 | CHECK_CS_FIND(0); |
| 195 | } |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame] | 196 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 197 | BOOST_AUTO_TEST_CASE(EnablementFlags) |
Junxiao Shi | 3d2049f | 2018-01-26 23:46:06 +0000 | [diff] [blame] | 198 | { |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 199 | BOOST_CHECK_EQUAL(cs.shouldAdmit(), true); |
| 200 | BOOST_CHECK_EQUAL(cs.shouldServe(), true); |
Junxiao Shi | 3d2049f | 2018-01-26 23:46:06 +0000 | [diff] [blame] | 201 | |
| 202 | insert(1, "/A"); |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 203 | cs.enableAdmit(false); |
Junxiao Shi | 3d2049f | 2018-01-26 23:46:06 +0000 | [diff] [blame] | 204 | insert(2, "/B"); |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 205 | cs.enableAdmit(true); |
Junxiao Shi | 3d2049f | 2018-01-26 23:46:06 +0000 | [diff] [blame] | 206 | insert(3, "/C"); |
| 207 | |
| 208 | startInterest("/A"); |
| 209 | CHECK_CS_FIND(1); |
| 210 | startInterest("/B"); |
| 211 | CHECK_CS_FIND(0); |
| 212 | startInterest("/C"); |
| 213 | CHECK_CS_FIND(3); |
| 214 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 215 | cs.enableServe(false); |
Junxiao Shi | 3d2049f | 2018-01-26 23:46:06 +0000 | [diff] [blame] | 216 | startInterest("/A"); |
| 217 | CHECK_CS_FIND(0); |
| 218 | startInterest("/C"); |
| 219 | CHECK_CS_FIND(0); |
| 220 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 221 | cs.enableServe(true); |
Junxiao Shi | 3d2049f | 2018-01-26 23:46:06 +0000 | [diff] [blame] | 222 | startInterest("/A"); |
| 223 | CHECK_CS_FIND(1); |
| 224 | startInterest("/C"); |
| 225 | CHECK_CS_FIND(3); |
| 226 | } |
| 227 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 228 | BOOST_AUTO_TEST_CASE(CachePolicyNoCache) |
Junxiao Shi | 35b16b1 | 2015-02-16 22:14:57 -0700 | [diff] [blame] | 229 | { |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 230 | insert(1, "/A", [] (Data& data) { |
| 231 | data.setTag(make_shared<lp::CachePolicyTag>( |
| 232 | lp::CachePolicy().setPolicy(lp::CachePolicyType::NO_CACHE))); |
| 233 | }); |
Junxiao Shi | 35b16b1 | 2015-02-16 22:14:57 -0700 | [diff] [blame] | 234 | |
Junxiao Shi | 1fbdb54 | 2017-02-03 00:05:53 +0000 | [diff] [blame] | 235 | startInterest("/A"); |
| 236 | CHECK_CS_FIND(0); |
Junxiao Shi | 35b16b1 | 2015-02-16 22:14:57 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Junxiao Shi | fc20696 | 2015-01-16 11:12:22 -0700 | [diff] [blame] | 239 | BOOST_AUTO_TEST_CASE(Enumeration) |
| 240 | { |
Junxiao Shi | fc20696 | 2015-01-16 11:12:22 -0700 | [diff] [blame] | 241 | Name nameA("/A"); |
| 242 | Name nameAB("/A/B"); |
| 243 | Name nameABC("/A/B/C"); |
| 244 | Name nameD("/D"); |
| 245 | |
| 246 | BOOST_CHECK_EQUAL(cs.size(), 0); |
| 247 | BOOST_CHECK(cs.begin() == cs.end()); |
| 248 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 249 | insert(123, nameABC); |
Junxiao Shi | fc20696 | 2015-01-16 11:12:22 -0700 | [diff] [blame] | 250 | BOOST_CHECK_EQUAL(cs.size(), 1); |
| 251 | BOOST_CHECK(cs.begin() != cs.end()); |
| 252 | BOOST_CHECK(cs.begin()->getName() == nameABC); |
| 253 | BOOST_CHECK((*cs.begin()).getName() == nameABC); |
| 254 | |
| 255 | auto i = cs.begin(); |
| 256 | auto j = cs.begin(); |
| 257 | BOOST_CHECK(++i == cs.end()); |
| 258 | BOOST_CHECK(j++ == cs.begin()); |
| 259 | BOOST_CHECK(j == cs.end()); |
| 260 | |
Junxiao Shi | 9222f36 | 2019-04-16 15:15:23 +0000 | [diff] [blame] | 261 | insert(1, nameA); |
| 262 | insert(12, nameAB); |
| 263 | insert(4, nameD); |
Junxiao Shi | fc20696 | 2015-01-16 11:12:22 -0700 | [diff] [blame] | 264 | |
Davide Pesavento | a3a7a4e | 2022-05-29 16:06:22 -0400 | [diff] [blame] | 265 | const std::set<Name> expected{nameA, nameAB, nameABC, nameD}; |
Junxiao Shi | fc20696 | 2015-01-16 11:12:22 -0700 | [diff] [blame] | 266 | std::set<Name> actual; |
| 267 | for (const auto& csEntry : cs) { |
| 268 | actual.insert(csEntry.getName()); |
| 269 | } |
Davide Pesavento | a3a7a4e | 2022-05-29 16:06:22 -0400 | [diff] [blame] | 270 | BOOST_TEST(actual == expected, boost::test_tools::per_element()); |
Junxiao Shi | fc20696 | 2015-01-16 11:12:22 -0700 | [diff] [blame] | 271 | } |
| 272 | |
Minsheng Zhang | ffe8bbb | 2016-03-10 13:40:37 -0700 | [diff] [blame] | 273 | BOOST_AUTO_TEST_SUITE_END() // TestCs |
| 274 | BOOST_AUTO_TEST_SUITE_END() // Table |
Alexander Afanasyev | b927a3a | 2014-01-24 10:41:47 -0800 | [diff] [blame] | 275 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 276 | } // namespace nfd::tests |