From ecf57a9bd342638d861402990b0240909a2a14f2 Mon Sep 17 00:00:00 2001 From: tatiana-yan Date: Thu, 23 May 2019 11:41:02 +0300 Subject: [PATCH] [storage] Fix CountryTree_Smoke test --- storage/storage_tests/simple_tree_test.cpp | 30 ++++++++-------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/storage/storage_tests/simple_tree_test.cpp b/storage/storage_tests/simple_tree_test.cpp index e47ad8c4b1..eb75243847 100644 --- a/storage/storage_tests/simple_tree_test.cpp +++ b/storage/storage_tests/simple_tree_test.cpp @@ -2,17 +2,6 @@ #include "storage/country_tree.hpp" -namespace -{ -template -struct Calculator -{ - size_t count; - Calculator() : count(0) {} - void operator()(Node const &) { ++count; } -}; -} // namespace - UNIT_TEST(CountryTree_Smoke) { using Tree = storage::CountryTree::Node; @@ -45,15 +34,16 @@ UNIT_TEST(CountryTree_Smoke) TEST_EQUAL(tree.Child(4).Child(0).Parent().Value().Name(), "1", ()); TEST_EQUAL(tree.Child(4).Child(2).Parent().Value().Name(), "1", ()); - Calculator c1; - tree.ForEachChild(c1); - TEST_EQUAL(c1.count, 5, ()); + size_t count = 0; + auto countCallback = [&count](Tree const &) { ++count; }; + tree.ForEachChild(countCallback); + TEST_EQUAL(count, 5, ()); - Calculator c2; - tree.ForEachDescendant(c2); - TEST_EQUAL(c2.count, 8, ()); + count = 0; + tree.ForEachDescendant(countCallback); + TEST_EQUAL(count, 8, ()); - Calculator c3; - tree.Child(4).Child(0).ForEachAncestorExceptForTheRoot(c3); - TEST_EQUAL(c3.count, 1, ()); + count = 0; + tree.Child(4).Child(0).ForEachAncestorExceptForTheRoot(countCallback); + TEST_EQUAL(count, 1, ()); }