Files
comaps/search/search_tests_support/test_results_matching.hpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

90 lines
2.3 KiB
C++

#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 DataSource;
namespace generator
{
namespace tests_support
{
class TestFeature;
}
}
namespace search
{
namespace tests_support
{
class MatchingRule
{
public:
virtual ~MatchingRule() = default;
virtual bool Matches(FeatureType & 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 & 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::vector<std::shared_ptr<MatchingRule>> && rules);
// MatchingRule overrides:
bool Matches(FeatureType & feature) const override;
std::string ToString() const override;
private:
std::vector<std::shared_ptr<MatchingRule>> m_rules;
};
template <typename... Args>
std::shared_ptr<MatchingRule> ExactMatch(Args &&... args)
{
return std::make_shared<ExactMatchingRule>(std::forward<Args>(args)...);
}
inline std::shared_ptr<MatchingRule> AlternativesMatch(
std::vector<std::shared_ptr<MatchingRule>> && rules)
{
return std::make_shared<AlternativesMatchingRule>(std::move(rules));
}
bool MatchResults(DataSource const & dataSource, std::vector<std::shared_ptr<MatchingRule>> rules,
std::vector<search::Result> const & actual);
bool MatchResults(DataSource const & dataSource, std::vector<std::shared_ptr<MatchingRule>> rules,
search::Results const & actual);
bool ResultMatches(DataSource const & dataSource, std::shared_ptr<MatchingRule> rule,
search::Result const & result);
bool AlternativeMatch(DataSource const & dataSource,
std::vector<std::vector<std::shared_ptr<MatchingRule>>> rules,
std::vector<search::Result> const & results);
std::string DebugPrint(MatchingRule const & rule);
} // namespace tests_support
} // namespace search