Move non-public classes and functions to psync::detail namespace

CompressionScheme, CompressionError, and MissingDataInfo, which are
public types, are instead moved to a new header PSync/common.hpp

Change-Id: If1b8cb037cb321ff32c080c67df9dc3689223c00
diff --git a/tests/test-bloom-filter.cpp b/tests/test-bloom-filter.cpp
index 1788cd1..a33c088 100644
--- a/tests/test-bloom-filter.cpp
+++ b/tests/test-bloom-filter.cpp
@@ -24,8 +24,7 @@
 #include <ndn-cxx/name.hpp>
 
 namespace psync {
-
-using namespace ndn;
+namespace detail {
 
 BOOST_AUTO_TEST_SUITE(TestBloomFilter)
 
@@ -40,7 +39,7 @@
 
 BOOST_AUTO_TEST_CASE(NameAppendAndExtract)
 {
-  Name bfName("/test");
+  ndn::Name bfName("/test");
   BloomFilter bf(100, 0.001);
   bf.insert("/memphis");
   bf.appendToName(bfName);
@@ -56,4 +55,5 @@
 
 BOOST_AUTO_TEST_SUITE_END()
 
+} // namespace detail
 } // namespace psync
diff --git a/tests/test-full-producer.cpp b/tests/test-full-producer.cpp
index 2693421..f2c4a13 100644
--- a/tests/test-full-producer.cpp
+++ b/tests/test-full-producer.cpp
@@ -18,11 +18,11 @@
  **/
 
 #include "PSync/full-producer.hpp"
+#include "PSync/detail/util.hpp"
 
 #include "tests/boost-test.hpp"
 #include "tests/io-fixture.hpp"
 
-#include <ndn-cxx/name.hpp>
 #include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
 #include <ndn-cxx/util/dummy-client-face.hpp>
 
@@ -80,7 +80,7 @@
   BOOST_CHECK_NO_THROW(node.onSyncData(syncInterest, badCompress));
 
   const uint8_t test[] = {'t', 'e', 's', 't'};
-  auto goodCompressBadBlock = compress(node.m_contentCompression, &test[0], sizeof(test));
+  auto goodCompressBadBlock = detail::compress(node.m_contentCompression, test, sizeof(test));
   BOOST_CHECK_NO_THROW(node.onSyncData(syncInterest, goodCompressBadBlock));
 }
 
diff --git a/tests/test-full-sync.cpp b/tests/test-full-sync.cpp
index 0d2b0ee..8fd5100 100644
--- a/tests/test-full-sync.cpp
+++ b/tests/test-full-sync.cpp
@@ -20,11 +20,11 @@
 #include "PSync/full-producer.hpp"
 #include "PSync/consumer.hpp"
 #include "PSync/detail/state.hpp"
+#include "PSync/detail/util.hpp"
 
 #include "tests/boost-test.hpp"
 #include "tests/io-fixture.hpp"
 
-#include <ndn-cxx/name.hpp>
 #include <ndn-cxx/util/dummy-client-face.hpp>
 
 namespace psync {
@@ -390,7 +390,7 @@
   addNode(0);
 
   int i = 0;
-  State state;
+  detail::State state;
   std::shared_ptr<Buffer> compressed;
   do {
     Name prefixToPublish("userNode0-" + to_string(i++));
@@ -400,13 +400,13 @@
     state.addContent(Name(prefixToPublish).appendNumber(nodes[0]->m_prefixes[prefixToPublish]));
 
     auto block = state.wireEncode();
-    compressed = compress(nodes[0]->m_contentCompression, block.wire(), block.size());
+    compressed = detail::compress(nodes[0]->m_contentCompression, block.wire(), block.size());
   } while (compressed->size() < (MAX_NDN_PACKET_SIZE >> 1));
 
   advanceClocks(ndn::time::milliseconds(10), 100);
 
   Name syncInterestName(syncPrefix);
-  IBLT iblt(40, nodes[0]->m_ibltCompression);
+  detail::IBLT iblt(40, nodes[0]->m_ibltCompression);
   iblt.appendToName(syncInterestName);
 
   nodes[0]->onSyncInterest(syncPrefix, Interest(syncInterestName));
diff --git a/tests/test-iblt.cpp b/tests/test-iblt.cpp
index c689596..c015a19 100644
--- a/tests/test-iblt.cpp
+++ b/tests/test-iblt.cpp
@@ -22,9 +22,8 @@
 
 #include "tests/boost-test.hpp"
 
-#include <ndn-cxx/interest.hpp>
-
 namespace psync {
+namespace detail {
 
 using namespace ndn;
 
@@ -32,7 +31,7 @@
 
 BOOST_AUTO_TEST_CASE(Equal)
 {
-  int size = 10;
+  const size_t size = 10;
 
   IBLT iblt1(size, CompressionScheme::DEFAULT);
   IBLT iblt2(size, CompressionScheme::DEFAULT);
@@ -107,7 +106,7 @@
 
 BOOST_AUTO_TEST_CASE(CopyInsertErase)
 {
-  int size = 10;
+  const size_t size = 10;
 
   IBLT iblt1(size, CompressionScheme::DEFAULT);
 
@@ -136,7 +135,8 @@
 {
   // The case where we can't recognize if the rcvd IBF has higher sequence number
   // Relevant to full sync case
-  int size = 10;
+
+  const size_t size = 10;
 
   IBLT ownIBF(size, CompressionScheme::DEFAULT);
   IBLT rcvdIBF(size, CompressionScheme::DEFAULT);
@@ -160,10 +160,9 @@
 
 BOOST_AUTO_TEST_CASE(Difference)
 {
-  int size = 10;
+  const size_t size = 10;
 
   IBLT ownIBF(size, CompressionScheme::DEFAULT);
-
   IBLT rcvdIBF = ownIBF;
 
   IBLT diff = ownIBF - rcvdIBF;
@@ -200,7 +199,7 @@
   // Check that we can still list the difference
   // even though we can't list the IBFs itself
 
-  int size = 10;
+  const size_t size = 10;
 
   IBLT ownIBF(size, CompressionScheme::DEFAULT);
 
@@ -231,4 +230,5 @@
 
 BOOST_AUTO_TEST_SUITE_END()
 
+} // namespace detail
 } // namespace psync
diff --git a/tests/test-partial-producer.cpp b/tests/test-partial-producer.cpp
index 3f5de4c..bfbcc12 100644
--- a/tests/test-partial-producer.cpp
+++ b/tests/test-partial-producer.cpp
@@ -82,7 +82,7 @@
   syncInterestName.append("sync");
   Name syncInterestPrefix = syncInterestName;
 
-  BloomFilter bf(20, 0.001);
+  detail::BloomFilter bf(20, 0.001);
   bf.appendToName(syncInterestName);
 
   producer.m_iblt.appendToName(syncInterestName);
@@ -133,7 +133,7 @@
   // Sync interest with malicious IBF
   syncInterestName = syncPrefix;
   syncInterestName.append("sync");
-  BloomFilter bf(20, 0.001);
+  detail::BloomFilter bf(20, 0.001);
   bf.appendToName(syncInterestName);
   syncInterestName.append("fake-name");
   BOOST_CHECK_NO_THROW(producer.onSyncInterest(syncInterestName, Interest(syncInterestName)));
diff --git a/tests/test-producer-base.cpp b/tests/test-producer-base.cpp
index 4320e83..8e9dd77 100644
--- a/tests/test-producer-base.cpp
+++ b/tests/test-producer-base.cpp
@@ -18,7 +18,6 @@
  **/
 
 #include "PSync/producer-base.hpp"
-#include "PSync/detail/util.hpp"
 
 #include "tests/boost-test.hpp"
 
@@ -32,7 +31,7 @@
 
 BOOST_AUTO_TEST_SUITE(TestProducerBase)
 
-BOOST_AUTO_TEST_CASE(Ctor)
+BOOST_AUTO_TEST_CASE(Constructor)
 {
   util::DummyClientFace face;
   BOOST_REQUIRE_NO_THROW(ProducerBase(40, face, Name("/psync"), Name("/testUser")));
diff --git a/tests/test-segment-publisher.cpp b/tests/test-segment-publisher.cpp
index bf437b9..4874c49 100644
--- a/tests/test-segment-publisher.cpp
+++ b/tests/test-segment-publisher.cpp
@@ -25,9 +25,9 @@
 
 #include <ndn-cxx/data.hpp>
 #include <ndn-cxx/interest.hpp>
+#include <ndn-cxx/security/validator-null.hpp>
 #include <ndn-cxx/util/dummy-client-face.hpp>
 #include <ndn-cxx/util/segment-fetcher.hpp>
-#include <ndn-cxx/security/validator-null.hpp>
 
 namespace psync {
 
@@ -88,7 +88,7 @@
   shared_ptr<util::SegmentFetcher> fetcher;
   Name dataName;
   time::milliseconds freshness = 1_s;
-  State state;
+  detail::State state;
 
   int numComplete = 0;
   int numRepliesFromStore = 0;
diff --git a/tests/test-state.cpp b/tests/test-state.cpp
index 3f04c8b..0e31a67 100644
--- a/tests/test-state.cpp
+++ b/tests/test-state.cpp
@@ -24,8 +24,7 @@
 #include <ndn-cxx/data.hpp>
 
 namespace psync {
-
-using namespace ndn;
+namespace detail {
 
 BOOST_AUTO_TEST_SUITE(TestState)
 
@@ -36,17 +35,14 @@
   state.addContent(ndn::Name("test2"));
 
   // Simulate getting buffer content from segment fetcher
-  Data data;
+  ndn::Data data;
   data.setContent(state.wireEncode());
   ndn::Buffer buffer(data.getContent().value_size());
   std::copy(data.getContent().value_begin(),
             data.getContent().value_end(),
             buffer.begin());
 
-  ndn::ConstBufferPtr bufferPtr = make_shared<ndn::Buffer>(buffer);
-
-  ndn::Block block(std::move(bufferPtr));
-
+  ndn::Block block(std::make_shared<ndn::Buffer>(buffer));
   State rcvdState;
   rcvdState.wireDecode(block);
 
@@ -58,16 +54,14 @@
   State state;
 
   // Simulate getting buffer content from segment fetcher
-  Data data;
+  ndn::Data data;
   data.setContent(state.wireEncode());
   ndn::Buffer buffer(data.getContent().value_size());
   std::copy(data.getContent().value_begin(),
             data.getContent().value_end(),
             buffer.begin());
-  ndn::ConstBufferPtr bufferPtr = make_shared<ndn::Buffer>(buffer);
 
-  ndn::Block block(std::move(bufferPtr));
-
+  ndn::Block block(std::make_shared<ndn::Buffer>(buffer));
   BOOST_CHECK_NO_THROW(State state2(block));
 
   State state2(block);
@@ -90,4 +84,5 @@
 
 BOOST_AUTO_TEST_SUITE_END()
 
+} // namespace detail
 } // namespace psync
diff --git a/tests/test-util.cpp b/tests/test-util.cpp
index bea4e68..e37957a 100644
--- a/tests/test-util.cpp
+++ b/tests/test-util.cpp
@@ -22,10 +22,11 @@
 #include "tests/boost-test.hpp"
 
 namespace psync {
+namespace detail {
 
 BOOST_AUTO_TEST_SUITE(TestUtil)
 
-BOOST_AUTO_TEST_CASE(Basic)
+BOOST_AUTO_TEST_CASE(Compression)
 {
   std::vector<CompressionScheme> available = {CompressionScheme::ZLIB, CompressionScheme::GZIP,
                                               CompressionScheme::BZIP2, CompressionScheme::LZMA,
@@ -49,6 +50,9 @@
   supported.push_back(CompressionScheme::ZSTD);
 #endif
 
+  std::set_difference(available.begin(), available.end(), supported.begin(), supported.end(),
+                      std::inserter(notSupported, notSupported.begin()));
+
   const uint8_t uncompressed[] = {'t', 'e', 's', 't'};
 
   for (const auto& s : supported) {
@@ -57,17 +61,13 @@
     BOOST_CHECK_NO_THROW(decompress(s, compressed->data(), compressed->size()));
   }
 
-  std::set_difference(available.begin(), available.end(), supported.begin(), supported.end(),
-                      std::inserter(notSupported, notSupported.begin()));
-
   for (const auto& s : notSupported) {
-    BOOST_CHECK_THROW(compress(s, uncompressed, sizeof(uncompressed)),
-                      std::runtime_error);
-    BOOST_CHECK_THROW(decompress(s, uncompressed, sizeof(uncompressed)),
-                      std::runtime_error);
+    BOOST_CHECK_THROW(compress(s, uncompressed, sizeof(uncompressed)), CompressionError);
+    BOOST_CHECK_THROW(decompress(s, uncompressed, sizeof(uncompressed)), CompressionError);
   }
 }
 
 BOOST_AUTO_TEST_SUITE_END()
 
+} // namespace detail
 } // namespace psync