Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 7c10b3b | 2015-01-20 12:24:27 -0800 | [diff] [blame] | 3 | * Copyright (c) 2014-2015, Regents of the University of California, |
| 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 | 3ecec50 | 2014-04-16 13:42:44 -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/>. |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 24 | */ |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 25 | |
| 26 | #include "rib/rib.hpp" |
| 27 | |
| 28 | #include "tests/test-common.hpp" |
| 29 | |
| 30 | namespace nfd { |
| 31 | namespace rib { |
| 32 | namespace tests { |
| 33 | |
Spyridon Mastorakis | d0381c0 | 2015-02-19 10:29:41 -0800 | [diff] [blame] | 34 | BOOST_FIXTURE_TEST_SUITE(TestRib, nfd::tests::BaseFixture) |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 35 | |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 36 | BOOST_AUTO_TEST_CASE(RibEntry) |
| 37 | { |
| 38 | rib::RibEntry entry; |
| 39 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 40 | rib::Route route1; |
| 41 | route1.faceId = 1; |
| 42 | route1.origin = 0; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 43 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 44 | entry.insertRoute(route1); |
| 45 | BOOST_CHECK_EQUAL(entry.getRoutes().size(), 1); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 46 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 47 | Route route2; |
| 48 | route2.faceId = 1; |
| 49 | route2.origin = 128; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 50 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 51 | entry.insertRoute(route2); |
| 52 | BOOST_CHECK_EQUAL(entry.getRoutes().size(), 2); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 53 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 54 | entry.eraseRoute(route1); |
| 55 | BOOST_CHECK_EQUAL(entry.getRoutes().size(), 1); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 56 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 57 | BOOST_CHECK(entry.findRoute(route1) == entry.getRoutes().end()); |
| 58 | BOOST_CHECK(entry.findRoute(route2) != entry.getRoutes().end()); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 59 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 60 | entry.insertRoute(route2); |
| 61 | BOOST_CHECK_EQUAL(entry.getRoutes().size(), 1); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 62 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 63 | entry.eraseRoute(route1); |
| 64 | BOOST_CHECK_EQUAL(entry.getRoutes().size(), 1); |
| 65 | BOOST_CHECK(entry.findRoute(route2) != entry.getRoutes().end()); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 66 | } |
| 67 | |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 68 | BOOST_AUTO_TEST_CASE(Parent) |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 69 | { |
| 70 | rib::Rib rib; |
| 71 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 72 | Route root; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 73 | Name name1("/"); |
| 74 | root.faceId = 1; |
| 75 | root.origin = 20; |
| 76 | rib.insert(name1, root); |
| 77 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 78 | Route route1; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 79 | Name name2("/hello"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 80 | route1.faceId = 2; |
| 81 | route1.origin = 20; |
| 82 | rib.insert(name2, route1); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 83 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 84 | Route route2; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 85 | Name name3("/hello/world"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 86 | route2.faceId = 3; |
| 87 | route2.origin = 20; |
| 88 | rib.insert(name3, route2); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 89 | |
| 90 | shared_ptr<rib::RibEntry> ribEntry = rib.findParent(name3); |
| 91 | BOOST_REQUIRE(static_cast<bool>(ribEntry)); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 92 | BOOST_CHECK_EQUAL(ribEntry->getRoutes().front().faceId, 2); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 93 | |
| 94 | ribEntry = rib.findParent(name2); |
| 95 | BOOST_REQUIRE(static_cast<bool>(ribEntry)); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 96 | BOOST_CHECK_EQUAL(ribEntry->getRoutes().front().faceId, 1); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 97 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 98 | Route route3; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 99 | Name name4("/hello/test/foo/bar"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 100 | route2.faceId = 3; |
| 101 | route2.origin = 20; |
| 102 | rib.insert(name4, route3); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 103 | |
| 104 | ribEntry = rib.findParent(name4); |
| 105 | BOOST_CHECK(ribEntry != shared_ptr<rib::RibEntry>()); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 106 | BOOST_CHECK(ribEntry->getRoutes().front().faceId == 2); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 107 | } |
| 108 | |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 109 | BOOST_AUTO_TEST_CASE(Children) |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 110 | { |
| 111 | rib::Rib rib; |
| 112 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 113 | Route route1; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 114 | Name name1("/"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 115 | route1.faceId = 1; |
| 116 | route1.origin = 20; |
| 117 | rib.insert(name1, route1); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 118 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 119 | Route route2; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 120 | Name name2("/hello/world"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 121 | route2.faceId = 2; |
| 122 | route2.origin = 20; |
| 123 | rib.insert(name2, route2); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 124 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 125 | Route route3; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 126 | Name name3("/hello/test/foo/bar"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 127 | route3.faceId = 3; |
| 128 | route3.origin = 20; |
| 129 | rib.insert(name3, route3); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 130 | |
| 131 | BOOST_CHECK_EQUAL((rib.find(name1)->second)->getChildren().size(), 2); |
| 132 | BOOST_CHECK_EQUAL((rib.find(name2)->second)->getChildren().size(), 0); |
| 133 | BOOST_CHECK_EQUAL((rib.find(name3)->second)->getChildren().size(), 0); |
| 134 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 135 | Route entry4; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 136 | Name name4("/hello"); |
| 137 | entry4.faceId = 4; |
| 138 | entry4.origin = 20; |
| 139 | rib.insert(name4, entry4); |
| 140 | |
| 141 | BOOST_CHECK_EQUAL((rib.find(name1)->second)->getChildren().size(), 1); |
| 142 | BOOST_CHECK_EQUAL((rib.find(name2)->second)->getChildren().size(), 0); |
| 143 | BOOST_CHECK_EQUAL((rib.find(name3)->second)->getChildren().size(), 0); |
| 144 | BOOST_CHECK_EQUAL((rib.find(name4)->second)->getChildren().size(), 2); |
| 145 | |
| 146 | BOOST_CHECK_EQUAL((rib.find(name1)->second)->getChildren().front()->getName(), "/hello"); |
| 147 | BOOST_CHECK_EQUAL((rib.find(name4)->second)->getParent()->getName(), "/"); |
| 148 | |
| 149 | BOOST_REQUIRE(static_cast<bool>((rib.find(name2)->second)->getParent())); |
| 150 | BOOST_CHECK_EQUAL((rib.find(name2)->second)->getParent()->getName(), name4); |
| 151 | BOOST_REQUIRE(static_cast<bool>((rib.find(name3)->second)->getParent())); |
| 152 | BOOST_CHECK_EQUAL((rib.find(name3)->second)->getParent()->getName(), name4); |
| 153 | } |
| 154 | |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 155 | BOOST_AUTO_TEST_CASE(EraseFace) |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 156 | { |
| 157 | rib::Rib rib; |
| 158 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 159 | Route route1; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 160 | Name name1("/"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 161 | route1.faceId = 1; |
| 162 | route1.origin = 20; |
| 163 | rib.insert(name1, route1); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 164 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 165 | Route route2; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 166 | Name name2("/hello/world"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 167 | route2.faceId = 2; |
| 168 | route2.origin = 20; |
| 169 | rib.insert(name2, route2); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 170 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 171 | Route route3; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 172 | Name name3("/hello/world"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 173 | route3.faceId = 1; |
| 174 | route3.origin = 20; |
| 175 | rib.insert(name3, route3); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 176 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 177 | Route entry4; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 178 | Name name4("/not/inserted"); |
| 179 | entry4.faceId = 1; |
| 180 | entry4.origin = 20; |
| 181 | |
| 182 | rib.erase(name4, entry4); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 183 | rib.erase(name1, route1); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 184 | |
| 185 | BOOST_CHECK(rib.find(name1) == rib.end()); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 186 | BOOST_CHECK_EQUAL((rib.find(name2)->second)->getRoutes().size(), 2); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 187 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 188 | rib.erase(name2, route2); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 189 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 190 | BOOST_CHECK_EQUAL((rib.find(name2)->second)->getRoutes().size(), 1); |
| 191 | BOOST_CHECK_EQUAL((rib.find(name2)->second)->getRoutes().front().faceId, 1); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 192 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 193 | rib.erase(name3, route3); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 194 | |
| 195 | BOOST_CHECK(rib.find(name2) == rib.end()); |
| 196 | |
| 197 | rib.erase(name4, entry4); |
| 198 | } |
| 199 | |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 200 | BOOST_AUTO_TEST_CASE(EraseRibEntry) |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 201 | { |
| 202 | rib::Rib rib; |
| 203 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 204 | Route route1; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 205 | Name name1("/"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 206 | route1.faceId = 1; |
| 207 | route1.origin = 20; |
| 208 | rib.insert(name1, route1); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 209 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 210 | Route route2; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 211 | Name name2("/hello"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 212 | route2.faceId = 2; |
| 213 | route2.origin = 20; |
| 214 | rib.insert(name2, route2); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 215 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 216 | Route route3; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 217 | Name name3("/hello/world"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 218 | route3.faceId = 1; |
| 219 | route3.origin = 20; |
| 220 | rib.insert(name3, route3); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 221 | |
| 222 | shared_ptr<rib::RibEntry> ribEntry1 = rib.find(name1)->second; |
| 223 | shared_ptr<rib::RibEntry> ribEntry2 = rib.find(name2)->second; |
| 224 | shared_ptr<rib::RibEntry> ribEntry3 = rib.find(name3)->second; |
| 225 | |
| 226 | BOOST_CHECK(ribEntry1->getChildren().front() == ribEntry2); |
| 227 | BOOST_CHECK(ribEntry3->getParent() == ribEntry2); |
| 228 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 229 | rib.erase(name2, route2); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 230 | BOOST_CHECK(ribEntry1->getChildren().front() == ribEntry3); |
| 231 | BOOST_CHECK(ribEntry3->getParent() == ribEntry1); |
| 232 | } |
| 233 | |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 234 | BOOST_AUTO_TEST_CASE(Basic) |
| 235 | { |
| 236 | rib::Rib rib; |
| 237 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 238 | Route route1; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 239 | Name name1("/hello/world"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 240 | route1.faceId = 1; |
| 241 | route1.origin = 20; |
| 242 | route1.cost = 10; |
| 243 | route1.flags = ndn::nfd::ROUTE_FLAG_CHILD_INHERIT | ndn::nfd::ROUTE_FLAG_CAPTURE; |
| 244 | route1.expires = time::steady_clock::now() + time::milliseconds(1500); |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 245 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 246 | rib.insert(name1, route1); |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 247 | BOOST_CHECK_EQUAL(rib.size(), 1); |
| 248 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 249 | rib.insert(name1, route1); |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 250 | BOOST_CHECK_EQUAL(rib.size(), 1); |
| 251 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 252 | Route route2; |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 253 | Name name2("/hello/world"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 254 | route2.faceId = 1; |
| 255 | route2.origin = 20; |
| 256 | route2.cost = 100; |
| 257 | route2.flags = ndn::nfd::ROUTE_FLAG_CHILD_INHERIT; |
| 258 | route2.expires = time::steady_clock::now() + time::seconds(0); |
Alexander Afanasyev | 20d3144 | 2014-04-19 17:00:53 -0700 | [diff] [blame] | 259 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 260 | rib.insert(name2, route2); |
Alexander Afanasyev | 20d3144 | 2014-04-19 17:00:53 -0700 | [diff] [blame] | 261 | BOOST_CHECK_EQUAL(rib.size(), 1); |
| 262 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 263 | route2.faceId = 2; |
| 264 | rib.insert(name2, route2); |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 265 | BOOST_CHECK_EQUAL(rib.size(), 2); |
| 266 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 267 | BOOST_CHECK(rib.find(name1)->second->hasFaceId(route1.faceId)); |
| 268 | BOOST_CHECK(rib.find(name1)->second->hasFaceId(route2.faceId)); |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 269 | |
| 270 | Name name3("/foo/bar"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 271 | rib.insert(name3, route2); |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 272 | BOOST_CHECK_EQUAL(rib.size(), 3); |
| 273 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 274 | route2.origin = 1; |
| 275 | rib.insert(name3, route2); |
Alexander Afanasyev | 20d3144 | 2014-04-19 17:00:53 -0700 | [diff] [blame] | 276 | BOOST_CHECK_EQUAL(rib.size(), 4); |
| 277 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 278 | rib.erase(name3, route2); |
Alexander Afanasyev | 20d3144 | 2014-04-19 17:00:53 -0700 | [diff] [blame] | 279 | BOOST_CHECK_EQUAL(rib.size(), 3); |
| 280 | |
Vince | 12e4946 | 2014-06-09 13:29:32 -0500 | [diff] [blame] | 281 | Name name4("/hello/world"); |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 282 | rib.erase(name4, route2); |
Alexander Afanasyev | 20d3144 | 2014-04-19 17:00:53 -0700 | [diff] [blame] | 283 | BOOST_CHECK_EQUAL(rib.size(), 3); |
| 284 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 285 | route2.origin = 20; |
| 286 | rib.erase(name4, route2); |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 287 | BOOST_CHECK_EQUAL(rib.size(), 2); |
| 288 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 289 | BOOST_CHECK_EQUAL(rib.find(name2, route2), static_cast<Route*>(0)); |
| 290 | BOOST_CHECK_NE(rib.find(name1, route1), static_cast<Route*>(0)); |
Alexander Afanasyev | 20d3144 | 2014-04-19 17:00:53 -0700 | [diff] [blame] | 291 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 292 | rib.erase(name1, route1); |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 293 | BOOST_CHECK_EQUAL(rib.size(), 1); |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | BOOST_AUTO_TEST_SUITE_END() |
| 297 | |
| 298 | } // namespace tests |
| 299 | } // namespace rib |
| 300 | } // namespace nfd |