From 3b265d0d0b5b35155aae9dce891a84b4b4e7cb60 Mon Sep 17 00:00:00 2001 From: Constantin Shalnev Date: Thu, 31 Dec 2015 12:55:46 +0300 Subject: [PATCH] Added dashes test --- map/style_tests/dashes_test.cpp | 43 +++++++++++++++++++++++++++++++++ map/style_tests/style_tests.pro | 1 + 2 files changed, 44 insertions(+) create mode 100644 map/style_tests/dashes_test.cpp diff --git a/map/style_tests/dashes_test.cpp b/map/style_tests/dashes_test.cpp new file mode 100644 index 0000000000..fd40cb4b92 --- /dev/null +++ b/map/style_tests/dashes_test.cpp @@ -0,0 +1,43 @@ +#include "testing/testing.hpp" + +#include "indexer/classificator_loader.hpp" +#include "indexer/drawing_rules.hpp" +#include "indexer/drules_struct.pb.h" +#include "indexer/map_style_reader.hpp" + +namespace +{ +double constexpr kMaxVisualScale = 4.; + +double constexpr kMaxDashLength = 128 / kMaxVisualScale; +// Why 128? 7 bits are used to pack dash value (see stipple_pen_resource.cpp, StipplePenHandle::Init) +// Max value, which can be packed in 7 bits, is 128. +} // namespace + +UNIT_TEST(Test_Dashes) +{ + for (size_t s = 0; s < MapStyleCount; ++s) + { + MapStyle const mapStyle = static_cast(s); + + GetStyleReader().SetCurrentStyle(mapStyle); + classificator::Load(); + + drule::rules().ForEachRule([](int, int, int, drule::BaseRule const * rule) + { + LineDefProto const * const line = rule->GetLine(); + if (nullptr == line || !line->has_dashdot()) + return; + + DashDotProto const & dd = line->dashdot(); + + int const n = dd.dd_size(); + for (int i = 0; i < n; ++i) + { + double const value = dd.dd(i); + TEST_GREATER_OR_EQUAL(value, 0.0, ()); + TEST_LESS_OR_EQUAL(value, kMaxDashLength, ()); + } + }); + } +} diff --git a/map/style_tests/style_tests.pro b/map/style_tests/style_tests.pro index cb0af0e100..9a3953a04d 100644 --- a/map/style_tests/style_tests.pro +++ b/map/style_tests/style_tests.pro @@ -17,4 +17,5 @@ QT *= core SOURCES += \ ../../testing/testingmain.cpp \ classificator_tests.cpp \ + dashes_test.cpp \ style_symbols_consistency_test.cpp \