Accommodate n-Dimensional HR coordinates
refs: #3751
Change-Id: Ib705b671daba56f58e09876a48d8b31649bd7ab1
diff --git a/tests/publisher/publisher-fixture.hpp b/tests/publisher/publisher-fixture.hpp
index eba000d..30ffa7c 100644
--- a/tests/publisher/publisher-fixture.hpp
+++ b/tests/publisher/publisher-fixture.hpp
@@ -84,7 +84,7 @@
}
CoordinateLsa
- createCoordinateLsa(const std::string& origin, double radius, double angle)
+ createCoordinateLsa(const std::string& origin, double radius, std::vector<double> angle)
{
CoordinateLsa lsa(origin, 1, ndn::time::system_clock::now(),
radius, angle);
@@ -109,7 +109,7 @@
checkTlvLsaInfo(tlvLsa.getLsaInfo(), lsa);
BOOST_CHECK_EQUAL(tlvLsa.getHyperbolicRadius(), lsa.getCorRadius());
- BOOST_CHECK_EQUAL(tlvLsa.getHyperbolicAngle(), lsa.getCorTheta());
+ BOOST_CHECK(tlvLsa.getHyperbolicAngle() == lsa.getCorTheta());
}
void
diff --git a/tests/publisher/test-lsa-publisher.cpp b/tests/publisher/test-lsa-publisher.cpp
index 8ee842b..6a3045f 100644
--- a/tests/publisher/test-lsa-publisher.cpp
+++ b/tests/publisher/test-lsa-publisher.cpp
@@ -76,13 +76,20 @@
{
ndn::Name thisRouter("/RouterA");
- CoordinateLsa routerALsa = createCoordinateLsa(thisRouter.toUri(), 10.0, 20.0);
+ std::vector<double> anglesA, anglesB, anglesC;
+ anglesA.push_back(20.00);
+ anglesB.push_back(543.21);
+ // Setting two angles for testing routerCLsa
+ anglesC.push_back(0.02);
+ anglesC.push_back(1.23);
+
+ CoordinateLsa routerALsa = createCoordinateLsa(thisRouter.toUri(), 10.0, anglesA);
lsdb.installCoordinateLsa(routerALsa);
- CoordinateLsa routerBLsa = createCoordinateLsa("/RouterB", 123.45, 543.21);
+ CoordinateLsa routerBLsa = createCoordinateLsa("/RouterB", 123.45, anglesB);
lsdb.installCoordinateLsa(routerBLsa);
- CoordinateLsa routerCLsa = createCoordinateLsa("/RouterC", 0.01, 0.02);
+ CoordinateLsa routerCLsa = createCoordinateLsa("/RouterC", 0.01, anglesC);
lsdb.installCoordinateLsa(routerCLsa);
CoordinateLsaPublisher publisher(lsdb, *face, keyChain);
diff --git a/tests/publisher/test-lsdb-dataset-interest-handler.cpp b/tests/publisher/test-lsdb-dataset-interest-handler.cpp
index 8e9855a..e08d1f2 100644
--- a/tests/publisher/test-lsdb-dataset-interest-handler.cpp
+++ b/tests/publisher/test-lsdb-dataset-interest-handler.cpp
@@ -70,8 +70,10 @@
addAdjacency(adjLsa, "/RouterA/adjacency1", "udp://face-1", 10);
lsdb.installAdjLsa(adjLsa);
+ std::vector<double> angles = {20.00, 30.00};
+
// Install coordinate LSA
- CoordinateLsa coordinateLsa = createCoordinateLsa("/RouterA", 10.0, 20.0);
+ CoordinateLsa coordinateLsa = createCoordinateLsa("/RouterA", 10.0, angles);
lsdb.installCoordinateLsa(coordinateLsa);
// Install Name LSA
diff --git a/tests/publisher/test-lsdb-status-publisher.cpp b/tests/publisher/test-lsdb-status-publisher.cpp
index be21670..c9412ad 100644
--- a/tests/publisher/test-lsdb-status-publisher.cpp
+++ b/tests/publisher/test-lsdb-status-publisher.cpp
@@ -49,14 +49,18 @@
addAdjacency(routerBAdjLsa, "/RouterB/adjacency3", "udp://face-3", 30);
lsdb.installAdjLsa(routerBAdjLsa);
+ std::vector<double> anglesA = {20.00},
+ anglesB = {543.21},
+ anglesC = {0.02, 2.25};
+
// Install coordinate LSAs
- CoordinateLsa routerACorLsa = createCoordinateLsa("/RouterA", 10.0, 20.0);
+ CoordinateLsa routerACorLsa = createCoordinateLsa("/RouterA", 10.0, anglesA);
lsdb.installCoordinateLsa(routerACorLsa);
- CoordinateLsa routerBCorLsa = createCoordinateLsa("/RouterB", 123.45, 543.21);
+ CoordinateLsa routerBCorLsa = createCoordinateLsa("/RouterB", 123.45, anglesB);
lsdb.installCoordinateLsa(routerBCorLsa);
- CoordinateLsa routerCCorLsa = createCoordinateLsa("/RouterC", 0.01, 0.02);
+ CoordinateLsa routerCCorLsa = createCoordinateLsa("/RouterC", 0.01, anglesC);
lsdb.installCoordinateLsa(routerCCorLsa);
// Install Name LSAs
diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp
index e818ac3..df347f1 100644
--- a/tests/test-conf-file-processor.cpp
+++ b/tests/test-conf-file-processor.cpp
@@ -98,6 +98,14 @@
" angle 1.45\n"
"}\n\n";
+const std::string SECTION_HYPERBOLIC_ANGLES_ON =
+ "hyperbolic\n"
+ "{\n"
+ " state on\n"
+ " radius 123.456\n"
+ " angle 1.45,2.25\n"
+ "}\n\n";
+
const std::string SECTION_HYPERBOLIC_OFF =
"hyperbolic\n"
"{\n"
@@ -128,6 +136,10 @@
const std::string CONFIG_HYPERBOLIC = SECTION_GENERAL + SECTION_NEIGHBORS +
SECTION_HYPERBOLIC_ON + SECTION_FIB + SECTION_ADVERTISING;
+const std::string CONFIG_HYPERBOLIC_ANGLES = SECTION_GENERAL + SECTION_NEIGHBORS +
+ SECTION_HYPERBOLIC_ANGLES_ON + SECTION_FIB +
+ SECTION_ADVERTISING;
+
class ConfFileProcessorFixture : public BaseFixture
{
public:
@@ -365,7 +377,22 @@
ConfParameter& conf = nlsr.getConfParameter();
BOOST_CHECK_EQUAL(conf.getHyperbolicState(), 1);
BOOST_CHECK_EQUAL(conf.getCorR(), 123.456);
- BOOST_CHECK_EQUAL(conf.getCorTheta(), 1.45);
+ std::vector<double> angles;
+ angles.push_back(1.45);
+ BOOST_CHECK(conf.getCorTheta() == angles);
+}
+
+BOOST_AUTO_TEST_CASE(Hyperbolic2)
+{
+ processConfigurationString(CONFIG_HYPERBOLIC_ANGLES);
+
+ ConfParameter& conf = nlsr.getConfParameter();
+ BOOST_CHECK_EQUAL(conf.getHyperbolicState(), 1);
+ BOOST_CHECK_EQUAL(conf.getCorR(), 123.456);
+ std::vector<double> angles;
+ angles.push_back(1.45);
+ angles.push_back(2.25);
+ BOOST_CHECK(conf.getCorTheta() == angles);
}
BOOST_AUTO_TEST_CASE(DefaultValuesGeneral)
diff --git a/tests/test-conf-parameter.cpp b/tests/test-conf-parameter.cpp
index 2d69a27..55a65b1 100644
--- a/tests/test-conf-parameter.cpp
+++ b/tests/test-conf-parameter.cpp
@@ -61,7 +61,9 @@
cp1.setCorR(2.5);
- cp1.setCorTheta(102.5);
+ std::vector<double> angles = {102.5};
+
+ cp1.setCorTheta(angles);
cp1.setInfoInterestInterval(3);
@@ -89,7 +91,7 @@
BOOST_CHECK_EQUAL(cp1.getHyperbolicState(), 1);
- BOOST_CHECK_CLOSE(cp1.getCorTheta(), 102.5, 0.0001);
+ BOOST_CHECK(cp1.getCorTheta() == angles);
BOOST_CHECK_EQUAL(cp1.getInfoInterestInterval(), 3);
}
diff --git a/tests/test-hyperbolic-calculator.cpp b/tests/test-hyperbolic-calculator.cpp
index 0001ae4..030fe25 100644
--- a/tests/test-hyperbolic-calculator.cpp
+++ b/tests/test-hyperbolic-calculator.cpp
@@ -51,11 +51,11 @@
, adjacencies(nlsr.getAdjacencyList())
, lsdb(nlsr.getLsdb())
{
- setUpTopology();
}
// Triangle topology with routers A, B, C connected
- void setUpTopology()
+ void setUpTopology(std::vector<double> anglesA, std::vector<double> anglesB,
+ std::vector<double> anglesC)
{
INIT_LOGGERS("/tmp", "TRACE");
@@ -70,7 +70,8 @@
AdjLsa adjA(a.getName(), 1, MAX_TIME, 2, adjacencies);
lsdb.installAdjLsa(adjA);
- CoordinateLsa coordA(adjA.getOrigRouter(), 1, MAX_TIME, 16.23, 2.97);
+
+ CoordinateLsa coordA(adjA.getOrigRouter(), 1, MAX_TIME, 16.23, anglesA);
lsdb.installCoordinateLsa(coordA);
// Router B
@@ -84,7 +85,7 @@
AdjLsa adjB(b.getName(), 1, MAX_TIME, 2, adjacencyListB);
lsdb.installAdjLsa(adjB);
- CoordinateLsa coordB(adjB.getOrigRouter(), 1, MAX_TIME, 16.59, 3.0);
+ CoordinateLsa coordB(adjB.getOrigRouter(), 1, MAX_TIME, 16.59, anglesB);
lsdb.installCoordinateLsa(coordB);
// Router C
@@ -98,12 +99,55 @@
AdjLsa adjC(c.getName(), 1, MAX_TIME, 2, adjacencyListC);
lsdb.installAdjLsa(adjC);
- CoordinateLsa coordC(adjC.getOrigRouter(), 1, MAX_TIME, 14.11, 2.99);
+ CoordinateLsa coordC(adjC.getOrigRouter(), 1, MAX_TIME, 14.11, anglesC);
lsdb.installCoordinateLsa(coordC);
map.createFromAdjLsdb(nlsr);
}
+ void runTest(const double& expectedCost)
+ {
+ HyperbolicRoutingCalculator calculator(map.getMapSize(), false, ROUTER_A_NAME);
+ calculator.calculatePaths(map, routingTable, lsdb, adjacencies);
+
+ RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);
+
+ // Router A should be able to get to B through B with cost 0 and to B through C
+ NexthopList& bHopList = entryB->getNexthopList();
+ BOOST_REQUIRE_EQUAL(bHopList.getNextHops().size(), 2);
+
+ for (std::set<NextHop, NextHopComparator>::iterator it = bHopList.begin(); it != bHopList.end(); ++it) {
+ std::string faceUri = it->getConnectingFaceUri();
+ uint64_t cost = it->getRouteCostAsAdjustedInteger();
+
+ BOOST_CHECK((faceUri == ROUTER_B_FACE && cost == 0) ||
+ (faceUri == ROUTER_C_FACE && cost == applyHyperbolicFactorAndRound(expectedCost)));
+ }
+
+ RoutingTableEntry* entryC = routingTable.findRoutingTableEntry(ROUTER_C_NAME);
+
+ // Router A should be able to get to C through C with cost 0 and to C through B
+ NexthopList& cHopList = entryC->getNexthopList();
+ BOOST_REQUIRE_EQUAL(cHopList.getNextHops().size(), 2);
+
+ for (std::set<NextHop, NextHopComparator>::iterator it = cHopList.begin(); it != cHopList.end(); ++it) {
+ std::string faceUri = it->getConnectingFaceUri();
+ uint64_t cost = it->getRouteCostAsAdjustedInteger();
+
+ BOOST_CHECK((faceUri == ROUTER_B_FACE && cost == applyHyperbolicFactorAndRound(expectedCost)) ||
+ (faceUri == ROUTER_C_FACE && cost == 0));
+ }
+ }
+
+ uint64_t
+ applyHyperbolicFactorAndRound(double d)
+ {
+ // Hyperbolic costs in the tests were calculated with 1*10^-9 precision.
+ // A factor larger than 1*10^9 will cause the tests to fail.
+ BOOST_REQUIRE(NextHop::HYPERBOLIC_COST_ADJUSTMENT_FACTOR <= 1000000000);
+ return round(NextHop::HYPERBOLIC_COST_ADJUSTMENT_FACTOR*d);
+ }
+
public:
std::shared_ptr<ndn::util::DummyClientFace> face;
Nlsr nlsr;
@@ -130,49 +174,26 @@
const std::string HyperbolicCalculatorFixture::ROUTER_B_FACE = "udp4://10.0.0.2";
const std::string HyperbolicCalculatorFixture::ROUTER_C_FACE = "udp4://10.0.0.3";
-uint64_t
-applyHyperbolicFactorAndRound(double d)
-{
- // Hyperbolic costs in the tests were calculated with 1*10^-9 precision.
- // A factor larger than 1*10^9 will cause the tests to fail.
- BOOST_REQUIRE(NextHop::HYPERBOLIC_COST_ADJUSTMENT_FACTOR <= 1000000000);
- return round(NextHop::HYPERBOLIC_COST_ADJUSTMENT_FACTOR*d);
-}
-
BOOST_FIXTURE_TEST_SUITE(TestHyperbolicRoutingCalculator, HyperbolicCalculatorFixture)
BOOST_AUTO_TEST_CASE(Basic)
{
- HyperbolicRoutingCalculator calculator(map.getMapSize(), false, ROUTER_A_NAME);
- calculator.calculatePaths(map, routingTable, lsdb, adjacencies);
+ std::vector<double> anglesA = {2.97},
+ anglesB = {3.0},
+ anglesC = {2.99};
+ setUpTopology(anglesA, anglesB, anglesC);
- RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);
+ runTest(20.103356956);
+}
- // Router A should be able to get to B through B with cost 0 and to B through C
- NexthopList& bHopList = entryB->getNexthopList();
- BOOST_REQUIRE_EQUAL(bHopList.getNextHops().size(), 2);
+BOOST_AUTO_TEST_CASE(BasicMultipleAngles)
+{
+ std::vector<double> anglesA = {2.97,1.22},
+ anglesB = {3.0, 0.09},
+ anglesC = {321, 2.99};
+ setUpTopology(anglesA, anglesB, anglesC);
- for (std::set<NextHop, NextHopComparator>::iterator it = bHopList.begin(); it != bHopList.end(); ++it) {
- std::string faceUri = it->getConnectingFaceUri();
- uint64_t cost = it->getRouteCostAsAdjustedInteger();
-
- BOOST_CHECK((faceUri == ROUTER_B_FACE && cost == 0) ||
- (faceUri == ROUTER_C_FACE && cost == applyHyperbolicFactorAndRound(20.103356956)));
- }
-
- RoutingTableEntry* entryC = routingTable.findRoutingTableEntry(ROUTER_C_NAME);
-
- // Router A should be able to get to C through C with cost 0 and to C through B
- NexthopList& cHopList = entryC->getNexthopList();
- BOOST_REQUIRE_EQUAL(cHopList.getNextHops().size(), 2);
-
- for (std::set<NextHop, NextHopComparator>::iterator it = cHopList.begin(); it != cHopList.end(); ++it) {
- std::string faceUri = it->getConnectingFaceUri();
- uint64_t cost = it->getRouteCostAsAdjustedInteger();
-
- BOOST_CHECK((faceUri == ROUTER_B_FACE && cost == applyHyperbolicFactorAndRound(20.103356956)) ||
- (faceUri == ROUTER_C_FACE && cost == 0));
- }
+ runTest(30.655296361);
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/test-lsa.cpp b/tests/test-lsa.cpp
index d7c97f9..e501c59 100644
--- a/tests/test-lsa.cpp
+++ b/tests/test-lsa.cpp
@@ -100,11 +100,14 @@
BOOST_AUTO_TEST_CASE(CoordinateLsaConstructorAndGetters)
{
ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
- CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, 30.0);
- CoordinateLsa clsa2("router1", 12, testTimePoint, 2.5, 30.0);
+ std::vector<double> angles1, angles2;
+ angles1.push_back(30.0);
+ angles2.push_back(30.0);
+ CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, angles1);
+ CoordinateLsa clsa2("router1", 12, testTimePoint, 2.5, angles2);
BOOST_CHECK_CLOSE(clsa1.getCorRadius(), 2.5, 0.0001);
- BOOST_CHECK_CLOSE(clsa1.getCorTheta(), 30.0, 0.0001);
+ BOOST_CHECK(clsa1.getCorTheta() == angles1);
BOOST_CHECK(clsa1.isEqualContent(clsa2));
@@ -124,7 +127,6 @@
adjList.insert(adj2);
ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
-
std::ostringstream ss;
ss << testTimePoint;
@@ -133,21 +135,21 @@
AdjLsa lsa("router1", 12, testTimePoint, adjList.getSize(), adjList);
std::string EXPECTED_OUTPUT =
- "Adj Lsa:\n"
- " Origination Router: /router1\n"
- " Ls Type: adjacency\n"
- " Ls Seq No: 12\n"
- " Ls Lifetime: " + TEST_TIME_POINT_STRING + "\n"
- " Adjacents: \n"
- " Adjacent 1:\n"
- " Adjacent Name: /adjacent1\n"
- " Connecting FaceUri: ://\n"
- " Link Cost: 10\n"
- " Adjacent 2:\n"
- " Adjacent Name: /adjacent2\n"
- " Connecting FaceUri: ://\n"
- " Link Cost: 10\n"
- "adj_lsa_end";
+ "Adj Lsa:\n"
+ " Origination Router: /router1\n"
+ " Ls Type: adjacency\n"
+ " Ls Seq No: 12\n"
+ " Ls Lifetime: " + TEST_TIME_POINT_STRING + "\n"
+ " Adjacents: \n"
+ " Adjacent 1:\n"
+ " Adjacent Name: /adjacent1\n"
+ " Connecting FaceUri: ://\n"
+ " Link Cost: 10\n"
+ " Adjacent 2:\n"
+ " Adjacent Name: /adjacent2\n"
+ " Connecting FaceUri: ://\n"
+ " Link Cost: 10\n"
+ "adj_lsa_end";
std::ostringstream os;
os << lsa;
@@ -200,7 +202,8 @@
BOOST_CHECK_EQUAL(nlsa1.getData(), nlsa2.getData());
//Coordinate LSA
- CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, 30.0);
+ std::vector<double> angles = {30, 40.0};
+ CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, angles);
CoordinateLsa clsa2;
BOOST_CHECK(clsa2.initializeFromContent(clsa1.getData()));
diff --git a/tests/test-sync-logic-handler.cpp b/tests/test-sync-logic-handler.cpp
index 76ca830..6e47e1c 100644
--- a/tests/test-sync-logic-handler.cpp
+++ b/tests/test-sync-logic-handler.cpp
@@ -209,9 +209,11 @@
3 , adjList);
lsdb.installAdjLsa(adjLsa);
+ std::vector<double> angles = {0.0};
+
// Install Cor LSA
CoordinateLsa corLsa(originRouter, 1000, ndn::time::system_clock::TimePoint::max(),
- 0,0);
+ 0, angles);
lsdb.installCoordinateLsa(corLsa);
std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
diff --git a/tests/tlv/test-coordinate-lsa.cpp b/tests/tlv/test-coordinate-lsa.cpp
index f7789c4..fa05d95 100644
--- a/tests/tlv/test-coordinate-lsa.cpp
+++ b/tests/tlv/test-coordinate-lsa.cpp
@@ -24,7 +24,7 @@
#include "../boost-test.hpp"
namespace nlsr {
-namespace tlv {
+namespace tlv {
namespace test {
BOOST_AUTO_TEST_SUITE(TlvTestCoordinateLsa)
@@ -53,7 +53,9 @@
coordinateLsa.setLsaInfo(lsaInfo);
coordinateLsa.setHyperbolicRadius(1.65);
- coordinateLsa.setHyperbolicAngle(1.78);
+ std::vector<double> angles;
+ angles.push_back(1.78);
+ coordinateLsa.setHyperbolicAngle(angles);
const ndn::Block& wire = coordinateLsa.wireEncode();
@@ -73,7 +75,8 @@
BOOST_REQUIRE_EQUAL(coordinateLsa.getLsaInfo().getExpirationPeriod(),
ndn::time::milliseconds(10000));
BOOST_REQUIRE_EQUAL(coordinateLsa.getHyperbolicRadius(), 1.65);
- BOOST_REQUIRE_EQUAL(coordinateLsa.getHyperbolicAngle(), 1.78);
+ std::vector<double> angles = {1.78};
+ BOOST_REQUIRE(coordinateLsa.getHyperbolicAngle() == angles);
}
BOOST_AUTO_TEST_CASE(CoordinateLsaOutputStream)
@@ -87,7 +90,8 @@
coordinateLsa.setLsaInfo(lsaInfo);
coordinateLsa.setHyperbolicRadius(1.65);
- coordinateLsa.setHyperbolicAngle(1.78);
+ std::vector<double> angles = {1.78};
+ coordinateLsa.setHyperbolicAngle(angles);
std::ostringstream os;
os << coordinateLsa;
@@ -97,9 +101,23 @@
"SequenceNumber: 128, "
"ExpirationPeriod: 10000 milliseconds), "
"HyperbolicRadius: 1.65, "
- "HyperbolicAngle: 1.78)");
+ "HyperbolicAngles: 1.78)");
+
+ angles.push_back(3.21);
+ coordinateLsa.setHyperbolicAngle(angles);
+
+ std::ostringstream os2;
+ os2 << coordinateLsa;
+
+ BOOST_CHECK_EQUAL(os2.str(), "CoordinateLsa("
+ "LsaInfo(OriginRouter: /test, "
+ "SequenceNumber: 128, "
+ "ExpirationPeriod: 10000 milliseconds), "
+ "HyperbolicRadius: 1.65, "
+ "HyperbolicAngles: 1.78, 3.21)");
}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace test
diff --git a/tests/tlv/test-lsdb-status.cpp b/tests/tlv/test-lsdb-status.cpp
index 5b15fa0..12284e8 100644
--- a/tests/tlv/test-lsdb-status.cpp
+++ b/tests/tlv/test-lsdb-status.cpp
@@ -22,9 +22,11 @@
#include "tlv/lsdb-status.hpp"
#include "../boost-test.hpp"
+#include <boost/mpl/vector.hpp>
+#include <boost/lexical_cast.hpp>
namespace nlsr {
-namespace tlv {
+namespace tlv {
namespace test {
BOOST_AUTO_TEST_SUITE(TlvTestLsdbStatus)
@@ -123,7 +125,9 @@
coordinateLsa.setLsaInfo(lsaInfo);
coordinateLsa.setHyperbolicRadius(1.65);
- coordinateLsa.setHyperbolicAngle(1.78);
+ std::vector<double> angles;
+ angles.push_back(1.78);
+ coordinateLsa.setHyperbolicAngle(angles);
lsdbStatus.addCoordinateLsa(coordinateLsa);
@@ -183,7 +187,9 @@
BOOST_CHECK_EQUAL(lsaInfo.getExpirationPeriod(), ndn::time::milliseconds(10000));
BOOST_REQUIRE_EQUAL(it3->getHyperbolicRadius(), 1.65);
- BOOST_REQUIRE_EQUAL(it3->getHyperbolicAngle(), 1.78);
+ std::vector<double> angles;
+ angles.push_back(1.78);
+ BOOST_REQUIRE(it3->getHyperbolicAngle() == angles);
BOOST_CHECK_EQUAL(lsdbStatus.hasCoordinateLsas(), true);
@@ -250,7 +256,9 @@
coordinateLsa.setLsaInfo(lsaInfo);
coordinateLsa.setHyperbolicRadius(1.65);
- coordinateLsa.setHyperbolicAngle(1.78);
+ std::vector<double> angles;
+ angles.push_back(1.78);
+ coordinateLsa.setHyperbolicAngle(angles);
lsdbStatus.addCoordinateLsa(coordinateLsa);
BOOST_CHECK_EQUAL(lsdbStatus.hasCoordinateLsas(), true);
@@ -268,8 +276,23 @@
BOOST_CHECK_EQUAL(lsdbStatus.hasNameLsas(), false);
}
-BOOST_AUTO_TEST_CASE(LsdbStatusOutputStream)
+class Theta
{
+public:
+ std::vector<double> angles = {1.78};
+};
+
+class ThetaAndPhi
+{
+public:
+ std::vector<double> angles = {1.78, 3.21};
+};
+
+typedef boost::mpl::vector<Theta, ThetaAndPhi> HyperbolicAngleVectorFixture;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(LsdbStatusOutputStream, HRAngleVector, HyperbolicAngleVectorFixture)
+{
+ HRAngleVector angleVector;
LsdbStatus lsdbStatus;
LsaInfo lsaInfo;
@@ -289,22 +312,34 @@
lsdbStatus.addAdjacencyLsa(adjacencyLsa);
- // CoordinateLsa
- CoordinateLsa coordinateLsa;
- coordinateLsa.setLsaInfo(lsaInfo);
-
- coordinateLsa.setHyperbolicRadius(1.65);
- coordinateLsa.setHyperbolicAngle(1.78);
-
- lsdbStatus.addCoordinateLsa(coordinateLsa);
-
- // NameLsa
+ // NameLsa
NameLsa nameLsa;
nameLsa.setLsaInfo(lsaInfo);
nameLsa.addName("name1");
lsdbStatus.addNameLsa(nameLsa);
+ // CoordinateLsa
+ CoordinateLsa coordinateLsa;
+ coordinateLsa.setLsaInfo(lsaInfo);
+
+ coordinateLsa.setHyperbolicRadius(1.65);
+ coordinateLsa.setHyperbolicAngle(angleVector.angles);
+
+ std::string outputAngles = "HyperbolicAngles: ";
+ for (uint i = 0; i < angleVector.angles.size(); i++) {
+ std::string angle = boost::lexical_cast<std::string>(angleVector.angles[i]);
+ if (i == angleVector.angles.size()-1) {
+ outputAngles += angle;
+ }
+ else {
+ outputAngles += angle + ", ";
+ }
+ }
+ outputAngles += "), ";
+
+ lsdbStatus.addCoordinateLsa(coordinateLsa);
+
std::ostringstream os;
os << lsdbStatus;
@@ -321,7 +356,7 @@
"SequenceNumber: 128, "
"ExpirationPeriod: 10000 milliseconds), "
"HyperbolicRadius: 1.65, "
- "HyperbolicAngle: 1.78), "
+ + outputAngles +
"NameLsa("
"LsaInfo("
"OriginRouter: /test, "