[storage] Fix CountryTree_Smoke test

This commit is contained in:
tatiana-yan 2019-05-23 11:41:02 +03:00 committed by mpimenov
parent b6c4a59021
commit ecf57a9bd3

View file

@ -2,17 +2,6 @@
#include "storage/country_tree.hpp"
namespace
{
template <class Node>
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<Tree> 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<Tree> c2;
tree.ForEachDescendant(c2);
TEST_EQUAL(c2.count, 8, ());
count = 0;
tree.ForEachDescendant(countCallback);
TEST_EQUAL(count, 8, ());
Calculator<Tree> 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, ());
}