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

ugc_types_test.cpp « indexer_tests « indexer - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7a2c18a503a217b92a427ef733866a5650685f3a (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "testing/testing.hpp"

#include "indexer/classificator.hpp"
#include "indexer/classificator_loader.hpp"
#include "indexer/ftraits.hpp"

UNIT_TEST(UgcTypes_Full)
{
  classificator::Load();
  Classificator const & c = classif();

  using ftraits::UGC;

  feature::TypesHolder holder;
  {
    auto const type = c.GetTypeByPath({"amenity", "bank"});
    holder.Assign(type);
    TEST(UGC::IsUGCAvailable(holder), ());
    TEST(UGC::IsRatingAvailable(holder), ());
    TEST(UGC::IsReviewsAvailable(holder), ());
    TEST(!UGC::IsDetailsAvailable(holder), ());
    ftraits::UGCRatingCategories expected = {"quality", "service", "value_for_money"};
    TEST_EQUAL(UGC::GetCategories(holder), expected, ());
    auto const matchingType = *UGC::GetType(holder);
    TEST_EQUAL(matchingType, type, ());
    TEST_EQUAL(c.GetReadableObjectName(matchingType), "amenity-bank", ());
  }
  {
    auto const type = c.GetTypeByPath({"tourism", "information", "office"});
    holder.Assign(type);
    TEST(UGC::IsUGCAvailable(holder), ());
    TEST(UGC::IsRatingAvailable(holder), ());
    TEST(UGC::IsReviewsAvailable(holder), ());
    TEST(!UGC::IsDetailsAvailable(holder), ());
    ftraits::UGCRatingCategories expected = {"quality", "service", "value_for_money"};
    TEST_EQUAL(UGC::GetCategories(holder), expected, ());
    auto const matchingType = *UGC::GetType(holder);
    TEST_EQUAL(matchingType, type, ());
    TEST_EQUAL(c.GetReadableObjectName(matchingType), "tourism-information-office", ());
  }
  {
    auto const type = c.GetTypeByPath({"amenity", "hospital"});
    holder.Assign(type);
    TEST(UGC::IsUGCAvailable(holder), ());
    TEST(UGC::IsRatingAvailable(holder), ());
    TEST(UGC::IsReviewsAvailable(holder), ());
    TEST(!UGC::IsDetailsAvailable(holder), ());
    ftraits::UGCRatingCategories expected = {"expertise", "equipment", "value_for_money"};
    TEST_EQUAL(UGC::GetCategories(holder), expected, ());
    auto const matchingType = *UGC::GetType(holder);
    TEST_EQUAL(matchingType, type, ());
    TEST_EQUAL(c.GetReadableObjectName(matchingType), "amenity-hospital", ());
  }
  {
    holder.Assign(c.GetTypeByPath({"traffic_calming", "bump"}));
    TEST(!UGC::IsUGCAvailable(holder), ());
    TEST(!UGC::GetType(holder), ());
  }
  {
    holder.Assign(c.GetTypeByPath({"sponsored", "booking"}));
    TEST(!UGC::IsUGCAvailable(holder), ());
    TEST(!UGC::IsRatingAvailable(holder), ());
    TEST(!UGC::IsReviewsAvailable(holder), ());
    TEST(!UGC::IsDetailsAvailable(holder), ());
    ftraits::UGCRatingCategories expected = {};
    TEST_EQUAL(UGC::GetCategories(holder), expected, ());
    TEST(!UGC::GetType(holder), ());

    holder.Assign(c.GetTypeByPath({"sponsored", "booking"}));
    holder.Add(c.GetTypeByPath({"amenity", "hospital"}));
    TEST(!UGC::IsUGCAvailable(holder), ());
    TEST(!UGC::IsRatingAvailable(holder), ());
    TEST(!UGC::IsReviewsAvailable(holder), ());
    TEST(!UGC::IsDetailsAvailable(holder), ());
    TEST_EQUAL(UGC::GetCategories(holder), expected, ());
    TEST(!UGC::GetType(holder), ());

    holder.Assign(c.GetTypeByPath({"amenity", "hospital"}));
    holder.Add(c.GetTypeByPath({"sponsored", "booking"}));
    TEST(!UGC::IsUGCAvailable(holder), ());
    TEST(!UGC::IsRatingAvailable(holder), ());
    TEST(!UGC::IsReviewsAvailable(holder), ());
    TEST(!UGC::IsDetailsAvailable(holder), ());
    TEST_EQUAL(UGC::GetCategories(holder), expected, ());
    TEST(!UGC::GetType(holder), ());
  }
}