Fix LeafContainer

Change-Id: Ie708e64c1d30751d902f99d17ce0cae0c8d5d08a
diff --git a/tests/unit-tests/test-leaf.cpp b/tests/unit-tests/test-leaf.cpp
index a8f3101..5553a05 100644
--- a/tests/unit-tests/test-leaf.cpp
+++ b/tests/unit-tests/test-leaf.cpp
@@ -17,7 +17,9 @@
  * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+
 #include "leaf.hpp"
+#include "leaf-container.hpp"
 #include <ndn-cxx/encoding/buffer-stream.hpp>
 
 #include "boost-test.hpp"
@@ -63,6 +65,62 @@
   BOOST_CHECK(*result == *digest);
 }
 
+BOOST_AUTO_TEST_CASE(Container)
+{
+  LeafPtr leaf1 = make_shared<Leaf>(Name("/test/name"), 1, 10);
+  LeafPtr leaf2 = make_shared<Leaf>(Name("/test/name"), 2, 10);
+
+  LeafContainer container;
+
+  container.insert(leaf1);
+  container.insert(leaf2);
+
+  Name idx1("/test/name");
+  idx1.appendNumber(1);
+
+  Name idx2("/test/name");
+  idx2.appendNumber(2);
+
+  Name idx3("/test/name");
+  idx3.appendNumber(3);
+
+  Name idx4("/test/mane");
+  idx4.appendNumber(4);
+
+  LeafContainer::index<hashed>::type& hashedIndex = container.get<hashed>();
+
+  BOOST_CHECK_EQUAL(container.get<ordered>().size(), 2);
+  BOOST_CHECK_EQUAL(container.get<hashed>().size(), 2);
+  BOOST_CHECK(container.find(idx1) != container.end());
+  BOOST_CHECK(container.find(idx2) != container.end());
+  BOOST_CHECK(container.find(idx3) == container.end());
+
+  BOOST_CHECK(hashedIndex.find(idx1) != hashedIndex.end());
+  BOOST_CHECK(hashedIndex.find(idx2) != hashedIndex.end());
+  BOOST_CHECK(hashedIndex.find(idx3) == hashedIndex.end());
+
+  LeafPtr leaf3 = make_shared<Leaf>(Name("/test/mane"), 3, 10);
+  container.insert(leaf3);
+
+  Name idx0("/test/mane");
+  idx0.appendNumber(3);
+
+  LeafContainer::index<ordered>::type::iterator it = container.get<ordered>().begin();
+  BOOST_CHECK_EQUAL((*it)->getSessionName(), idx0);
+  it++;
+  BOOST_REQUIRE(it != container.get<ordered>().end());
+  BOOST_CHECK_EQUAL((*it)->getSessionName(), idx1);
+  it++;
+  BOOST_REQUIRE(it != container.get<ordered>().end());
+  BOOST_CHECK_EQUAL((*it)->getSessionName(), idx2);
+
+
+  BOOST_CHECK(hashedIndex.find(idx0) != hashedIndex.end());
+  BOOST_CHECK(hashedIndex.find(idx1) != hashedIndex.end());
+  BOOST_CHECK(hashedIndex.find(idx2) != hashedIndex.end());
+  BOOST_CHECK(hashedIndex.find(idx4) == hashedIndex.end());
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace test