tests: Check ACTIVE/INACTIVE Adjacencies in LSA construction
refs #2735
Change-Id: I5d0c4940c0bc688a895a71603c9ea93b87cfba42
diff --git a/tests/test-lsa.cpp b/tests/test-lsa.cpp
index 57fa403..0d8c942 100644
--- a/tests/test-lsa.cpp
+++ b/tests/test-lsa.cpp
@@ -57,28 +57,43 @@
BOOST_AUTO_TEST_CASE(AdjacentLsaConstructorAndGetters)
{
- Adjacent adj1("adjacent");
- Adjacent adj2("adjacent2");
-
- AdjacencyList adjList;
- adjList.insert(adj1);
+ ndn::Name routerName("/ndn/site/router");
+ ndn::Name adjacencyName("/ndn/site/adjacency");
ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
-//For AdjLsa, lsType is 2.
-//1 is the number of adjacent in adjacent list.
- AdjLsa alsa1("router1", AdjLsa::TYPE_STRING, 12, testTimePoint, 1, adjList);
- AdjLsa alsa2("router1", AdjLsa::TYPE_STRING, 12, testTimePoint, 1, adjList);
+ uint32_t seqNo = 12;
+ // An AdjLsa initialized with ACTIVE adjacencies should copy the adjacencies
+ AdjacencyList activeAdjacencies;
+ Adjacent activeAdjacency(adjacencyName);
+ activeAdjacency.setStatus(Adjacent::STATUS_ACTIVE);
+ activeAdjacencies.insert(activeAdjacency);
+
+ AdjLsa alsa1(routerName, AdjLsa::TYPE_STRING, seqNo, testTimePoint,
+ activeAdjacencies.getSize(), activeAdjacencies);
+ BOOST_CHECK_EQUAL(alsa1.getAdl().getSize(), 1);
BOOST_CHECK_EQUAL(alsa1.getLsType(), AdjLsa::TYPE_STRING);
- BOOST_CHECK_EQUAL(alsa1.getLsSeqNo(), (uint32_t)12);
+ BOOST_CHECK_EQUAL(alsa1.getLsSeqNo(), seqNo);
BOOST_CHECK_EQUAL(alsa1.getExpirationTimePoint(), testTimePoint);
- BOOST_CHECK_EQUAL(alsa1.getNoLink(), (uint32_t)1);
+ BOOST_CHECK_EQUAL(alsa1.getNoLink(), 1);
+ BOOST_CHECK(alsa1.getAdl().isNeighbor(activeAdjacency.getName()));
- BOOST_CHECK(alsa1.isEqualContent(alsa2));
+ // An AdjLsa initialized with INACTIVE adjacencies should not copy the adjacencies
+ AdjacencyList inactiveAdjacencies;
+ Adjacent inactiveAdjacency(adjacencyName);
+ inactiveAdjacency.setStatus(Adjacent::STATUS_INACTIVE);
+ inactiveAdjacencies.insert(inactiveAdjacency);
- alsa1.addAdjacent(adj2);
+ AdjLsa alsa2(routerName, AdjLsa::TYPE_STRING, seqNo, testTimePoint,
+ inactiveAdjacencies.getSize(), inactiveAdjacencies);
+ BOOST_CHECK_EQUAL(alsa2.getAdl().getSize(), 0);
- const std::string ADJACENT_1 = "adjacent2";
- BOOST_CHECK(alsa1.getAdl().isNeighbor(ADJACENT_1));
+ // Thus, the two LSAs should not have equal content
+ BOOST_CHECK_EQUAL(alsa1.isEqualContent(alsa2), false);
+
+ // Create a duplicate of alsa1 which should have equal content
+ AdjLsa alsa3(routerName, AdjLsa::TYPE_STRING, seqNo, testTimePoint,
+ activeAdjacencies.getSize(), activeAdjacencies);
+ BOOST_CHECK(alsa1.isEqualContent(alsa3));
}
BOOST_AUTO_TEST_CASE(CoordinateLsaConstructorAndGetters)