1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#include "testing/testing.hpp"
#include "indexer/cell_coverer.hpp"
#include "indexer/indexer_tests/bounds.hpp"
#include "geometry/covering_utils.hpp"
#include "coding/hex.hpp"
#include "base/logging.hpp"
// Unit test uses m2::CellId<30> for historical reasons, the actual production code uses RectId.
typedef m2::CellId<30> CellIdT;
UNIT_TEST(CellIdToStringRecode)
{
char const kTest[] = "21032012203";
TEST_EQUAL(CellIdT::FromString(kTest).ToString(), kTest, ());
}
UNIT_TEST(GoldenCoverRect)
{
vector<CellIdT> cells;
CoverRect<OrthoBounds>({27.43, 53.83, 27.70, 53.96}, 4, RectId::DEPTH_LEVELS, cells);
TEST_EQUAL(cells.size(), 4, ());
TEST_EQUAL(cells[0].ToString(), "32012211300", ());
TEST_EQUAL(cells[1].ToString(), "32012211301", ());
TEST_EQUAL(cells[2].ToString(), "32012211302", ());
TEST_EQUAL(cells[3].ToString(), "32012211303", ());
}
UNIT_TEST(ArtificialCoverRect)
{
typedef Bounds<0, 0, 16, 16> TestBounds;
vector<CellIdT> cells;
CoverRect<TestBounds>({5, 5, 11, 11}, 4, RectId::DEPTH_LEVELS, cells);
TEST_EQUAL(cells.size(), 4, ());
TEST_EQUAL(cells[0].ToString(), "03", ());
TEST_EQUAL(cells[1].ToString(), "12", ());
TEST_EQUAL(cells[2].ToString(), "21", ());
TEST_EQUAL(cells[3].ToString(), "30", ());
}
UNIT_TEST(MaxDepthCoverSpiral)
{
using TestBounds = Bounds<0, 0, 8, 8>;
auto cells = vector<m2::CellId<3>>{};
CoverSpiral<TestBounds, m2::CellId<3>>({2.1, 4.1, 2.1, 4.1}, 2, cells);
TEST_EQUAL(cells.size(), 1, ());
TEST_EQUAL(cells[0].Level(), 1, ());
}
|