blob: 22577f0d10ec6021d49455a9aa8ae052e02a7303 [file] [log] [blame]
Vince Lehman76c751c2014-11-18 17:36:38 -06001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento1b077f62019-02-19 19:19:44 -05002/*
3 * Copyright (c) 2014-2019, Regents of the University of California,
Vince Lehman76c751c2014-11-18 17:36:38 -06004 * 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.
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/>.
24 */
25
Vince Lehman76c751c2014-11-18 17:36:38 -060026#include "rib/rib-update.hpp"
27#include "rib/rib-update-batch.hpp"
28
Davide Pesavento97210d52016-10-14 15:45:48 +020029#include "tests/test-common.hpp"
Davide Pesavento1b077f62019-02-19 19:19:44 -050030#include "tests/daemon/rib/create-route.hpp"
Davide Pesavento97210d52016-10-14 15:45:48 +020031
Vince Lehman76c751c2014-11-18 17:36:38 -060032namespace nfd {
33namespace rib {
34namespace tests {
35
Davide Pesavento97210d52016-10-14 15:45:48 +020036BOOST_FIXTURE_TEST_SUITE(TestRibUpdate, nfd::tests::BaseFixture)
Vince Lehman76c751c2014-11-18 17:36:38 -060037
38BOOST_AUTO_TEST_CASE(BatchBasic)
39{
40 const uint64_t faceId = 1;
41
42 RibUpdateBatch batch(faceId);
43
44 Route routeRegister = createRoute(faceId, 128, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
45
46 RibUpdate registerUpdate;
47 registerUpdate.setAction(RibUpdate::REGISTER)
48 .setName("/a")
49 .setRoute(routeRegister);
50
51 batch.add(registerUpdate);
52
53 BOOST_CHECK_EQUAL(batch.getFaceId(), faceId);
54
55 Route routeUnregister = createRoute(faceId, 0, 0, ndn::nfd::ROUTE_FLAG_CAPTURE);
56
57 RibUpdate unregisterUpdate;
58 unregisterUpdate.setAction(RibUpdate::UNREGISTER)
59 .setName("/a/b")
60 .setRoute(routeUnregister);
61
62 batch.add(unregisterUpdate);
63
64 BOOST_REQUIRE_EQUAL(batch.size(), 2);
65 RibUpdateBatch::const_iterator it = batch.begin();
66
67 BOOST_CHECK_EQUAL(it->getAction(), RibUpdate::REGISTER);
68 BOOST_CHECK_EQUAL(it->getName(), "/a");
69 BOOST_CHECK_EQUAL(it->getRoute(), routeRegister);
70
71 ++it;
72 BOOST_CHECK_EQUAL(it->getAction(), RibUpdate::UNREGISTER);
73 BOOST_CHECK_EQUAL(it->getName(), "/a/b");
74 BOOST_CHECK_EQUAL(it->getRoute(), routeUnregister);
75
76 ++it;
77 BOOST_CHECK(it == batch.end());
78}
79
Davide Pesavento97210d52016-10-14 15:45:48 +020080BOOST_AUTO_TEST_SUITE_END() // TestRibUpdate
Vince Lehman76c751c2014-11-18 17:36:38 -060081
82} // namespace tests
83} // namespace rib
84} // namespace nfd