blob: 3ea831a7b4be000ad19413cb49f6f1222475feb1 [file] [log] [blame]
Nick Gordonb50e51b2016-07-22 16:05:57 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Nick Gordonfeae5572017-01-13 12:06:26 -06003 * Copyright (c) 2014-2017, The University of Memphis,
Nick Gordonb50e51b2016-07-22 16:05:57 -05004 * Regents of the University of California
5 *
6 * This file is part of NLSR (Named-data Link State Routing).
7 * See AUTHORS.md for complete list of NLSR authors and contributors.
8 *
9 * NLSR is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * \author Nicholas Gordon <nmgordon@memphis.edu>
21 *
22 **/
23#include "route/routing-table-pool-entry.hpp"
24#include "route/nexthop.hpp"
25#include "route/nexthop-list.hpp"
26
27#include <boost/test/unit_test.hpp>
28
29namespace nlsr {
30
31namespace test {
32
33BOOST_AUTO_TEST_SUITE(TestRoutingTablePoolEntry)
34
35BOOST_AUTO_TEST_CASE(EqualsOperator)
36{
37 NextHop hop1;
38 hop1.setRouteCost(25);
39 hop1.setConnectingFaceUri("AAA");
40
41 NextHop hop2;
42 hop2.setRouteCost(10);
43 hop2.setConnectingFaceUri("BBB");
44
45 NexthopList nhl1;
46 NexthopList nhl2;
47
48 nhl1.addNextHop(hop1);
49 nhl1.addNextHop(hop2);
50
51 RoutingTablePoolEntry rtpe1("/memphis/ndn/rtr1", 0);
52 RoutingTablePoolEntry rtpe2("/memphis/ndn/rtr1", 0);
53
54 rtpe1.setNexthopList(nhl1);
55 rtpe2.setNexthopList(nhl1);
56
57 BOOST_CHECK_EQUAL(rtpe1, rtpe2);
58}
59
60BOOST_AUTO_TEST_CASE(IncrementEntryUseCount)
61{
62 RoutingTablePoolEntry rtpe1("router1");
63
64 rtpe1.incrementUseCount();
65
66 BOOST_CHECK_EQUAL(rtpe1.getUseCount(), 2);
67}
68
69BOOST_AUTO_TEST_CASE(DecrementEntryUseCountNotZero)
70{
71 RoutingTablePoolEntry rtpe1("router1");
72
73 rtpe1.decrementUseCount();
74
75 BOOST_CHECK_EQUAL(rtpe1.getUseCount(), 0);
76}
77
78BOOST_AUTO_TEST_CASE(DecrementEntryUseCountAtZero)
79{
80 RoutingTablePoolEntry rtpe1("router1");
81
82 rtpe1.decrementUseCount();
83 rtpe1.decrementUseCount();
84
85 BOOST_CHECK_EQUAL(rtpe1.getUseCount(), 0);
86}
87
88BOOST_AUTO_TEST_CASE(UpdateNextHopList)
89{
90 RoutingTablePoolEntry rtpe1("router1");
91 NextHop nh1;
92 NexthopList nhl1;
93
94 nhl1.addNextHop(nh1);
95
96 rtpe1.setNexthopList(nhl1);
97
98 BOOST_CHECK_EQUAL(rtpe1.getNexthopList(), nhl1);
99}
100
101BOOST_AUTO_TEST_SUITE_END()
102
103} // namespace test
104} // namespace nlsr