blob: c7b1c6cecef57cd2fe7febf112926a5c7e12d48c [file] [log] [blame]
Vince Lehman76c751c2014-11-18 17:36:38 -06001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
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.
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
26#include "tests/test-common.hpp"
27#include "rib-test-common.hpp"
28
29#include "rib/rib-update.hpp"
30#include "rib/rib-update-batch.hpp"
31
32namespace nfd {
33namespace rib {
34namespace tests {
35
36BOOST_FIXTURE_TEST_SUITE(RibRibUpdate, nfd::tests::BaseFixture)
37
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
80
81BOOST_AUTO_TEST_SUITE_END()
82
83} // namespace tests
84} // namespace rib
85} // namespace nfd