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

test_results_matching.hpp « search_tests_support « search - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3a776d48ca5f31c8e5a36cffcc4ec9e85fecbf43 (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
#pragma once

#include "search/result.hpp"

#include "indexer/mwm_set.hpp"

#include "std/shared_ptr.hpp"
#include "std/string.hpp"
#include "std/vector.hpp"

class FeatureType;
class Index;

namespace generator
{
namespace tests_support
{
class TestFeature;
}
}

namespace search
{
namespace tests_support
{
class MatchingRule
{
public:
  virtual ~MatchingRule() = default;

  virtual bool Matches(FeatureType const & feature) const = 0;
  virtual string ToString() const = 0;
};

class ExactMatchingRule : public MatchingRule
{
public:
  ExactMatchingRule(MwmSet::MwmId const & mwmId,
                    generator::tests_support::TestFeature const & feature);

  // MatchingRule overrides:
  bool Matches(FeatureType const & feature) const override;
  string ToString() const override;

private:
  MwmSet::MwmId m_mwmId;
  generator::tests_support::TestFeature const & m_feature;
};

class AlternativesMatchingRule : public MatchingRule
{
public:
  AlternativesMatchingRule(initializer_list<shared_ptr<MatchingRule>> rules);

  // MatchingRule overrides:
  bool Matches(FeatureType const & feature) const override;
  string ToString() const override;

private:
  vector<shared_ptr<MatchingRule>> m_rules;
};

template <typename... TArgs>
shared_ptr<MatchingRule> ExactMatch(TArgs &&... args)
{
  return make_shared<ExactMatchingRule>(forward<TArgs>(args)...);
}

template <typename... TArgs>
shared_ptr<MatchingRule> AlternativesMatch(TArgs &&... args)
{
  return make_shared<AlternativesMatchingRule>(forward<TArgs>(args)...);
}

bool MatchResults(Index const & index, vector<shared_ptr<MatchingRule>> rules,
                  vector<search::Result> const & actual);

string DebugPrint(MatchingRule const & rule);
}  // namespace tests_support
}  // namespace search