name: Add std::hash<Name> to support unordered_map container
Change-Id: I1edda483340fc5a891b6ae3a9cc4baf39b859621
Refs: #2147
diff --git a/tests/unit-tests/test-name.cpp b/tests/unit-tests/test-name.cpp
index 785321a..f10cf0a 100644
--- a/tests/unit-tests/test-name.cpp
+++ b/tests/unit-tests/test-name.cpp
@@ -24,6 +24,7 @@
#include "boost-test.hpp"
#include <boost/tuple/tuple.hpp>
#include <boost/mpl/vector.hpp>
+#include <unordered_map>
namespace ndn {
@@ -274,6 +275,21 @@
BOOST_CHECK_EQUAL(number, 11676);
}
+BOOST_AUTO_TEST_CASE(UnorderedMap)
+{
+ std::unordered_map<Name, int> map;
+ Name name1("/1");
+ Name name2("/2");
+ Name name3("/3");
+ map[name1] = 1;
+ map[name2] = 2;
+ map[name3] = 3;
+
+ BOOST_CHECK_EQUAL(map[name1], 1);
+ BOOST_CHECK_EQUAL(map[name2], 2);
+ BOOST_CHECK_EQUAL(map[name3], 3);
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace ndn