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