91#ifndef OR_TOOLS_MATH_OPT_CPP_MATCHERS_H_
92#define OR_TOOLS_MATH_OPT_CPP_MATCHERS_H_
97#include "gtest/gtest.h"
112testing::Matcher<VariableMap<double>>
IsNear(
121testing::Matcher<LinearConstraintMap<double>>
IsNear(
148testing::Matcher<PrimalSolution>
IsNear(
153testing::Matcher<DualSolution>
IsNear(
156testing::Matcher<Basis>
BasisIs(
const Basis& expected);
164testing::Matcher<PrimalRay>
IsNear(PrimalRay expected,
170 VariableMap<double> expected_var_values,
176testing::Matcher<DualRay>
IsNear(DualRay expected,
190 std::optional<double> expected_objective = std::nullopt,
194 double expected_objective, VariableMap<double> expected_variable_values,
198 double expected_objective, LinearConstraintMap<double> expected_dual_values,
199 VariableMap<double> expected_reduced_costs,
bool check_warnings =
true,
206 bool check_warnings =
true);
212 const std::vector<TerminationReason>& allowed,
bool check_warnings =
true);
219 Limit expected,
bool allow_limit_undetermined =
false,
220 bool check_warnings =
true);
227 Limit expected,
bool allow_limit_undetermined =
false,
228 bool check_warnings =
true);
235 Limit expected,
bool allow_limit_undetermined =
false,
236 bool check_warnings =
true);
255 VariableMap<double> expected_vars,
378testing::Matcher<IncrementalSolver::UpdateResult>
DidUpdate();
386void PrintTo(
const Termination& termination, std::ostream* os);
387void PrintTo(
const PrimalSolution& primal_solution, std::ostream* os);
388void PrintTo(
const DualSolution& dual_solution, std::ostream* os);
389void PrintTo(
const PrimalRay& primal_ray, std::ostream* os);
390void PrintTo(
const DualRay& dual_ray, std::ostream* os);
391void PrintTo(
const Basis& basis, std::ostream* os);
392void PrintTo(
const Solution& solution, std::ostream* os);
393void PrintTo(
const SolveResult& result, std::ostream* os);
397template <
typename K,
typename V>
399 constexpr int kMaxPrint = 10;
406 if (num_added >= kMaxPrint) {
407 *os <<
"...(size=" << id_map.
size() <<
")";
410 *os <<
"{" << k <<
", " << ::testing::PrintToString(id_map.
at(k)) <<
"}";
std::vector< K > SortedKeys() const
const V & at(const K &k) const
Matcher< SolveResult > HasDualSolution(DualSolution expected, const double tolerance)
Matcher< SolveResult > HasSolution(PrimalSolution expected, const double tolerance)
void PrintTo(const Termination &termination, std::ostream *os)
testing::Matcher< SolveResult > TerminatesWithReasonNoSolutionFound(const Limit expected, const bool allow_limit_undetermined, const bool check_warnings)
constexpr double kMatcherDefaultTolerance
Matcher< IncrementalSolver::UpdateResult > DidUpdate()
testing::Matcher< SolveResult > TerminatesWithReasonFeasible(const Limit expected, const bool allow_limit_undetermined, const bool check_warnings)
Matcher< SolveResult > IsConsistentWith(const SolveResult &expected, const SolveResultMatcherOptions &options)
Matcher< SolveResult > IsOptimal(const std::optional< double > expected_objective, const bool check_warnings, const double tolerance)
Matcher< VariableMap< double > > IsNearlySubsetOf(VariableMap< double > expected, double tolerance)
Matcher< SolveResult > HasDualRay(DualRay expected, const double tolerance)
Matcher< SolveResult > IsOptimalWithSolution(const double expected_objective, const VariableMap< double > expected_variable_values, const bool check_warnings, const double tolerance)
Matcher< SolveResult > TerminatesWith(const TerminationReason expected, const bool check_warnings)
Matcher< SolveResult > HasPrimalRay(PrimalRay expected, const double tolerance)
testing::Matcher< SolveResult > TerminatesWithLimit(const Limit expected, const bool allow_limit_undetermined, const bool check_warnings)
Matcher< VariableMap< double > > IsNear(VariableMap< double > expected, const double tolerance)
Matcher< Basis > BasisIs(const Basis &expected)
Matcher< PrimalRay > PrimalRayIsNear(VariableMap< double > expected_var_values, const double tolerance)
Matcher< SolveResult > IsOptimalWithDualSolution(const double expected_objective, const LinearConstraintMap< double > expected_dual_values, const VariableMap< double > expected_reduced_costs, const bool check_warnings, const double tolerance)
Matcher< SolveResult > TerminatesWithOneOf(const std::vector< TerminationReason > &allowed, const bool check_warnings)
Collection of objects used to extend the Constraint Solver library.
bool inf_or_unb_soft_match
bool check_solutions_if_inf_or_unbounded