**breaking** route: consolidate routing tlv into route
refs: #5116
Plus some misc improvements
Change-Id: Id0902fec65160b4368b1b5066f460433aced98ed
diff --git a/tests/publisher/test-dataset-interest-handler.cpp b/tests/publisher/test-dataset-interest-handler.cpp
index 7342f62..2ec5d35 100644
--- a/tests/publisher/test-dataset-interest-handler.cpp
+++ b/tests/publisher/test-dataset-interest-handler.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
@@ -17,10 +17,10 @@
*
* 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/>.
- **/
+ */
#include "publisher/dataset-interest-handler.hpp"
-#include "tlv/tlv-nlsr.hpp"
+#include "tlv-nlsr.hpp"
#include "tests/test-common.hpp"
#include "publisher-fixture.hpp"
diff --git a/tests/test-hyperbolic-calculator.cpp b/tests/route/test-hyperbolic-calculator.cpp
similarity index 98%
rename from tests/test-hyperbolic-calculator.cpp
rename to tests/route/test-hyperbolic-calculator.cpp
index 2a787ba..a697e2e 100644
--- a/tests/test-hyperbolic-calculator.cpp
+++ b/tests/route/test-hyperbolic-calculator.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
@@ -17,14 +17,13 @@
*
* 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/>.
- **/
+ */
-#include "test-common.hpp"
+#include "../test-common.hpp"
#include "route/routing-table-calculator.hpp"
#include "adjacency-list.hpp"
-//#include "lsa.hpp"
#include "lsdb.hpp"
#include "nlsr.hpp"
#include "route/map.hpp"
diff --git a/tests/test-link-state-calculator.cpp b/tests/route/test-link-state-calculator.cpp
similarity index 99%
rename from tests/test-link-state-calculator.cpp
rename to tests/route/test-link-state-calculator.cpp
index f43c4f6..a0d04df 100644
--- a/tests/test-link-state-calculator.cpp
+++ b/tests/route/test-link-state-calculator.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
@@ -17,15 +17,14 @@
*
* 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/>.
- **/
+ */
#include "route/routing-table-calculator.hpp"
#include "adjacency-list.hpp"
-//#include "lsa.hpp"
#include "lsdb.hpp"
#include "nlsr.hpp"
-#include "test-common.hpp"
+#include "../test-common.hpp"
#include "route/map.hpp"
#include "route/routing-table.hpp"
#include "adjacent.hpp"
diff --git a/tests/route/test-map-entry.cpp b/tests/route/test-map-entry.cpp
deleted file mode 100644
index 0429dde..0000000
--- a/tests/route/test-map-entry.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2019, 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 Ashlesh Gawande <agawande@memphis.edu>
- **/
-
-#include "route/map.hpp"
-#include "tests/boost-test.hpp"
-
-namespace nlsr {
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TestMapEntry)
-
-BOOST_AUTO_TEST_CASE(MapEntryConstructorAndGetters)
-{
- std::string rtr = "r0";
-
- MapEntry me1(rtr, 1);
-
- BOOST_CHECK_EQUAL(me1.getRouter(), "r0");
-
- BOOST_CHECK_EQUAL(me1.getMappingNumber(), 1);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace nlsr
diff --git a/tests/route/test-nexthop-list.cpp b/tests/route/test-nexthop-list.cpp
index 5bdef4d..9ab8572 100644
--- a/tests/route/test-nexthop-list.cpp
+++ b/tests/route/test-nexthop-list.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2019, The University of Memphis,
+/*
+ * Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -17,7 +17,7 @@
*
* 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/>.
- **/
+ */
#include "route/nexthop-list.hpp"
#include "route/nexthop.hpp"
@@ -101,7 +101,7 @@
NexthopList::iterator it = list.begin();
BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), hopA.getConnectingFaceUri());
- list.reset();
+ list.clear();
list.addNextHop(hopZ);
list.addNextHop(hopA);
@@ -118,7 +118,7 @@
shortUriHop.setRouteCost(25);
shortUriHop.setConnectingFaceUri("AAA");
- list.reset();
+ list.clear();
list.addNextHop(longUriHop);
list.addNextHop(shortUriHop);
diff --git a/tests/route/test-nexthop.cpp b/tests/route/test-nexthop.cpp
index 3a6a5fd..a11c221 100644
--- a/tests/route/test-nexthop.cpp
+++ b/tests/route/test-nexthop.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2019, The University of Memphis,
+/*
+ * Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -16,9 +16,7 @@
*
* 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 Ashlesh Gawande <agawande@memphis.edu>
- **/
+ */
#include "route/nexthop.hpp"
#include "tests/boost-test.hpp"
@@ -102,6 +100,50 @@
BOOST_CHECK(hop1.getRouteCostAsAdjustedInteger() > hop2.getRouteCostAsAdjustedInteger());
}
+const uint8_t NexthopData[] =
+{
+ // Header
+ 0x8f, 0x1d,
+ // Uri
+ 0x8d, 0x11, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f,
+ 0x70, 0x2f, 0x74, 0x6c, 0x76,
+ // Cost
+ 0x86, 0x08, 0x3f, 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66
+};
+
+BOOST_AUTO_TEST_CASE(NexthopEncode)
+{
+ NextHop nexthops1;
+ nexthops1.setConnectingFaceUri("/test/nexthop/tlv");
+ nexthops1.setRouteCost(1.65);
+
+ const ndn::Block& wire = nexthops1.wireEncode();
+ BOOST_REQUIRE_EQUAL_COLLECTIONS(NexthopData,
+ NexthopData + sizeof(NexthopData),
+ wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE(NexthopDecode)
+{
+ NextHop nexthops1;
+
+ nexthops1.wireDecode(ndn::Block(NexthopData, sizeof(NexthopData)));
+
+ BOOST_REQUIRE_EQUAL(nexthops1.getConnectingFaceUri(), "/test/nexthop/tlv");
+ BOOST_REQUIRE_EQUAL(nexthops1.getRouteCost(), 1.65);
+}
+
+BOOST_AUTO_TEST_CASE(AdjacencyOutputStream)
+{
+ NextHop nexthops1;
+ nexthops1.setConnectingFaceUri("/test/nexthop/tlv");
+ nexthops1.setRouteCost(99);
+
+ std::ostringstream os;
+ os << nexthops1;
+ BOOST_CHECK_EQUAL(os.str(), "NextHop(Uri: /test/nexthop/tlv, Cost: 99)");
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace test
diff --git a/tests/route/test-routing-table-entry.cpp b/tests/route/test-routing-table-entry.cpp
index 574abc2..c17b981 100644
--- a/tests/route/test-routing-table-entry.cpp
+++ b/tests/route/test-routing-table-entry.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2019, The University of Memphis,
+/*
+ * Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -16,9 +16,7 @@
*
* 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 Ashlesh Gawande <agawande@memphis.edu>
- **/
+ */
#include "route/routing-table-entry.hpp"
#include "tests/boost-test.hpp"
@@ -35,6 +33,134 @@
BOOST_CHECK_EQUAL(rte1.getDestination(), "router1");
}
+const uint8_t RoutingTableEntryWithNexthopsData[] =
+{
+ // Header
+ 0x91, 0x35,
+ // Destination Name
+ 0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31, 0x8f, 0x14,
+ // Nexthop
+ 0x8d, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x31, 0x86, 0x08, 0x3f, 0xfa,
+ 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x8f, 0x14, 0x8d, 0x08,
+ // Nexthop
+ 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x32, 0x86, 0x08, 0x3f, 0xfa, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66
+};
+
+const uint8_t RoutingTableEntryWithoutNexthopsData[] =
+{
+ // Header
+ 0x91, 0x09,
+ // Destination Name
+ 0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31
+};
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithNexthops)
+{
+ RoutingTableEntry rte(ndn::Name("dest1"));
+
+ NextHop nexthops1;
+ nexthops1.setConnectingFaceUri("nexthop1");
+ nexthops1.setRouteCost(1.65);
+ rte.getNexthopList().addNextHop(nexthops1);
+
+ NextHop nexthops2;
+ nexthops2.setConnectingFaceUri("nexthop2");
+ nexthops2.setRouteCost(1.65);
+ rte.getNexthopList().addNextHop(nexthops2);
+
+ const ndn::Block& wire = rte.wireEncode();
+
+ BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableEntryWithNexthopsData,
+ RoutingTableEntryWithNexthopsData +
+ sizeof(RoutingTableEntryWithNexthopsData),
+ wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithNexthops)
+{
+ RoutingTableEntry rte(ndn::Block(RoutingTableEntryWithNexthopsData,
+ sizeof(RoutingTableEntryWithNexthopsData)));
+ BOOST_CHECK_EQUAL(rte.getDestination(), "dest1");
+
+ BOOST_CHECK(rte.getNexthopList().size() != 0);
+ auto it = rte.getNexthopList().begin();
+ BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), "nexthop1");
+ BOOST_CHECK_EQUAL(it->getRouteCost(), 1.65);
+
+ it++;
+ BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), "nexthop2");
+ BOOST_CHECK_EQUAL(it->getRouteCost(), 1.65);
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithoutNexthops)
+{
+ RoutingTableEntry rte(ndn::Name("dest1"));
+
+ auto wire = rte.wireEncode();
+
+ BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableEntryWithoutNexthopsData,
+ RoutingTableEntryWithoutNexthopsData +
+ sizeof(RoutingTableEntryWithoutNexthopsData),
+ wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithoutNexthops)
+{
+ RoutingTableEntry rte(ndn::Block(RoutingTableEntryWithoutNexthopsData,
+ sizeof(RoutingTableEntryWithoutNexthopsData)));
+
+ BOOST_CHECK_EQUAL(rte.getDestination(), "dest1");
+ BOOST_CHECK(rte.getNexthopList().size() == 0);
+}
+
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryClear)
+{
+ RoutingTableEntry rte(ndn::Name("dest1"));
+
+ NextHop nexthops1;
+ nexthops1.setConnectingFaceUri("nexthop1");
+ nexthops1.setRouteCost(99);
+ rte.getNexthopList().addNextHop(nexthops1);
+
+ BOOST_CHECK_EQUAL(rte.getNexthopList().size(), 1);
+
+ auto it = rte.getNexthopList().begin();
+ BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), "nexthop1");
+ BOOST_CHECK_EQUAL(it->getRouteCost(), 99);
+
+ rte.getNexthopList().clear();
+ BOOST_CHECK_EQUAL(rte.getNexthopList().size(), 0);
+
+ NextHop nexthops2;
+ nexthops2.setConnectingFaceUri("nexthop2");
+ nexthops2.setRouteCost(99);
+ rte.getNexthopList().addNextHop(nexthops2);
+
+ BOOST_CHECK_EQUAL(rte.getNexthopList().size(), 1);
+ it = rte.getNexthopList().begin();
+ BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), "nexthop2");
+ BOOST_CHECK_EQUAL(it->getRouteCost(), 99);
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryOutputStream)
+{
+ RoutingTableEntry rte(ndn::Name("dest1"));
+
+ NextHop nexthops1;
+ nexthops1.setConnectingFaceUri("nexthop1");
+ nexthops1.setRouteCost(99);
+ rte.getNexthopList().addNextHop(nexthops1);
+
+ std::ostringstream os;
+ os << rte;
+
+ BOOST_CHECK_EQUAL(os.str(),
+ " Destination: /dest1\n"
+ " NextHop(Uri: nexthop1, Cost: 99)\n");
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace test
diff --git a/tests/route/test-routing-table.cpp b/tests/route/test-routing-table.cpp
index f8a7df5..0bce153 100644
--- a/tests/route/test-routing-table.cpp
+++ b/tests/route/test-routing-table.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California
*
@@ -16,9 +16,7 @@
*
* 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 Ashlesh Gawande <agawande@memphis.edu>
- **/
+ */
#include "route/routing-table.hpp"
#include "nlsr.hpp"
@@ -30,23 +28,106 @@
namespace nlsr {
namespace test {
-BOOST_FIXTURE_TEST_SUITE(TestRoutingTable, BaseFixture)
-
-BOOST_AUTO_TEST_CASE(RoutingTableAddNextHop)
+class RoutingTableFixture
{
+public:
+ RoutingTableFixture()
+ : conf(face, keyChain)
+ , nlsr(face, keyChain, conf)
+ , rt(nlsr.m_routingTable)
+ {
+ }
+
+public:
ndn::util::DummyClientFace face;
ndn::KeyChain keyChain;
- ConfParameter conf(face, keyChain);
- Nlsr nlsr(face, keyChain, conf);
+ ConfParameter conf;
+ Nlsr nlsr;
- RoutingTable rt1(m_scheduler, nlsr.m_fib, nlsr.m_lsdb,
- nlsr.m_namePrefixTable, conf);
+ RoutingTable& rt;
+};
+BOOST_AUTO_TEST_SUITE(TestRoutingTable)
+
+BOOST_FIXTURE_TEST_CASE(RoutingTableAddNextHop, RoutingTableFixture)
+{
NextHop nh1;
const std::string DEST_ROUTER = "destRouter";
- rt1.addNextHop(DEST_ROUTER, nh1);
+ rt.addNextHop(DEST_ROUTER, nh1);
- BOOST_CHECK_EQUAL(rt1.findRoutingTableEntry(DEST_ROUTER)->getDestination(), DEST_ROUTER);
+ BOOST_CHECK_EQUAL(rt.findRoutingTableEntry(DEST_ROUTER)->getDestination(), DEST_ROUTER);
+}
+
+const uint8_t RoutingTableData1[] =
+{
+ // Header
+ 0x90, 0x20,
+ // Routing table entry
+ 0x91, 0x1e,
+ // Destination
+ 0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31, 0x8f, 0x13,
+ // Nexthop
+ 0x8d, 0x07, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x86, 0x08, 0x3f, 0xfa, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x66
+};
+
+const uint8_t RoutingTableData2[] =
+{
+ // Header
+ 0x90, 0x00
+};
+
+BOOST_FIXTURE_TEST_CASE(RoutingTableEncode1, RoutingTableFixture)
+{
+ NextHop nexthops;
+ nexthops.setConnectingFaceUri("nexthop");
+ nexthops.setRouteCost(1.65);
+ rt.addNextHop("dest1", nexthops);
+
+ auto wire = rt.wireEncode();
+ BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableData1,
+ RoutingTableData1 + sizeof(RoutingTableData1),
+ wire.begin(), wire.end());
+}
+
+BOOST_FIXTURE_TEST_CASE(RoutingTableEncode2, RoutingTableFixture)
+{
+ auto wire = rt.wireEncode();
+ BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableData2,
+ RoutingTableData2 + sizeof(RoutingTableData2),
+ wire.begin(), wire.end());
+}
+
+BOOST_FIXTURE_TEST_CASE(RoutingTableDecode1, RoutingTableFixture)
+{
+ RoutingTableStatus rtStatus(ndn::Block(RoutingTableData1, sizeof(RoutingTableData1)));
+
+ auto it1 = rtStatus.m_rTable.begin();
+
+ ndn::Name des1 = it1->getDestination();
+ BOOST_CHECK_EQUAL(des1, "dest1");
+
+ auto it2 = it1->getNexthopList().begin();
+ BOOST_CHECK_EQUAL(it2->getConnectingFaceUri(), "nexthop");
+ BOOST_CHECK_EQUAL(it2->getRouteCost(), 1.65);
+
+ BOOST_CHECK_EQUAL(rtStatus.m_rTable.size(), 1);
+}
+
+BOOST_FIXTURE_TEST_CASE(RoutingTableOutputStream, RoutingTableFixture)
+{
+ NextHop nexthops;
+ nexthops.setConnectingFaceUri("nexthop");
+ nexthops.setRouteCost(99);
+ rt.addNextHop("dest1", nexthops);
+
+ std::ostringstream os;
+ os << rt;
+
+ BOOST_CHECK_EQUAL(os.str(),
+ "Routing Table:\n"
+ " Destination: /dest1\n"
+ " NextHop(Uri: nexthop, Cost: 99)\n");
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/tlv/test-destination.cpp b/tests/tlv/test-destination.cpp
deleted file mode 100644
index adc153e..0000000
--- a/tests/tlv/test-destination.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2020, The University of Memphis,
- * Regents of the University of California,
- * Arizona Board of Regents.
- *
- * 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/>.
- **/
-
-#include "tlv/destination.hpp"
-
-#include "tests/boost-test.hpp"
-
-namespace nlsr {
-namespace tlv {
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TlvTestDes)
-
-const uint8_t DesData[] =
-{
- // Header
- 0x8e, 0x13,
- // Routername 746573742f646573742f746c76
- 0x07, 0x11, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x65, 0x73, 0x74,
- 0x08, 0x03, 0x74, 0x6c, 0x76
-};
-
-BOOST_AUTO_TEST_CASE(DesEncode)
-{
- Destination des1;
- des1.setName("/test/dest/tlv");
-
- const ndn::Block& wire = des1.wireEncode();
-
- BOOST_REQUIRE_EQUAL_COLLECTIONS(DesData,
- DesData + sizeof(DesData),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(DesDecode)
-{
- Destination des1;
-
- des1.wireDecode(ndn::Block(DesData, sizeof(DesData)));
-
- ndn::Name DEST_NAME = ndn::Name("/test/dest/tlv");
- BOOST_REQUIRE_EQUAL(des1.getName(), DEST_NAME);
-}
-
-BOOST_AUTO_TEST_CASE(DesOutputStream)
-{
- Destination des1;
- des1.setName("/test/dest/tlv");
-
- std::ostringstream os;
- os << des1;
-
- BOOST_CHECK_EQUAL(os.str(), "Destination: /test/dest/tlv");
-}
-
-BOOST_AUTO_TEST_CASE(DesMake)
-{
- RoutingTableEntry rte("/test/dest/tlv");
-
- std::shared_ptr<Destination> des = makeDes(rte);
- BOOST_CHECK_EQUAL(des->getName(), rte.getDestination());
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace tlv
-} // namespace nlsr
diff --git a/tests/tlv/test-nexthops.cpp b/tests/tlv/test-nexthops.cpp
deleted file mode 100644
index f5b4d29..0000000
--- a/tests/tlv/test-nexthops.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2020, The University of Memphis,
- * Regents of the University of California,
- * Arizona Board of Regents.
- *
- * 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/>.
- **/
-
-#include "tlv/nexthop.hpp"
-
-#include "tests/boost-test.hpp"
-
-namespace nlsr {
-namespace tlv {
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TlvTestNexthops)
-
-const uint8_t NexthopData[] =
-{
- // Header
- 0x8f, 0x1d,
- // Uri
- 0x8d, 0x11, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f,
- 0x70, 0x2f, 0x74, 0x6c, 0x76,
- // Cost
- 0x86, 0x08, 0x3f, 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66
-};
-
-BOOST_AUTO_TEST_CASE(NexthopEncode)
-{
- NextHop nexthops1;
- nexthops1.setUri("/test/nexthop/tlv");
- nexthops1.setCost(1.65);
-
- const ndn::Block& wire = nexthops1.wireEncode();
- BOOST_REQUIRE_EQUAL_COLLECTIONS(NexthopData,
- NexthopData + sizeof(NexthopData),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(NexthopDecode)
-{
- NextHop nexthops1;
-
- nexthops1.wireDecode(ndn::Block(NexthopData, sizeof(NexthopData)));
-
- BOOST_REQUIRE_EQUAL(nexthops1.getUri(), "/test/nexthop/tlv");
- BOOST_REQUIRE_EQUAL(nexthops1.getCost(), 1.65);
-}
-
-BOOST_AUTO_TEST_CASE(AdjacencyOutputStream)
-{
- NextHop nexthops1;
- nexthops1.setUri("/test/nexthop/tlv");
- nexthops1.setCost(99);
-
- std::ostringstream os;
- os << nexthops1;
- BOOST_CHECK_EQUAL(os.str(), "NextHop(Uri: /test/nexthop/tlv, Cost: 99)\n");
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace tlv
-} // namespace nlsr
diff --git a/tests/tlv/test-routing-table-entry.cpp b/tests/tlv/test-routing-table-entry.cpp
deleted file mode 100644
index 338945b..0000000
--- a/tests/tlv/test-routing-table-entry.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2020, The University of Memphis,
- * Regents of the University of California,
- * Arizona Board of Regents.
- *
- * 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/>.
- **/
-
-#include "tlv/routing-table-entry.hpp"
-
-#include "tests/boost-test.hpp"
-
-namespace nlsr {
-namespace tlv {
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TlvTestRoutingTableEntry)
-
-const uint8_t RoutingTableEntryWithNexthopsData[] =
-{
- // Header
- 0x91, 0x37,
- // Destination
- 0x8e, 0x09, 0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31,
- // Nexthop
- 0x8f, 0x14, 0x8d, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x31, 0x86, 0x08,
- 0x3f, 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x8f, 0x14,
- // Nexthop
- 0x8d, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x32, 0x86, 0x08, 0x3f, 0xfa,
- 0x66, 0x66, 0x66, 0x66, 0x66, 0x66
-};
-
-const uint8_t RoutingTableEntryWithoutNexthopsData[] =
-{
- // Header
- 0x91, 0x0b,
- // Destination
- 0x8e, 0x09, 0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31
-};
-
-BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithNexthops)
-{
- RoutingTable rt;
-
- Destination des1;
- des1.setName("dest1");
- rt.setDestination(des1);
-
- NextHop nexthops1;
- nexthops1.setUri("nexthop1");
- nexthops1.setCost(1.65);
- rt.addNexthops(nexthops1);
-
- NextHop nexthops2;
- nexthops2.setUri("nexthop2");
- nexthops2.setCost(1.65);
- rt.addNexthops(nexthops2);
-
- const ndn::Block& wire = rt.wireEncode();
-
- BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableEntryWithNexthopsData,
- RoutingTableEntryWithNexthopsData +
- sizeof(RoutingTableEntryWithNexthopsData),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithNexthops)
-{
- RoutingTable rt;
-
- rt.wireDecode(ndn::Block(RoutingTableEntryWithNexthopsData,
- sizeof(RoutingTableEntryWithNexthopsData)));
-
- Destination des = rt.getDestination();
- BOOST_CHECK_EQUAL(des.getName(), "dest1");
-
- BOOST_CHECK_EQUAL(rt.hasNexthops(), true);
- std::list<NextHop> nexthops = rt.getNextHops();
- std::list<NextHop>::const_iterator it = nexthops.begin();
- BOOST_CHECK_EQUAL(it->getUri(), "nexthop1");
- BOOST_CHECK_EQUAL(it->getCost(), 1.65);
-
- it++;
- BOOST_CHECK_EQUAL(it->getUri(), "nexthop2");
- BOOST_CHECK_EQUAL(it->getCost(), 1.65);
-}
-
-BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithoutNexthops)
-{
- RoutingTable rt;
-
- Destination des1;
- des1.setName("dest1");
- rt.setDestination(des1);
-
- const ndn::Block& wire = rt.wireEncode();
-
- BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableEntryWithoutNexthopsData,
- RoutingTableEntryWithoutNexthopsData +
- sizeof(RoutingTableEntryWithoutNexthopsData),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithoutNexthops)
-{
- RoutingTable rt;
-
- rt.wireDecode(ndn::Block(RoutingTableEntryWithoutNexthopsData,
- sizeof(RoutingTableEntryWithoutNexthopsData)));
-
- Destination des = rt.getDestination();
- BOOST_CHECK_EQUAL(des.getName(), "dest1");
-
- BOOST_CHECK_EQUAL(rt.hasNexthops(), false);
-}
-
-
-BOOST_AUTO_TEST_CASE(RoutingTableEntryClear)
-{
- RoutingTable rt;
- Destination des1;
- des1.setName("dest1");
- rt.setDestination(des1);
-
- NextHop nexthops1;
- nexthops1.setUri("nexthop1");
- nexthops1.setCost(99);
- rt.addNexthops(nexthops1);
-
- BOOST_CHECK_EQUAL(rt.getNextHops().size(), 1);
-
- std::list<NextHop> nexthops = rt.getNextHops();
- std::list<NextHop>::const_iterator it = nexthops.begin();
- BOOST_CHECK_EQUAL(it->getUri(), "nexthop1");
- BOOST_CHECK_EQUAL(it->getCost(), 99);
-
- rt.clearNexthops();
- BOOST_CHECK_EQUAL(rt.getNextHops().size(), 0);
-
- NextHop nexthops2;
- nexthops2.setUri("nexthop2");
- nexthops2.setCost(99);
- rt.addNexthops(nexthops2);
-
- BOOST_CHECK_EQUAL(rt.getNextHops().size(), 1);
-
- nexthops = rt.getNextHops();
- it = nexthops.begin();
- BOOST_CHECK_EQUAL(it->getUri(), "nexthop2");
- BOOST_CHECK_EQUAL(it->getCost(), 99);
-}
-
-BOOST_AUTO_TEST_CASE(RoutingTableEntryOutputStream)
-{
- RoutingTable rt;
- Destination des1;
- des1.setName("dest1");
- rt.setDestination(des1);
-
- NextHop nexthops1;
- nexthops1.setUri("nexthop1");
- nexthops1.setCost(99);
- rt.addNexthops(nexthops1);
-
- std::ostringstream os;
- os << rt;
-
- BOOST_CHECK_EQUAL(os.str(),
- "Destination: /dest1\n"
- "NexthopList(\n"
- "NextHop(Uri: nexthop1, Cost: 99)\n"
- ")");
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace tlv
-} // namespace nlsr
diff --git a/tests/tlv/test-routing-table.cpp b/tests/tlv/test-routing-table.cpp
deleted file mode 100644
index 70c25c9..0000000
--- a/tests/tlv/test-routing-table.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2020, The University of Memphis,
- * Regents of the University of California,
- * Arizona Board of Regents.
- *
- * 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/>.
- **/
-
-#include "tlv/routing-table-status.hpp"
-
-#include "tests/boost-test.hpp"
-
-namespace nlsr {
-namespace tlv {
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TlvTestRoutingTable)
-
-const uint8_t RoutingTableData1[] =
-{
- // Header
- 0x90, 0x22,
- // Routing table entry
- 0x91, 0x20,
- // Destination
- 0x8e, 0x09, 0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31,
- // Nexthop
- 0x8f, 0x13, 0x8d, 0x07, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x86, 0x08, 0x3f,
- 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66
-};
-
-const uint8_t RoutingTableData2[] =
-{
- // Header
- 0x90, 0x00
-};
-
-BOOST_AUTO_TEST_CASE(RoutingTableEncode1)
-{
- RoutingTableStatus rtStatus;
-
- Destination des;
- des.setName("dest1");
-
- // RoutingtableEntry
- RoutingTable rt;
- rt.setDestination(des);
-
- NextHop nexthops;
- nexthops.setUri("nexthop");
- nexthops.setCost(1.65);
- rt.addNexthops(nexthops);
-
- rtStatus.addRoutingTable(rt);
-
- const ndn::Block& wire = rtStatus.wireEncode();
-
- BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableData1,
- RoutingTableData1 + sizeof(RoutingTableData1),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(RoutingTableEncode2)
-{
- RoutingTableStatus rtStatus;
-
- const ndn::Block& wire = rtStatus.wireEncode();
-
- BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableData2,
- RoutingTableData2 + sizeof(RoutingTableData2),
- wire.begin(), wire.end());
-}
-
-BOOST_AUTO_TEST_CASE(RoutingTableDecode1)
-{
- RoutingTableStatus rtStatus;
-
- rtStatus.wireDecode(ndn::Block(RoutingTableData1, sizeof(RoutingTableData1)));
-
- std::list<RoutingTable> rte = rtStatus.getRoutingtable();
- std::list<RoutingTable>::const_iterator it1 = rte.begin();
-
- Destination des1 = it1->getDestination();
- BOOST_CHECK_EQUAL(des1.getName(), "dest1");
-
- std::list<NextHop> nexthops = it1->getNextHops();
- std::list<NextHop>::const_iterator it2 = nexthops.begin();
- BOOST_CHECK_EQUAL(it2->getUri(), "nexthop");
- BOOST_CHECK_EQUAL(it2->getCost(), 1.65);
-
- BOOST_CHECK_EQUAL(rtStatus.hasRoutingTable(), true);
-}
-
-BOOST_AUTO_TEST_CASE(RoutingTableDecode2)
-{
- RoutingTableStatus rtStatus;
- rtStatus.wireDecode(ndn::Block(RoutingTableData2, sizeof(RoutingTableData2)));
-
- BOOST_CHECK_EQUAL(rtStatus.hasRoutingTable(), false);
-}
-
-BOOST_AUTO_TEST_CASE(RoutingTableClear)
-{
- RoutingTableStatus rtStatus;
- Destination des;
- des.setName("dest1");
-
- // RoutingtableEntry
- RoutingTable rt;
- rt.setDestination(des);
-
- NextHop nexthops;
- nexthops.setUri("nexthop");
- nexthops.setCost(1.65);
- rt.addNexthops(nexthops);
-
- rtStatus.addRoutingTable(rt);
-
- BOOST_CHECK_EQUAL(rtStatus.hasRoutingTable(), true);
- rtStatus.clearRoutingTable();
- BOOST_CHECK_EQUAL(rtStatus.hasRoutingTable(), false);
-}
-
-BOOST_AUTO_TEST_CASE(RoutingTableOutputStream)
-{
- RoutingTableStatus rtStatus;
- Destination des;
- des.setName("dest1");
-
- // RoutingtableEntry
- RoutingTable rt;
- rt.setDestination(des);
-
- NextHop nexthops;
- nexthops.setUri("nexthop");
- nexthops.setCost(99);
- rt.addNexthops(nexthops);
-
- rtStatus.addRoutingTable(rt);
-
- std::ostringstream os;
- os << rtStatus;
-
- BOOST_CHECK_EQUAL(os.str(), "Routing Table Status: \n"
- "Destination: /dest1\n"
- "NexthopList(\n"
- "NextHop(Uri: nexthop, Cost: 99)\n"
- ")");
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace tlv
-} // namespace nlsr