fw: FaceTable iterator dereferences to Face& instead of shared_ptr
This commit also improves the speed and reliability of
Mgmt/TestFaceManager/CreateFace test suite.
refs #3205
Change-Id: Idd013488ced2d7f8072ef8a3d910f94da2e0c8ac
diff --git a/tests/daemon/fw/face-table.t.cpp b/tests/daemon/fw/face-table.t.cpp
index 4616efb..e8962b8 100644
--- a/tests/daemon/fw/face-table.t.cpp
+++ b/tests/daemon/fw/face-table.t.cpp
@@ -113,41 +113,31 @@
BOOST_CHECK_EQUAL(std::distance(faceTable.begin(), faceTable.end()), faceTable.size());
hasFace1 = hasFace2 = false;
for (FaceTable::const_iterator it = faceTable.begin(); it != faceTable.end(); ++it) {
- if (*it == face1) {
- hasFace1 = true;
- }
+ hasFace1 = hasFace1 || &*it == face1.get();
}
- BOOST_CHECK(hasFace1);
+ BOOST_CHECK_EQUAL(hasFace1, true);
faceTable.add(face2);
BOOST_CHECK_EQUAL(faceTable.size(), 2);
BOOST_CHECK_EQUAL(std::distance(faceTable.begin(), faceTable.end()), faceTable.size());
hasFace1 = hasFace2 = false;
for (FaceTable::const_iterator it = faceTable.begin(); it != faceTable.end(); ++it) {
- if (*it == face1) {
- hasFace1 = true;
- }
- if (*it == face2) {
- hasFace2 = true;
- }
+ hasFace1 = hasFace1 || &*it == face1.get();
+ hasFace2 = hasFace2 || &*it == face2.get();
}
- BOOST_CHECK(hasFace1);
- BOOST_CHECK(hasFace2);
+ BOOST_CHECK_EQUAL(hasFace1, true);
+ BOOST_CHECK_EQUAL(hasFace2, true);
face1->close();
BOOST_CHECK_EQUAL(faceTable.size(), 1);
BOOST_CHECK_EQUAL(std::distance(faceTable.begin(), faceTable.end()), faceTable.size());
hasFace1 = hasFace2 = false;
for (FaceTable::const_iterator it = faceTable.begin(); it != faceTable.end(); ++it) {
- if (*it == face1) {
- hasFace1 = true;
- }
- if (*it == face2) {
- hasFace2 = true;
- }
+ hasFace1 = hasFace1 || &*it == face1.get();
+ hasFace2 = hasFace2 || &*it == face2.get();
}
- BOOST_CHECK(!hasFace1);
- BOOST_CHECK(hasFace2);
+ BOOST_CHECK_EQUAL(hasFace1, false);
+ BOOST_CHECK_EQUAL(hasFace2, true);
}
BOOST_AUTO_TEST_SUITE_END() // TestFaceTable
diff --git a/tests/daemon/fw/strategy.t.cpp b/tests/daemon/fw/strategy.t.cpp
index 90654d7..7a15df4 100644
--- a/tests/daemon/fw/strategy.t.cpp
+++ b/tests/daemon/fw/strategy.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,6 +27,8 @@
#include "dummy-strategy.hpp"
#include "tests/daemon/face/dummy-face.hpp"
#include <boost/range/adaptor/filtered.hpp>
+#include <boost/range/adaptor/transformed.hpp>
+#include <boost/range/algorithm/copy.hpp>
#include "tests/test-common.hpp"
@@ -58,14 +60,15 @@
getLocalFaces()
{
auto enumerable = this->getFaceTable() |
- boost::adaptors::filtered([] (shared_ptr<Face> face) {
- return face->getScope() == ndn::nfd::FACE_SCOPE_LOCAL;
+ boost::adaptors::filtered([] (Face& face) {
+ return face.getScope() == ndn::nfd::FACE_SCOPE_LOCAL;
+ }) |
+ boost::adaptors::transformed([] (Face& face) {
+ return face.getId();
});
std::vector<FaceId> results;
- for (shared_ptr<Face> face : enumerable) {
- results.push_back(face->getId());
- }
+ boost::copy(enumerable, std::back_inserter(results));
return results;
}