From 198dc7e284bdbb0a168df1bf3c4651ba4fb71c2d Mon Sep 17 00:00:00 2001 From: Constantin Shalnev Date: Thu, 15 Oct 2015 18:36:03 +0300 Subject: [PATCH] Fixed notes --- .../style_symbols_consistency_test.cpp | 44 ++++++++----------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/map/style_tests/style_symbols_consistency_test.cpp b/map/style_tests/style_symbols_consistency_test.cpp index 679649bdbc..3f8871ae07 100644 --- a/map/style_tests/style_symbols_consistency_test.cpp +++ b/map/style_tests/style_symbols_consistency_test.cpp @@ -7,14 +7,14 @@ #include "graphics/defines.hpp" -#include "coding/reader.hpp" -#include "coding/parse_xml.hpp" - #include "base/logging.hpp" -#include "std/array.hpp" +#include "coding/parse_xml.hpp" +#include "coding/reader.hpp" + +#include "std/algorithm.hpp" +#include "std/set.hpp" #include "std/string.hpp" -#include "std/unordered_set.hpp" namespace { @@ -22,7 +22,7 @@ namespace class SdfParsingDispatcher { public: - SdfParsingDispatcher(unordered_set & symbols) + SdfParsingDispatcher(set & symbols) : m_symbols(symbols) {} @@ -36,12 +36,12 @@ public: } private: - unordered_set & m_symbols; + set & m_symbols; }; -unordered_set GetSymbolsSetFromDrawingRule() +set GetSymbolsSetFromDrawingRule() { - unordered_set symbols; + set symbols; drule::rules().ForEachRule([&symbols](int, int, int, drule::BaseRule const * rule) { SymbolRuleProto const * const symbol = rule->GetSymbol(); @@ -51,9 +51,9 @@ unordered_set GetSymbolsSetFromDrawingRule() return symbols; } -unordered_set GetSymbolsSetFromResourcesFile(string const & density) +set GetSymbolsSetFromResourcesFile(string const & density) { - unordered_set symbols; + set symbols; SdfParsingDispatcher dispatcher(symbols); ReaderPtr reader = GetStyleReader().GetResourceReader("symbols.sdf", density); ReaderSource > source(reader); @@ -61,15 +61,6 @@ unordered_set GetSymbolsSetFromResourcesFile(string const & density) return symbols; } -// returns s1 - s2 -unordered_set Subtract(unordered_set const & s1, unordered_set const & s2) -{ - unordered_set res(s1); - for (auto const & s : s2) - res.erase(s); - return res; -} - } // namespace UNIT_TEST(Test_SymbolsConsistency) @@ -85,22 +76,23 @@ UNIT_TEST(Test_SymbolsConsistency) GetStyleReader().SetCurrentStyle(mapStyle); classificator::Load(); - unordered_set const drawingRuleSymbols = GetSymbolsSetFromDrawingRule(); + set const drawingRuleSymbols = GetSymbolsSetFromDrawingRule(); for (size_t d = 0; d < graphics::EDensityCount; ++d) { string const density = graphics::convert(static_cast(d)); - unordered_set const resourceStyles = GetSymbolsSetFromResourcesFile(density); + set const resourceStyles = GetSymbolsSetFromResourcesFile(density); - unordered_set const s = Subtract(drawingRuleSymbols, resourceStyles); - - vector const missed(s.begin(), s.end()); + vector missed; + set_difference(drawingRuleSymbols.begin(), drawingRuleSymbols.end(), + resourceStyles.begin(), resourceStyles.end(), + back_inserter(missed)); if (!missed.empty()) { // We are interested in all set of bugs, therefore we do not stop test here but - // continue it just keep in res that test failed. + // continue it just keeping in res that test failed. LOG(LINFO, ("Symbols mismatch: style", mapStyle, ", density", density, ", missed", missed)); res = false; }