blob: f6d6fd72d52ca0b57c10a1da493997034edc756d (
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
|
#pragma once
#include "search/result.hpp"
#include "indexer/mwm_set.hpp"
#include <initializer_list>
#include <memory>
#include <string>
#include <utility>
#include <vector>
class FeatureType;
class DataSourceBase;
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 std::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;
std::string ToString() const override;
private:
MwmSet::MwmId m_mwmId;
generator::tests_support::TestFeature const & m_feature;
};
class AlternativesMatchingRule : public MatchingRule
{
public:
AlternativesMatchingRule(std::initializer_list<std::shared_ptr<MatchingRule>> rules);
// MatchingRule overrides:
bool Matches(FeatureType const & feature) const override;
std::string ToString() const override;
private:
std::vector<std::shared_ptr<MatchingRule>> m_rules;
};
template <typename... TArgs>
std::shared_ptr<MatchingRule> ExactMatch(TArgs &&... args)
{
return std::make_shared<ExactMatchingRule>(forward<TArgs>(args)...);
}
template <typename... TArgs>
std::shared_ptr<MatchingRule> AlternativesMatch(TArgs &&... args)
{
return std::make_shared<AlternativesMatchingRule>(std::forward<TArgs>(args)...);
}
bool MatchResults(DataSourceBase const & dataSource, std::vector<std::shared_ptr<MatchingRule>> rules,
std::vector<search::Result> const & actual);
bool MatchResults(DataSourceBase const & dataSource, std::vector<std::shared_ptr<MatchingRule>> rules,
search::Results const & actual);
bool ResultMatches(DataSourceBase const & dataSource, std::shared_ptr<MatchingRule> rule,
search::Result const & result);
std::string DebugPrint(MatchingRule const & rule);
} // namespace tests_support
} // namespace search
|