Welcome to mirror list, hosted at ThFree Co, Russian Federation.

country_test.cpp « storage_tests « storage - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b6794d00649ac310de06ada26ce13189f6addbbc (plain)
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
#include "../../testing/testing.hpp"

#include "../country.hpp"

#include "../../version/version.hpp"

#include "../../coding/file_writer.hpp"
#include "../../coding/file_reader.hpp"

#include "../../base/start_mem_debug.hpp"

using namespace storage;


UNIT_TEST(TilesSerialization)
{
  static string const FILE = "tiles_serialization_test";
  int32_t const level = 8;
  TDataFiles::value_type const v1(55000, 55000);
  TDataFiles::value_type const v2(15000, 15000);
  TDataFiles::value_type const v3(5, 5);
  TCommonFiles::value_type const vv1("str2", 456);
  TCommonFiles::value_type const vv2("str1", 123);
  {
    TDataFiles dataFiles;
    dataFiles.push_back(v1);
    dataFiles.push_back(v2);
    dataFiles.push_back(v3);
    TCommonFiles commonFiles;
    commonFiles.push_back(vv1);
    commonFiles.push_back(vv2);

    SaveTiles(FILE, level, dataFiles, commonFiles);
  }

  {
    uint32_t version;

    TTilesContainer tiles;
    TEST(LoadTiles(ReaderPtr<Reader>(new FileReader(FILE)), tiles, version), ());

    TEST_EQUAL( tiles.size(), 5, ());
    TEST_EQUAL( tiles[0], TTilesContainer::value_type(
        CountryCellId::FromBitsAndLevel(5, level).ToString(), 5), ());
    TEST_EQUAL( tiles[1], TTilesContainer::value_type(
        CountryCellId::FromBitsAndLevel(15000, level).ToString(), 15000), ());
    TEST_EQUAL( tiles[2], TTilesContainer::value_type(
        CountryCellId::FromBitsAndLevel(55000, level).ToString(), 55000), ());
    TEST_EQUAL( tiles[3], TTilesContainer::value_type("str1", 123), ());
    TEST_EQUAL( tiles[4], TTilesContainer::value_type("str2", 456), ());
  }

  FileWriter::DeleteFileX(FILE);
}