91#ifndef OR_TOOLS_MATH_OPT_CPP_MATCHERS_H_
92#define OR_TOOLS_MATH_OPT_CPP_MATCHERS_H_
98#include "gtest/gtest.h"
113testing::Matcher<VariableMap<double>>
IsNear(
122testing::Matcher<LinearConstraintMap<double>>
IsNear(
149testing::Matcher<PrimalSolution>
IsNear(
154testing::Matcher<DualSolution>
IsNear(
157testing::Matcher<Basis>
BasisIs(
const Basis& expected);
165testing::Matcher<PrimalRay>
IsNear(PrimalRay expected,
171 VariableMap<double> expected_var_values,
177testing::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,
208 const std::vector<TerminationReason>& allowed);
214 Limit expected,
bool allow_limit_undetermined =
false);
220 Limit expected,
bool allow_limit_undetermined =
false);
226 Limit expected,
bool allow_limit_undetermined =
false);
245 VariableMap<double> expected_vars,
365testing::Matcher<IncrementalSolver::UpdateResult>
DidUpdate();
373void PrintTo(
const Termination& termination, std::ostream* os);
374void PrintTo(
const PrimalSolution& primal_solution, std::ostream* os);
375void PrintTo(
const DualSolution& dual_solution, std::ostream* os);
376void PrintTo(
const PrimalRay& primal_ray, std::ostream* os);
377void PrintTo(
const DualRay& dual_ray, std::ostream* os);
378void PrintTo(
const Basis& basis, std::ostream* os);
379void PrintTo(
const Solution& solution, std::ostream* os);
380void PrintTo(
const SolveResult& result, std::ostream* os);
384template <
typename K,
typename V>
386 constexpr int kMaxPrint = 10;
393 if (num_added >= kMaxPrint) {
394 *os <<
"...(size=" << id_map.
size() <<
")";
397 *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)
testing::Matcher< SolveResult > TerminatesWithReasonNoSolutionFound(const Limit expected, const bool allow_limit_undetermined)
Matcher< SolveResult > IsOptimal(const std::optional< double > expected_objective, const double tolerance)
void PrintTo(const Termination &termination, std::ostream *os)
constexpr double kMatcherDefaultTolerance
Matcher< IncrementalSolver::UpdateResult > DidUpdate()
Matcher< SolveResult > IsOptimalWithSolution(const double expected_objective, const VariableMap< double > expected_variable_values, const double tolerance)
Matcher< SolveResult > TerminatesWithOneOf(const std::vector< TerminationReason > &allowed)
Matcher< SolveResult > IsConsistentWith(const SolveResult &expected, const SolveResultMatcherOptions &options)
testing::Matcher< SolveResult > TerminatesWithReasonFeasible(const Limit expected, const bool allow_limit_undetermined)
Matcher< VariableMap< double > > IsNearlySubsetOf(VariableMap< double > expected, double tolerance)
testing::Matcher< SolveResult > TerminatesWithLimit(const Limit expected, const bool allow_limit_undetermined)
Matcher< SolveResult > HasDualRay(DualRay expected, const double tolerance)
Matcher< SolveResult > IsOptimalWithDualSolution(const double expected_objective, const LinearConstraintMap< double > expected_dual_values, const VariableMap< double > expected_reduced_costs, const double tolerance)
Matcher< SolveResult > TerminatesWith(const TerminationReason expected)
Matcher< SolveResult > HasPrimalRay(PrimalRay expected, const double tolerance)
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)
Collection of objects used to extend the Constraint Solver library.
bool inf_or_unb_soft_match
bool check_solutions_if_inf_or_unbounded