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