face+mgmt: simplify factories and FaceManager using C++11 features
Change-Id: I113a4c15ef82bff705f61f31b170f49727bc3794
Refs: #3258
diff --git a/tests/daemon/face/udp.t.cpp b/tests/daemon/face/udp.t.cpp
index 6869176..86c9bfe 100644
--- a/tests/daemon/face/udp.t.cpp
+++ b/tests/daemon/face/udp.t.cpp
@@ -44,22 +44,16 @@
UdpFactory factory;
BOOST_REQUIRE_EQUAL(factory.getChannels().empty(), true);
- std::vector<shared_ptr<const Channel> > expectedChannels;
-
+ std::vector<shared_ptr<const Channel>> expectedChannels;
expectedChannels.push_back(factory.createChannel("127.0.0.1", "20070"));
expectedChannels.push_back(factory.createChannel("127.0.0.1", "20071"));
expectedChannels.push_back(factory.createChannel("::1", "20071"));
- std::list<shared_ptr<const Channel> > channels = factory.getChannels();
- for (std::list<shared_ptr<const Channel> >::const_iterator i = channels.begin();
- i != channels.end(); ++i)
- {
- std::vector<shared_ptr<const Channel> >::iterator pos =
- std::find(expectedChannels.begin(), expectedChannels.end(), *i);
-
- BOOST_REQUIRE(pos != expectedChannels.end());
- expectedChannels.erase(pos);
- }
+ for (const auto& i : factory.getChannels()) {
+ auto pos = std::find(expectedChannels.begin(), expectedChannels.end(), i);
+ BOOST_REQUIRE(pos != expectedChannels.end());
+ expectedChannels.erase(pos);
+ }
BOOST_CHECK_EQUAL(expectedChannels.size(), 0);
}
diff --git a/tests/daemon/face/websocket.t.cpp b/tests/daemon/face/websocket.t.cpp
index d3da744..a1d8a52 100644
--- a/tests/daemon/face/websocket.t.cpp
+++ b/tests/daemon/face/websocket.t.cpp
@@ -42,32 +42,26 @@
BOOST_AUTO_TEST_CASE(GetChannels)
{
- WebSocketFactory factory("19596");
+ WebSocketFactory factory;
BOOST_REQUIRE_EQUAL(factory.getChannels().empty(), true);
- std::vector<shared_ptr<const Channel> > expectedChannels;
-
+ std::vector<shared_ptr<const Channel>> expectedChannels;
expectedChannels.push_back(factory.createChannel("127.0.0.1", "20070"));
expectedChannels.push_back(factory.createChannel("127.0.0.1", "20071"));
expectedChannels.push_back(factory.createChannel("::1", "20071"));
- std::list<shared_ptr<const Channel> > channels = factory.getChannels();
- for (std::list<shared_ptr<const Channel> >::const_iterator i = channels.begin();
- i != channels.end(); ++i)
- {
- std::vector<shared_ptr<const Channel> >::iterator pos =
- std::find(expectedChannels.begin(), expectedChannels.end(), *i);
-
- BOOST_REQUIRE(pos != expectedChannels.end());
- expectedChannels.erase(pos);
- }
+ for (const auto& i : factory.getChannels()) {
+ auto pos = std::find(expectedChannels.begin(), expectedChannels.end(), i);
+ BOOST_REQUIRE(pos != expectedChannels.end());
+ expectedChannels.erase(pos);
+ }
BOOST_CHECK_EQUAL(expectedChannels.size(), 0);
}
BOOST_AUTO_TEST_CASE(UnsupportedFaceCreate)
{
- WebSocketFactory factory("19596");
+ WebSocketFactory factory;
BOOST_CHECK_THROW(factory.createFace(FaceUri("ws://127.0.0.1:20070"),
ndn::nfd::FACE_PERSISTENCY_PERMANENT,
@@ -226,7 +220,7 @@
BOOST_FIXTURE_TEST_CASE(EndToEnd4, EndToEndFixture)
{
- WebSocketFactory factory1("9696");
+ WebSocketFactory factory1;
shared_ptr<WebSocketChannel> channel1 = factory1.createChannel("127.0.0.1", "20070");
channel1->setPingInterval(time::milliseconds(3000));
diff --git a/tests/daemon/mgmt/face-manager.t.cpp b/tests/daemon/mgmt/face-manager.t.cpp
index db24029..b8944b4 100644
--- a/tests/daemon/mgmt/face-manager.t.cpp
+++ b/tests/daemon/mgmt/face-manager.t.cpp
@@ -370,7 +370,7 @@
BOOST_CHECK_NO_THROW(status.wireDecode(content.elements()[1]));
BOOST_CHECK_EQUAL(face3->getId(), status.getFaceId());
- ControlResponse expectedResponse(400, "malformed filter"); // nack, 400, malformed filter
+ ControlResponse expectedResponse(400, "Malformed filter"); // nack, 400, malformed filter
BOOST_CHECK_EQUAL(checkResponse(3, invalidQueryName, expectedResponse, tlv::ContentType_Nack),
CheckResponseResult::OK);
}
@@ -391,11 +391,11 @@
createFace(const FaceUri& uri,
ndn::nfd::FacePersistency persistency,
const FaceCreatedCallback& onCreated,
- const FaceConnectFailedCallback& onConnectFailed) DECL_OVERRIDE
+ const FaceCreationFailedCallback& onConnectFailed) DECL_OVERRIDE
{
}
- virtual std::list<shared_ptr<const Channel>>
+ virtual std::vector<shared_ptr<const Channel>>
getChannels() const DECL_OVERRIDE
{
return m_channels;
@@ -411,7 +411,7 @@
}
private:
- std::list<shared_ptr<const Channel> > m_channels;
+ std::vector<shared_ptr<const Channel>> m_channels;
};
BOOST_AUTO_TEST_CASE(ChannelDataset)