blob: e0014d26aca5d5fac2ad72438de894c252be1ec7 [file] [log] [blame]
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2016, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
* See AUTHORS.md for complete list of NLSR authors and contributors.
*
* NLSR is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*
* \author Nicholas Gordon <nmgordon@memphis.edu>
*
**/
#include "route/routing-table-pool-entry.hpp"
#include "route/nexthop.hpp"
#include "route/nexthop-list.hpp"
#include <boost/test/unit_test.hpp>
namespace nlsr {
namespace test {
BOOST_AUTO_TEST_SUITE(TestRoutingTablePoolEntry)
BOOST_AUTO_TEST_CASE(EqualsOperator)
{
NextHop hop1;
hop1.setRouteCost(25);
hop1.setConnectingFaceUri("AAA");
NextHop hop2;
hop2.setRouteCost(10);
hop2.setConnectingFaceUri("BBB");
NexthopList nhl1;
NexthopList nhl2;
nhl1.addNextHop(hop1);
nhl1.addNextHop(hop2);
RoutingTablePoolEntry rtpe1("/memphis/ndn/rtr1", 0);
RoutingTablePoolEntry rtpe2("/memphis/ndn/rtr1", 0);
rtpe1.setNexthopList(nhl1);
rtpe2.setNexthopList(nhl1);
BOOST_CHECK_EQUAL(rtpe1, rtpe2);
}
BOOST_AUTO_TEST_CASE(IncrementEntryUseCount)
{
RoutingTablePoolEntry rtpe1("router1");
rtpe1.incrementUseCount();
BOOST_CHECK_EQUAL(rtpe1.getUseCount(), 2);
}
BOOST_AUTO_TEST_CASE(DecrementEntryUseCountNotZero)
{
RoutingTablePoolEntry rtpe1("router1");
rtpe1.decrementUseCount();
BOOST_CHECK_EQUAL(rtpe1.getUseCount(), 0);
}
BOOST_AUTO_TEST_CASE(DecrementEntryUseCountAtZero)
{
RoutingTablePoolEntry rtpe1("router1");
rtpe1.decrementUseCount();
rtpe1.decrementUseCount();
BOOST_CHECK_EQUAL(rtpe1.getUseCount(), 0);
}
BOOST_AUTO_TEST_CASE(UpdateNextHopList)
{
RoutingTablePoolEntry rtpe1("router1");
NextHop nh1;
NexthopList nhl1;
nhl1.addNextHop(nh1);
rtpe1.setNexthopList(nhl1);
BOOST_CHECK_EQUAL(rtpe1.getNexthopList(), nhl1);
}
BOOST_AUTO_TEST_SUITE_END()
} // namespace test
} // namespace nlsr