Remove dependency on Selectors and refactor codebase.

Change-Id: Ic3024b76ba0eea61f790c91c36090b4aa68702a3
Refs: #4522
diff --git a/tests/unit/index.cpp b/tests/unit/index.cpp
deleted file mode 100644
index 6f255a2..0000000
--- a/tests/unit/index.cpp
+++ /dev/null
@@ -1,373 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2014-2017, Regents of the University of California.
- *
- * This file is part of NDN repo-ng (Next generation of NDN repository).
- * See AUTHORS.md for complete list of repo-ng authors and contributors.
- *
- * repo-ng is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * repo-ng, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "storage/index.hpp"
-
-#include "../sqlite-fixture.hpp"
-#include "../dataset-fixtures.hpp"
-
-#include <iostream>
-
-#include <ndn-cxx/security/signing-helpers.hpp>
-#include <ndn-cxx/util/sha256.hpp>
-#include <ndn-cxx/util/random.hpp>
-
-#include <boost/mpl/push_back.hpp>
-#include <boost/test/unit_test.hpp>
-
-namespace repo {
-namespace tests {
-
-BOOST_AUTO_TEST_SUITE(Index)
-
-class FindFixture
-{
-protected:
-  FindFixture()
-    : m_index(std::numeric_limits<size_t>::max())
-  {
-  }
-
-  Name
-  insert(int id, const Name& name)
-  {
-    shared_ptr<Data> data = make_shared<Data>(name);
-    data->setContent(reinterpret_cast<const uint8_t*>(&id), sizeof(id));
-    m_keyChain.sign(*data, ndn::signingWithSha256());
-    data->wireEncode();
-    m_index.insert(*data, id);
-
-    return data->getFullName();
-  }
-
-  Interest&
-  startInterest(const Name& name)
-  {
-    m_interest = make_shared<Interest>(name);
-    return *m_interest;
-  }
-
-  int
-  find()
-  {
-    std::pair<int, Name> found = m_index.find(*m_interest);
-    return found.first;
-  }
-
-protected:
-  repo::Index m_index;
-  KeyChain m_keyChain;
-  shared_ptr<Interest> m_interest;
-};
-
-BOOST_FIXTURE_TEST_SUITE(Find, FindFixture)
-
-BOOST_AUTO_TEST_CASE(EmptyDataName)
-{
-  insert(1, "ndn:/");
-  startInterest("ndn:/");
-  BOOST_CHECK_EQUAL(find(), 1);
-}
-
-BOOST_AUTO_TEST_CASE(EmptyInterestName)
-{
-  insert(1, "ndn:/A");
-  startInterest("ndn:/");
-  BOOST_CHECK_EQUAL(find(), 1);
-}
-
-BOOST_AUTO_TEST_CASE(ExactName)
-{
-  insert(1, "ndn:/");
-  insert(2, "ndn:/A");
-  insert(3, "ndn:/A/B");
-  insert(4, "ndn:/A/C");
-  insert(5, "ndn:/D");
-
-  startInterest("ndn:/A");
-  BOOST_CHECK_EQUAL(find(), 2);
-}
-
-BOOST_AUTO_TEST_CASE(FullName)
-{
-  Name n1 = insert(1, "ndn:/A");
-  Name n2 = insert(2, "ndn:/A");
-
-  startInterest(n1);
-  BOOST_CHECK_EQUAL(find(), 1);
-
-  startInterest(n2);
-  BOOST_CHECK_EQUAL(find(), 2);
-}
-
-BOOST_AUTO_TEST_CASE(Leftmost)
-{
-  insert(1, "ndn:/A");
-  insert(2, "ndn:/B/p/1");
-  insert(3, "ndn:/B/p/2");
-  insert(4, "ndn:/B/q/1");
-  insert(5, "ndn:/B/q/2");
-  insert(6, "ndn:/C");
-
-  startInterest("ndn:/B");
-  BOOST_CHECK_EQUAL(find(), 2);
-}
-
-BOOST_AUTO_TEST_CASE(Rightmost)
-{
-  insert(1, "ndn:/A");
-  insert(2, "ndn:/B/p/1");
-  insert(3, "ndn:/B/p/2");
-  insert(4, "ndn:/B/q/1");
-  insert(5, "ndn:/B/q/2");
-  insert(6, "ndn:/C");
-
-  startInterest("ndn:/B")
-    .setChildSelector(1);
-  BOOST_CHECK_EQUAL(find(), 4);
-}
-
-BOOST_AUTO_TEST_CASE(MinSuffixComponents)
-{
-  insert(1, "ndn:/");
-  insert(2, "ndn:/A");
-  insert(3, "ndn:/B/1");
-  insert(4, "ndn:/C/1/2");
-  insert(5, "ndn:/D/1/2/3");
-  insert(6, "ndn:/E/1/2/3/4");
-
-  startInterest("ndn:/")
-    .setMinSuffixComponents(0);
-  BOOST_CHECK_EQUAL(find(), 1);
-
-  startInterest("ndn:/")
-    .setMinSuffixComponents(1);
-  BOOST_CHECK_EQUAL(find(), 1);
-
-  startInterest("ndn:/")
-    .setMinSuffixComponents(2);
-  BOOST_CHECK_EQUAL(find(), 2);
-
-  startInterest("ndn:/")
-    .setMinSuffixComponents(3);
-  BOOST_CHECK_EQUAL(find(), 3);
-
-  startInterest("ndn:/")
-    .setMinSuffixComponents(4);
-  BOOST_CHECK_EQUAL(find(), 4);
-
-  startInterest("ndn:/")
-    .setMinSuffixComponents(5);
-  BOOST_CHECK_EQUAL(find(), 5);
-
-  startInterest("ndn:/")
-    .setMinSuffixComponents(6);
-  BOOST_CHECK_EQUAL(find(), 6);
-
-  startInterest("ndn:/")
-    .setMinSuffixComponents(7);
-  BOOST_CHECK_EQUAL(find(), 0);
-}
-
-BOOST_AUTO_TEST_CASE(MaxSuffixComponents)
-{
-  insert(1, "ndn:/");
-  insert(2, "ndn:/A");
-  insert(3, "ndn:/B/2");
-  insert(4, "ndn:/C/2/3");
-  insert(5, "ndn:/D/2/3/4");
-  insert(6, "ndn:/E/2/3/4/5");
-
-  startInterest("ndn:/")
-    .setChildSelector(1)
-    .setMaxSuffixComponents(0);
-  BOOST_CHECK_EQUAL(find(), 0);
-
-  startInterest("ndn:/")
-    .setChildSelector(1)
-    .setMaxSuffixComponents(1);
-  BOOST_CHECK_EQUAL(find(), 1);
-
-  startInterest("ndn:/")
-    .setChildSelector(1)
-    .setMaxSuffixComponents(2);
-  BOOST_CHECK_EQUAL(find(), 2);
-
-  startInterest("ndn:/")
-    .setChildSelector(1)
-    .setMaxSuffixComponents(3);
-  BOOST_CHECK_EQUAL(find(), 3);
-
-  startInterest("ndn:/")
-    .setChildSelector(1)
-    .setMaxSuffixComponents(4);
-  BOOST_CHECK_EQUAL(find(), 4);
-
-  startInterest("ndn:/")
-    .setChildSelector(1)
-    .setMaxSuffixComponents(5);
-  BOOST_CHECK_EQUAL(find(), 5);
-
-  startInterest("ndn:/")
-    .setChildSelector(1)
-    .setMaxSuffixComponents(6);
-  BOOST_CHECK_EQUAL(find(), 6);
-
-  startInterest("ndn:/")
-    .setChildSelector(1)
-    .setMaxSuffixComponents(7);
-  BOOST_CHECK_EQUAL(find(), 6);
-}
-
-BOOST_AUTO_TEST_CASE(DigestOrder)
-{
-  insert(1, "ndn:/A");
-  insert(2, "ndn:/A");
-  // We don't know which comes first, but there must be some order
-
-  startInterest("ndn:/A")
-    .setChildSelector(0);
-  uint32_t leftmost = find();
-
-  startInterest("ndn:/A")
-    .setChildSelector(1);
-  uint32_t rightmost = find();
-
-  BOOST_CHECK_NE(leftmost, rightmost);
-}
-
-BOOST_AUTO_TEST_CASE(DigestExclude)
-{
-  insert(1, "ndn:/A");
-  Name n2 = insert(2, "ndn:/A");
-  insert(3, "ndn:/A/B");
-
-  uint8_t digest00[ndn::util::Sha256::DIGEST_SIZE];
-  std::fill_n(digest00, sizeof(digest00), 0x00);
-  uint8_t digestFF[ndn::util::Sha256::DIGEST_SIZE];
-  std::fill_n(digestFF, sizeof(digestFF), 0xFF);
-
-  Exclude excludeDigest;
-  excludeDigest.excludeRange(
-    name::Component::fromImplicitSha256Digest(digest00, sizeof(digest00)),
-    name::Component::fromImplicitSha256Digest(digestFF, sizeof(digestFF)));
-
-  startInterest("ndn:/A")
-    .setChildSelector(0)
-    .setExclude(excludeDigest);
-  BOOST_CHECK_EQUAL(find(), 3);
-
-  startInterest("ndn:/A")
-    .setChildSelector(1)
-    .setExclude(excludeDigest);
-  BOOST_CHECK_EQUAL(find(), 3);
-
-  Exclude excludeGeneric;
-  excludeGeneric.excludeAfter(name::Component(static_cast<uint8_t*>(nullptr), 0));
-
-  startInterest("ndn:/A")
-    .setChildSelector(0)
-    .setExclude(excludeGeneric);
-  int found1 = find();
-  BOOST_CHECK(found1 == 1 || found1 == 2);
-
-  startInterest("ndn:/A")
-    .setChildSelector(1)
-    .setExclude(excludeGeneric);
-  int found2 = find();
-  BOOST_CHECK(found2 == 1 || found2 == 2);
-
-  Exclude exclude2 = excludeGeneric;
-  exclude2.excludeOne(n2.get(-1));
-
-  startInterest("ndn:/A")
-    .setChildSelector(0)
-    .setExclude(exclude2);
-  BOOST_CHECK_EQUAL(find(), 1);
-
-  startInterest("ndn:/A")
-    .setChildSelector(1)
-    .setExclude(exclude2);
-  BOOST_CHECK_EQUAL(find(), 1);
-}
-
-BOOST_AUTO_TEST_SUITE_END() // Find
-
-
-template<class Dataset>
-class Fixture : public Dataset
-{
-public:
-  Fixture()
-    : index(65535)
-  {
-  }
-
-public:
-  std::map<int64_t, shared_ptr<Data> > idToDataMap;
-  repo::Index index;
-};
-
-// Combine CommonDatasets with ComplexSelectorDataset
-typedef boost::mpl::push_back<CommonDatasets,
-                              ComplexSelectorsDataset>::type Datasets;
-
-BOOST_FIXTURE_TEST_CASE_TEMPLATE(Bulk, T, Datasets, Fixture<T>)
-{
-  BOOST_TEST_MESSAGE(T::getName());
-
-  for (typename T::DataContainer::iterator i = this->data.begin();
-       i != this->data.end(); ++i)
-    {
-      int64_t id = std::abs(static_cast<int64_t>(ndn::random::generateWord64()));
-      this->idToDataMap.insert(std::make_pair(id, *i));
-
-      BOOST_CHECK_EQUAL(this->index.insert(**i, id), true);
-    }
-
-  BOOST_CHECK_EQUAL(this->index.size(), this->data.size());
-
-  for (typename T::InterestContainer::iterator i = this->interests.begin();
-       i != this->interests.end(); ++i)
-    {
-      std::pair<int64_t, Name> item = this->index.find(i->first);
-
-      BOOST_REQUIRE_GT(item.first, 0);
-      BOOST_REQUIRE(this->idToDataMap.count(item.first) > 0);
-
-      BOOST_TEST_MESSAGE(i->first);
-      BOOST_CHECK_EQUAL(*this->idToDataMap[item.first], *i->second);
-
-      BOOST_CHECK_EQUAL(this->index.hasData(*i->second), true);
-    }
-
-  // Need support for selector-based removal
-  // for (typename T::RemovalsContainer::iterator i = this->removals.begin();
-  //      i != this->removals.end(); ++i)
-  //   {
-  //     size_t nRemoved = 0;
-  //     BOOST_REQUIRE_NO_THROW(this->index.erase(*i));
-  //     BOOST_CHECK_EQUAL(nRemoved, i->seconds);
-  //   }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace tests
-} // namespace repo
diff --git a/tests/unit/repo-command-parameter.cpp b/tests/unit/repo-command-parameter.cpp
index 3e35169..f01832a 100644
--- a/tests/unit/repo-command-parameter.cpp
+++ b/tests/unit/repo-command-parameter.cpp
@@ -19,8 +19,12 @@
 
 #include "repo-command-parameter.hpp"
 
-#include <ndn-cxx/selectors.hpp>
+#include "common.hpp"
 
+#include <ndn-cxx/encoding/block.hpp>
+#include <ndn-cxx/encoding/block-helpers.hpp>
+
+#include <boost/lexical_cast.hpp>
 #include <boost/test/unit_test.hpp>
 
 namespace repo {
@@ -35,33 +39,21 @@
   parameter.setStartBlockId(1);
   parameter.setEndBlockId(100);
   parameter.setProcessId(1234567890);
-  ndn::Selectors selectors;
-  selectors.setMaxSuffixComponents(1);
-  parameter.setSelectors(selectors);
 
-  ndn::Block wire = parameter.wireEncode();
+  Block wire = parameter.wireEncode();
 
   // These octets are obtained by the snippet below.
   // This check is intended to detect unexpected encoding change in the future.
-  //for (auto it = wire.begin(); it != wire.end(); ++it) {
-  //  printf("0x%02x, ", *it);
-  //}
-  static const uint8_t expected[] = {
-    0xc9, 0x1c, 0x07, 0x09, 0x08, 0x01, 0x61, 0x08, 0x01, 0x62, 0x08,
-    0x01, 0x63, 0x09, 0x03, 0x0e, 0x01, 0x01, 0xcc, 0x01, 0x01, 0xcd,
-    0x01, 0x64, 0xce, 0x04, 0x49, 0x96, 0x02, 0xd2
-  };
+  // Construct a \c Block from hexadecimal \p input.
+  Block expected = "C917 0709080161080162080163CC0101CD0164CE04499602D2"_block;
 
-  BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected),
-                                  wire.begin(), wire.end());
+  BOOST_CHECK_EQUAL(wire, expected);
 
   repo::RepoCommandParameter decoded(wire);
   BOOST_CHECK_EQUAL(decoded.getName(), parameter.getName());
   BOOST_CHECK_EQUAL(decoded.getStartBlockId(), parameter.getStartBlockId());
   BOOST_CHECK_EQUAL(decoded.getEndBlockId(), parameter.getEndBlockId());
   BOOST_CHECK_EQUAL(decoded.getProcessId(), parameter.getProcessId());
-  BOOST_CHECK_EQUAL(decoded.getSelectors().getMaxSuffixComponents(),
-                    parameter.getSelectors().getMaxSuffixComponents());
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/unit/repo-command-response.cpp b/tests/unit/repo-command-response.cpp
index 7686c50..057b180 100644
--- a/tests/unit/repo-command-response.cpp
+++ b/tests/unit/repo-command-response.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2018, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -19,6 +19,8 @@
 
 #include "repo-command-response.hpp"
 
+#include "common.hpp"
+
 #include <boost/test/unit_test.hpp>
 
 namespace repo {
@@ -36,21 +38,15 @@
   response.setInsertNum(100);
   response.setDeleteNum(100);
 
-  ndn::Block wire = response.wireEncode();
+  Block wire = response.wireEncode();
 
   // These octets are obtained by the snippet below.
   // This check is intended to detect unexpected encoding change in the future.
-  //for (auto it = wire.begin(); it != wire.end(); ++it) {
-  //  printf("0x%02x, ", *it);
-  //}
-  static const uint8_t expected[] = {
-    0xcf, 0x16, 0xce, 0x04, 0x49, 0x96, 0x02, 0xd2, 0xd0, 0x02,
-    0x01, 0x94, 0xcc, 0x01, 0x01, 0xcd, 0x01, 0x64, 0xd1, 0x01,
-    0x64, 0xd2, 0x01, 0x64
-  };
+  // Construct a \c Block from hexadecimal \p input.
 
-  BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected),
-                                  wire.begin(), wire.end());
+  Block expected = "CF16 CE04499602D2D0020194CC0101CD0164D10164D20164"_block;
+
+  BOOST_CHECK_EQUAL(wire, expected);
 
   repo::RepoCommandResponse decoded(wire);
   BOOST_CHECK_EQUAL(decoded.getCode(), response.getCode());
diff --git a/tests/unit/repo-storage.cpp b/tests/unit/repo-storage.cpp
index 1caecf1..0458c23 100644
--- a/tests/unit/repo-storage.cpp
+++ b/tests/unit/repo-storage.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017, Regents of the University of California.
+ * Copyright (c) 2014-2018, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -37,41 +37,31 @@
 {
 };
 
-// Combine CommonDatasets with ComplexSelectorDataset
-typedef boost::mpl::push_back<CommonDatasets,
-                              ComplexSelectorsDataset>::type Datasets;
 
-BOOST_FIXTURE_TEST_CASE_TEMPLATE(Bulk, T, Datasets, Fixture<T>)
+BOOST_FIXTURE_TEST_CASE_TEMPLATE(Bulk, T, CommonDatasets, Fixture<T>)
 {
-  // typedef ComplexSelectorsDataset T;
   BOOST_TEST_MESSAGE(T::getName());
 
   // Insert data into repo
-  for (typename T::DataContainer::iterator i = this->data.begin();
-       i != this->data.end(); ++i)
-    {
-      BOOST_CHECK_EQUAL(this->handle->insertData(**i), true);
-    }
+  for (auto i = this->data.begin(); i != this->data.end(); ++i) {
+    BOOST_CHECK_EQUAL(this->handle->insertData(**i), true);
+  }
 
   // check size directly with the storage (repo doesn't have interface yet)
   BOOST_CHECK_EQUAL(this->store->size(), static_cast<int64_t>(this->data.size()));
 
   // Read
-  for (typename T::InterestContainer::iterator i = this->interests.begin();
-       i != this->interests.end(); ++i)
-  {
-      shared_ptr<ndn::Data> dataTest = this->handle->readData(i->first);
-      BOOST_CHECK_EQUAL(*this->handle->readData(i->first), *i->second);
-    }
+  for (auto i = this->interests.begin(); i != this->interests.end(); ++i) {
+    std::shared_ptr<ndn::Data> dataTest = this->handle->readData(i->first);
+    BOOST_CHECK_EQUAL(*dataTest, *i->second);
+  }
 
   // Remove items
-  for (typename T::RemovalsContainer::iterator i = this->removals.begin();
-       i != this->removals.end(); ++i)
-    {
-      size_t nRemoved = 0;
-      BOOST_REQUIRE_NO_THROW(nRemoved = this->handle->deleteData(i->first));
-      BOOST_CHECK_EQUAL(nRemoved, i->second);
-    }
+  for (auto i = this->removals.begin(); i != this->removals.end(); ++i) {
+    size_t nRemoved = 0;
+    nRemoved = this->handle->deleteData(i->first);
+    BOOST_CHECK_EQUAL(nRemoved, i->second);
+  }
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/unit/sqlite-handle.cpp b/tests/unit/sqlite-handle.cpp
index ca7c7dd..9cfb0bf 100644
--- a/tests/unit/sqlite-handle.cpp
+++ b/tests/unit/sqlite-handle.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2017, Regents of the University of California.
+ * Copyright (c) 2014-2018, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -34,40 +34,40 @@
 class Fixture : public SqliteFixture, public Dataset
 {
 public:
-  std::map<int64_t, shared_ptr<Data>> idToDataMap;
+  std::map<Name, std::shared_ptr<Data>> nameToDataMap;
 };
 
 BOOST_FIXTURE_TEST_CASE_TEMPLATE(InsertReadDelete, T, CommonDatasets, Fixture<T>)
 {
   BOOST_TEST_CHECKPOINT(T::getName());
 
-  std::vector<int64_t> ids;
+  std::vector<Name> names;
 
   // Insert
-  for (typename T::DataContainer::iterator i = this->data.begin();
+  for (auto i = this->data.begin();
        i != this->data.end(); ++i) {
-    int64_t id = -1;
-    BOOST_REQUIRE_NO_THROW(id = this->handle->insert(**i));
-
-    this->idToDataMap.insert(std::make_pair(id, *i));
-    ids.push_back(id);
+    Name name = Name();
+    this->handle->insert(**i);
+    name = (*i)->getFullName();
+    this->nameToDataMap.insert(std::make_pair(name, *i));
+    names.push_back(name);
   }
   BOOST_CHECK_EQUAL(this->handle->size(), static_cast<int64_t>(this->data.size()));
 
   std::mt19937 rng{std::random_device{}()};
-  std::shuffle(ids.begin(), ids.end(), rng);
+  std::shuffle(names.begin(), names.end(), rng);
 
   // Read (all items should exist)
-  for (std::vector<int64_t>::iterator i = ids.begin(); i != ids.end(); ++i) {
-    shared_ptr<Data> retrievedData = this->handle->read(*i);
+  for (auto i = names.begin(); i != names.end(); ++i) {
+    std::shared_ptr<Data> retrievedData = this->handle->read(*i);
 
-    BOOST_REQUIRE(this->idToDataMap.count(*i) > 0);
-    BOOST_CHECK_EQUAL(*this->idToDataMap[*i], *retrievedData);
+    BOOST_REQUIRE(this->nameToDataMap.count(*i) > 0);
+    BOOST_CHECK_EQUAL(*this->nameToDataMap[*i], *retrievedData);
   }
   BOOST_CHECK_EQUAL(this->handle->size(), static_cast<int64_t>(this->data.size()));
 
   // Delete
-  for (std::vector<int64_t>::iterator i = ids.begin(); i != ids.end(); ++i) {
+  for (auto i = names.begin(); i != names.end(); ++i) {
     BOOST_CHECK_EQUAL(this->handle->erase(*i), true);
   }
 
diff --git a/tests/unit/tcp-bulk-insert-handle.cpp b/tests/unit/tcp-bulk-insert-handle.cpp
index f35a42f..48ec17d 100644
--- a/tests/unit/tcp-bulk-insert-handle.cpp
+++ b/tests/unit/tcp-bulk-insert-handle.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  Regents of the University of California.
+ * Copyright (c) 2014-2018,  Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -57,17 +57,16 @@
     ip::tcp::endpoint serverEndpoint = *endpoint;
 
     socket.async_connect(serverEndpoint,
-                         bind(&TcpClient::onSuccessfullConnect, this, _1));
+                         std::bind(&TcpClient::onSuccessfullConnect, this, _1));
   }
 
   virtual void
   onSuccessfullConnect(const boost::system::error_code& error)
   {
-    if (error)
-      {
-        BOOST_FAIL("TCP connection aborted");
-        return;
-      }
+    if (error) {
+      BOOST_FAIL("TCP connection aborted");
+      return;
+    }
   }
 
 public:
@@ -86,7 +85,7 @@
     , bulkInserter(ioService, *handle)
   {
     guardEvent = scheduler.scheduleEvent(ndn::time::seconds(2),
-                                         bind(&TcpBulkInsertFixture::fail, this, "Test timed out"));
+                                         std::bind(&TcpBulkInsertFixture::fail, this, "Test timed out"));
   }
 
   virtual void
@@ -102,15 +101,12 @@
     // described in http://www.boost.org/doc/libs/1_48_0/doc/html/boost_asio/overview/implementation.html,
     // scatter-gather is limited to at most `min(64,IOV_MAX)` buffers to be transmitted
     // in a single operation
-    for (typename Dataset::DataContainer::iterator i = this->data.begin();
-         i != this->data.end(); ++i) {
+    for (auto i = this->data.begin(); i != this->data.end(); ++i) {
 
-      socket.async_send(boost::asio::buffer((*i)->wireEncode().wire(),  (*i)->wireEncode().size()),
-                        bind(&TcpBulkInsertFixture::onSendFinished, this, _1, false));
+      socket.async_send(boost::asio::buffer((*i)->wireEncode().wire(), (*i)->wireEncode().size()),
+                        std::bind(&TcpBulkInsertFixture::onSendFinished, this, _1, false));
     }
-
-    socket.async_send(boost::asio::buffer(static_cast<const uint8_t*>(0), 0),
-                      bind(&TcpBulkInsertFixture::onSendFinished, this, _1, true));
+    onSendFinished(error, true);
   }
 
   void
@@ -127,7 +123,7 @@
       // In case there are some outstanding handlers
       // ioService.post(bind(&TcpBulkInsertFixture::stop, this));
       scheduler.scheduleEvent(ndn::time::seconds(1),
-                              bind(&TcpBulkInsertFixture::stop, this));
+                              std::bind(&TcpBulkInsertFixture::stop, this));
     }
   }
 
@@ -170,9 +166,8 @@
   this->ioService.run();
 
   // Read (all items should exist)
-  for (typename T::InterestContainer::iterator i = this->interests.begin();
-       i != this->interests.end(); ++i) {
-      BOOST_CHECK_EQUAL(*this->handle->readData(i->first), *i->second);
+  for (auto i = this->interests.begin(); i != this->interests.end(); ++i) {
+    BOOST_CHECK_EQUAL(*this->handle->readData(i->first), *i->second);
   }
 }