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