lsa: simplify initializeFromContent and improve naming
refs: #4354
Change-Id: I5ddd5a9f482f59e6ca52061ac92514feab8c3070
diff --git a/tests/mocks/lsa.cpp b/tests/mocks/lsa.cpp
index f4f6348..3ab6689 100644
--- a/tests/mocks/lsa.cpp
+++ b/tests/mocks/lsa.cpp
@@ -31,22 +31,15 @@
}
bool
-MockLsa::initializeFromContent(const std::string& content)
+MockLsa::deserialize(const std::string& content)
{
boost::char_separator<char> sep("|");
boost::tokenizer<boost::char_separator<char> >tokens(content, sep);
boost::tokenizer<boost::char_separator<char> >::iterator tok_iter =
tokens.begin();
- m_origRouter = ndn::Name(*tok_iter++);
- if (!(m_origRouter.size() > 0)) {
- return false;
- }
+
try {
- if (*tok_iter++ != std::to_string(Lsa::Type::MOCK)) {
- return false;
- }
- m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
- m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
+ deserializeCommon(tok_iter);
}
catch (const std::exception& e) {
return false;
diff --git a/tests/mocks/lsa.hpp b/tests/mocks/lsa.hpp
index 738ad8f..0ce6e3a 100644
--- a/tests/mocks/lsa.hpp
+++ b/tests/mocks/lsa.hpp
@@ -42,7 +42,7 @@
serialize() const override;
bool
- initializeFromContent(const std::string& content) override;
+ deserialize(const std::string& content) override;
};
} // namespace test
diff --git a/tests/test-lsa.cpp b/tests/test-lsa.cpp
index f3eff5c..413e393 100644
--- a/tests/test-lsa.cpp
+++ b/tests/test-lsa.cpp
@@ -163,7 +163,7 @@
//If we don't do this the test will fail
//Adjacent has default cost of 10 but no default
- //connecting face URI, so initializeFromContent fails
+ //connecting face URI, so deserialize fails
adj1.setFaceUri(ndn::util::FaceUri("udp://10.0.0.1"));
adj2.setFaceUri(ndn::util::FaceUri("udp://10.0.0.2"));
@@ -176,7 +176,7 @@
AdjLsa adjlsa1("router1", 1, testTimePoint, adjList.size(), adjList);
AdjLsa adjlsa2;
- BOOST_CHECK(adjlsa2.initializeFromContent(adjlsa1.serialize()));
+ BOOST_CHECK(adjlsa2.deserialize(adjlsa1.serialize()));
BOOST_CHECK(adjlsa1.isEqualContent(adjlsa2));
@@ -188,7 +188,7 @@
NameLsa nlsa1("router1", 1, testTimePoint, npl1);
NameLsa nlsa2;
- BOOST_CHECK(nlsa2.initializeFromContent(nlsa1.serialize()));
+ BOOST_CHECK(nlsa2.deserialize(nlsa1.serialize()));
BOOST_CHECK_EQUAL(nlsa1.serialize(), nlsa2.serialize());
@@ -197,7 +197,7 @@
CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, angles);
CoordinateLsa clsa2;
- BOOST_CHECK(clsa2.initializeFromContent(clsa1.serialize()));
+ BOOST_CHECK(clsa2.deserialize(clsa1.serialize()));
BOOST_CHECK_EQUAL(clsa1.serialize(), clsa2.serialize());
}