From 688034aaf8d9377a0640a842ab6ac67955b069f5 Mon Sep 17 00:00:00 2001 From: vng Date: Sat, 26 Mar 2011 17:42:38 +0200 Subject: [PATCH] Geometry coding test for special data. Invalid processing on iPhone. --- .../indexer_tests/geometry_coding_test.cpp | 36 +++++++++++++++++++ indexer/indexer_tests/point_to_int64_test.cpp | 13 +++++++ 2 files changed, 49 insertions(+) diff --git a/indexer/indexer_tests/geometry_coding_test.cpp b/indexer/indexer_tests/geometry_coding_test.cpp index 879906e0b5..95daa89c33 100644 --- a/indexer/indexer_tests/geometry_coding_test.cpp +++ b/indexer/indexer_tests/geometry_coding_test.cpp @@ -1,15 +1,20 @@ #include "../geometry_coding.hpp" #include "../../testing/testing.hpp" +#include "../../indexer/mercator.hpp" +#include "../../indexer/point_to_int64.hpp" + #include "../../geometry/geometry_tests/large_polygon.hpp" #include "../../geometry/distance.hpp" #include "../../geometry/simplification.hpp" +#include "../../geometry/pointu_to_uint64.hpp" #include "../../coding/byte_stream.hpp" #include "../../coding/varint.hpp" #include "../../coding/writer.hpp" #include "../../base/logging.hpp" +#include "../../base/array_adapters.hpp" typedef m2::PointU PU; @@ -163,3 +168,34 @@ UNIT_TEST(EncodePolyline) TestEncodePolyline("4000simp", maxPoint, SimplifyPoints(points, 4000)); } } + +UNIT_TEST(DecodePolyline_Values) +{ + uint64_t arr[] = { + 2734738402133224327, + 587102334176945, + 154352840547926, + 43024411088417, + 2208572839502425, + 1537729724693572015, + 110442683719211 + }; + + int64_t const baseP = 876424843953707746; + + array_read in(arr, ARRAY_SIZE(arr)); + + vector buffer(10); + array_write out(buffer); + + geo_coding::DecodePolylinePrev2(in, + m2::Uint64ToPointU(baseP), PointD2PointU(MercatorBounds::maxX, MercatorBounds::maxY), + out); + + for (size_t i = 0; i < out.size(); ++i) + { + CoordPointT const pt = PointU2PointD(out[i]); + TEST ( MercatorBounds::minX <= pt.first && pt.first <= MercatorBounds::maxX, (pt.first) ); + TEST ( MercatorBounds::minY <= pt.second && pt.second <= MercatorBounds::maxY, (pt.second) ); + } +} diff --git a/indexer/indexer_tests/point_to_int64_test.cpp b/indexer/indexer_tests/point_to_int64_test.cpp index 258b73a641..d136f31ad8 100644 --- a/indexer/indexer_tests/point_to_int64_test.cpp +++ b/indexer/indexer_tests/point_to_int64_test.cpp @@ -49,6 +49,19 @@ UNIT_TEST(PointToInt64_908175295886057813) TEST_EQUAL(id1, id2, (pt1)); } +/* +UNIT_TEST(PointToInt64_Values) +{ + CoordPointT const p = PointU2PointD(m2::PointU(3225901878, 23488265)); + + TEST_GREATER_OR_EQUAL(p.first, -180.0, ()); + TEST_GREATER_OR_EQUAL(p.second, -180.0, ()); + + TEST_LESS_OR_EQUAL(p.first, 180.0, ()); + TEST_LESS_OR_EQUAL(p.second, 180.0, ()); +} +*/ + UNIT_TEST(PointToInt64_Grid) { int const delta = 5;