blob: e76508cbaf23df16861a447d7772eab9dc3675df [file] [log] [blame]
Vince Lehman09131122014-09-09 17:10:11 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014 University of Memphis,
4 * 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 *
21 **/
22
23 #include "test-common.hpp"
24 #include "dummy-face.hpp"
25
26 #include "nlsr.hpp"
27
28namespace nlsr {
29namespace test {
30
31using ndn::DummyFace;
32using ndn::shared_ptr;
33
34BOOST_FIXTURE_TEST_SUITE(TestNlsr, BaseFixture)
35
36BOOST_AUTO_TEST_CASE(HyperbolicOn_ZeroCostNeighbors)
37{
38 shared_ptr<DummyFace> face = ndn::makeDummyFace();
39 Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
40
41 // Simulate loading configuration file
42 AdjacencyList& neighbors = nlsr.getAdjacencyList();
43
44 Adjacent neighborA("/ndn/neighborA", "uri://faceA", 25, Adjacent::STATUS_INACTIVE, 0, 0);
45 neighbors.insert(neighborA);
46
47 Adjacent neighborB("/ndn/neighborB", "uri://faceB", 10, Adjacent::STATUS_INACTIVE, 0, 0);
48 neighbors.insert(neighborB);
49
50 Adjacent neighborC("/ndn/neighborC", "uri://faceC", 17, Adjacent::STATUS_INACTIVE, 0, 0);
51 neighbors.insert(neighborC);
52
53 nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_ON);
54
55 nlsr.initialize();
56
57 std::list<Adjacent> neighborList = neighbors.getAdjList();
58 for (std::list<Adjacent>::iterator it = neighborList.begin(); it != neighborList.end(); ++it) {
59 BOOST_CHECK_EQUAL(it->getLinkCost(), 0);
60 }
61}
62
63BOOST_AUTO_TEST_CASE(HyperbolicOff_LinkStateCost)
64{
65 shared_ptr<DummyFace> face = ndn::makeDummyFace();
66 Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
67
68 // Simulate loading configuration file
69 AdjacencyList& neighbors = nlsr.getAdjacencyList();
70
71 Adjacent neighborA("/ndn/neighborA", "uri://faceA", 25, Adjacent::STATUS_INACTIVE, 0, 0);
72 neighbors.insert(neighborA);
73
74 Adjacent neighborB("/ndn/neighborB", "uri://faceB", 10, Adjacent::STATUS_INACTIVE, 0, 0);
75 neighbors.insert(neighborB);
76
77 Adjacent neighborC("/ndn/neighborC", "uri://faceC", 17, Adjacent::STATUS_INACTIVE, 0, 0);
78 neighbors.insert(neighborC);
79
80 nlsr.initialize();
81
82 std::list<Adjacent> neighborList = neighbors.getAdjList();
83 for (std::list<Adjacent>::iterator it = neighborList.begin(); it != neighborList.end(); ++it) {
84 BOOST_CHECK(it->getLinkCost() != 0);
85 }
86}
87
88BOOST_AUTO_TEST_SUITE_END()
89
90} //namespace test
91} //namespace nlsr