Use more C++17 features
Mainly structured bindings, inline variables, and class template
argument deduction, plus many more smaller things.
Change-Id: I810d17e0adb470426e4e30c898e03b3140ad052f
diff --git a/tests/daemon/table/name-tree.t.cpp b/tests/daemon/table/name-tree.t.cpp
index 2649834..6c410aa 100644
--- a/tests/daemon/table/name-tree.t.cpp
+++ b/tests/daemon/table/name-tree.t.cpp
@@ -56,6 +56,7 @@
}
BOOST_AUTO_TEST_SUITE(Hashtable)
+
using name_tree::Hashtable;
BOOST_AUTO_TEST_CASE(Modifiers)
@@ -256,7 +257,7 @@
npe.insertPitEntry(pit2);
BOOST_CHECK_EQUAL(npe.getPitEntries().size(), 2);
- pit::Entry* pit1ptr = pit1.get();
+ auto* pit1ptr = pit1.get();
weak_ptr<pit::Entry> pit1weak(pit1);
pit1.reset();
BOOST_CHECK_EQUAL(pit1weak.use_count(), 1); // npe is the sole owner of pit1
@@ -338,7 +339,6 @@
Entry* npe0 = nt.findExactMatch(name0);
BOOST_CHECK(npe0 == nullptr);
-
// findLongestPrefixMatch
Entry* temp = nullptr;
@@ -493,12 +493,10 @@
}
protected:
- static const size_t N_BUCKETS = 16;
+ static constexpr size_t N_BUCKETS = 16;
NameTree nt;
};
-const size_t EnumerationFixture::N_BUCKETS;
-
BOOST_FIXTURE_TEST_CASE(IteratorFullEnumerate, EnumerationFixture)
{
nt.lookup("/a/b/c");
@@ -556,7 +554,7 @@
// Accept "root" nameA only
auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) {
- return std::make_pair(entry.getName() == "/a", true);
+ return std::pair(entry.getName() == "/a", true);
});
EnumerationVerifier(enumerable)
@@ -570,7 +568,7 @@
// Accept anything except "root" nameA
auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) {
- return std::make_pair(entry.getName() != "/a", true);
+ return std::pair(entry.getName() != "/a", true);
});
EnumerationVerifier(enumerable)
@@ -586,7 +584,7 @@
// No NameA
// No SubTree from NameAB
auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) {
- return std::make_pair(entry.getName() != "/a", entry.getName() != "/a/b");
+ return std::pair(entry.getName() != "/a", entry.getName() != "/a/b");
});
EnumerationVerifier(enumerable)
@@ -604,7 +602,7 @@
// No NameA
// No SubTree from NameAC
auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) {
- return std::make_pair(entry.getName() != "/a", entry.getName() != "/a/c");
+ return std::pair(entry.getName() != "/a", entry.getName() != "/a/c");
});
EnumerationVerifier(enumerable)
@@ -621,7 +619,7 @@
// No Subtree from NameA
auto&& enumerable = nt.partialEnumerate("/a", [] (const Entry& entry) {
- return std::make_pair(true, entry.getName() != "/a");
+ return std::pair(true, entry.getName() != "/a");
});
EnumerationVerifier(enumerable)
@@ -647,23 +645,20 @@
nt.lookup("/E");
nt.lookup("/F");
- auto&& enumerable = nt.partialEnumerate("/A",
- [] (const Entry& entry) {
- bool visitEntry = false;
- bool visitChildren = false;
+ auto&& enumerable = nt.partialEnumerate("/A", [] (const Entry& entry) {
+ bool visitEntry = false;
+ bool visitChildren = false;
- Name name = entry.getName();
+ const Name& name = entry.getName();
+ if (name == "/" || name == "/A/B" || name == "/A/B/C" || name == "/A/D") {
+ visitEntry = true;
+ }
+ if (name == "/" || name == "/A" || name == "/F") {
+ visitChildren = true;
+ }
- if (name == "/" || name == "/A/B" || name == "/A/B/C" || name == "/A/D") {
- visitEntry = true;
- }
-
- if (name == "/" || name == "/A" || name == "/F") {
- visitChildren = true;
- }
-
- return std::make_pair(visitEntry, visitChildren);
- });
+ return std::pair(visitEntry, visitChildren);
+ });
EnumerationVerifier(enumerable)
.expect("/A/B")