lsa: change type variable to enum class
Change-Id: I7fba951649771700ce6ccc4be7fb400546607e96
refs: #4340
diff --git a/tests/test-sync-logic-handler.cpp b/tests/test-sync-logic-handler.cpp
index bb6a6db..e660a5d 100644
--- a/tests/test-sync-logic-handler.cpp
+++ b/tests/test-sync-logic-handler.cpp
@@ -23,6 +23,7 @@
#include "test-common.hpp"
#include "common.hpp"
#include "nlsr.hpp"
+#include "lsa.hpp"
#include "logger.hpp"
#include <ndn-cxx/util/dummy-client-face.hpp>
@@ -38,7 +39,7 @@
SyncLogicFixture()
: face(std::make_shared<ndn::util::DummyClientFace>())
, nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
- , testIsLsaNew([] (const ndn::Name& name, const std::string& lsaType,
+ , testIsLsaNew([] (const ndn::Name& name, const Lsa::Type& lsaType,
const uint64_t sequenceNumber) {
return true;
})
@@ -79,14 +80,14 @@
std::shared_ptr<ndn::util::DummyClientFace> face;
Nlsr nlsr;
ConfParameter conf;
- IsLsaNew testIsLsaNew;
+ SyncLogicHandler::IsLsaNew testIsLsaNew;
const std::string CONFIG_NETWORK;
const std::string CONFIG_SITE;
const std::string CONFIG_ROUTER_NAME;
const std::string OTHER_ROUTER_NAME;
- const std::vector<std::string> lsaTypes = {NameLsa::TYPE_STRING, AdjLsa::TYPE_STRING,
- CoordinateLsa::TYPE_STRING};
+ const std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::ADJACENCY,
+ Lsa::Type::COORDINATE};
};
BOOST_FIXTURE_TEST_SUITE(TestSyncLogicHandler, SyncLogicFixture)
@@ -100,13 +101,13 @@
SyncLogicHandler sync{std::ref(*face), testIsLsaNew, conf};
sync.createSyncSocket(conf.getChronosyncPrefix());
- std::vector<std::string> lsaTypes = {NameLsa::TYPE_STRING, AdjLsa::TYPE_STRING};
+ std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::ADJACENCY};
uint64_t syncSeqNo = 1;
- for (const std::string& lsaType : lsaTypes) {
+ for (const Lsa::Type& lsaType : lsaTypes) {
std::string updateName = conf.getLsaPrefix().toUri() + CONFIG_SITE
- + OTHER_ROUTER_NAME + lsaType;
+ + OTHER_ROUTER_NAME + std::to_string(lsaType);
// Actual testing done here -- signal function callback
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
@@ -131,11 +132,11 @@
sync.createSyncSocket(conf.getChronosyncPrefix());
uint64_t syncSeqNo = 1;
- std::vector<std::string> lsaTypes = {NameLsa::TYPE_STRING, CoordinateLsa::TYPE_STRING};
+ std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::COORDINATE};
- for (const std::string& lsaType : lsaTypes) {
+ for (const Lsa::Type& lsaType : lsaTypes) {
std::string updateName = conf.getLsaPrefix().toUri() + CONFIG_SITE
- + OTHER_ROUTER_NAME + lsaType;
+ + OTHER_ROUTER_NAME + std::to_string(lsaType);
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
[& ,this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
@@ -158,11 +159,11 @@
SyncLogicHandler sync{std::ref(*face), testIsLsaNew, conf};
sync.createSyncSocket(conf.getChronosyncPrefix());
- for (const std::string& lsaType : lsaTypes) {
+ for (const Lsa::Type& lsaType : lsaTypes) {
uint64_t syncSeqNo = 1;
std::string updateName = conf.getLsaPrefix().toUri() + CONFIG_SITE
- + OTHER_ROUTER_NAME + lsaType;
+ + OTHER_ROUTER_NAME + std::to_string(lsaType);
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
[& ,this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
@@ -185,11 +186,11 @@
SyncLogicHandler sync{std::ref(*face), testIsLsaNew, conf};
sync.createSyncSocket(conf.getChronosyncPrefix());
- for (const std::string& lsaType : lsaTypes) {
+ for (const Lsa::Type& lsaType : lsaTypes) {
// To ensure that we get correctly-separated components, create
// and modify a Name to hand off.
ndn::Name updateName = ndn::Name{conf.getLsaPrefix()};
- updateName.append(CONFIG_SITE).append(CONFIG_ROUTER_NAME).append(lsaType);
+ updateName.append(CONFIG_SITE).append(CONFIG_ROUTER_NAME).append(std::to_string(lsaType));
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
[& ,this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
@@ -211,9 +212,9 @@
SyncLogicHandler sync{std::ref(*face), testIsLsaNew, conf};
sync.createSyncSocket(conf.getChronosyncPrefix());
- for (const std::string& lsaType : lsaTypes) {
+ for (const Lsa::Type& lsaType : lsaTypes) {
ndn::Name updateName{CONFIG_SITE};
- updateName.append(CONFIG_ROUTER_NAME).append(lsaType);
+ updateName.append(CONFIG_ROUTER_NAME).append(std::to_string(lsaType));
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
[& ,this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
@@ -230,7 +231,7 @@
*/
BOOST_AUTO_TEST_CASE(LsaNotNew)
{
- auto testLsaAlwaysFalse = [] (const ndn::Name& routerName, const std::string& lsaType,
+ auto testLsaAlwaysFalse = [] (const ndn::Name& routerName, const Lsa::Type& lsaType,
const uint64_t& sequenceNumber) {
return false;
};
@@ -244,7 +245,8 @@
});
std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
- CONFIG_SITE + "/%C1.Router/other-router/" + NameLsa::TYPE_STRING;
+ CONFIG_SITE + "/%C1.Router/other-router/" +
+ std::to_string(Lsa::Type::NAME);
receiveUpdate(updateName, sequenceNumber, sync);
}
@@ -265,32 +267,32 @@
sync.buildUpdatePrefix();
BOOST_CHECK_EQUAL(sync.m_nameLsaUserPrefix,
- ndn::Name(expectedPrefix).append(NameLsa::TYPE_STRING));
+ ndn::Name(expectedPrefix).append(std::to_string(Lsa::Type::NAME)));
BOOST_CHECK_EQUAL(sync.m_adjLsaUserPrefix,
- ndn::Name(expectedPrefix).append(AdjLsa::TYPE_STRING));
+ ndn::Name(expectedPrefix).append(std::to_string(Lsa::Type::ADJACENCY)));
BOOST_CHECK_EQUAL(sync.m_coorLsaUserPrefix,
- ndn::Name(expectedPrefix).append(CoordinateLsa::TYPE_STRING));
+ ndn::Name(expectedPrefix).append(std::to_string(Lsa::Type::COORDINATE)));
}
/* Tests that SyncLogicHandler's socket will be created when
Nlsr::initialize is called, preventing use of sync before the
socket is created.
- NB: This test is as much an Nlsr class test as a SyncLogicHandler
- class test, but it rides the line and ends up here.
+ NB: This test is as much an Nlsr class test as a
+ SyncLogicHandler class test, but it rides the line and ends up here.
*/
BOOST_AUTO_TEST_CASE(CreateSyncSocketOnInitialization) // Bug #2649
{
nlsr.initialize();
// Make sure an adjacency LSA has not been built yet
- ndn::Name key = ndn::Name(nlsr.getConfParameter().getRouterPrefix()).append(AdjLsa::TYPE_STRING);
+ ndn::Name key = ndn::Name(nlsr.getConfParameter().getRouterPrefix()).append(std::to_string(Lsa::Type::ADJACENCY));
AdjLsa* lsa = nlsr.getLsdb().findAdjLsa(key);
BOOST_REQUIRE(lsa == nullptr);
// Publish a routing update before an Adjacency LSA is built
BOOST_CHECK_NO_THROW(nlsr.getLsdb().getSyncLogicHandler()
- .publishRoutingUpdate(AdjLsa::TYPE_STRING, 0));
+ .publishRoutingUpdate(Lsa::Type::ADJACENCY, 0));
}
BOOST_AUTO_TEST_SUITE_END()