Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
invalid_input_tests.h
Go to the documentation of this file.
1// Copyright 2010-2024 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#ifndef OR_TOOLS_MATH_OPT_SOLVER_TESTS_INVALID_INPUT_TESTS_H_
15#define OR_TOOLS_MATH_OPT_SOLVER_TESTS_INVALID_INPUT_TESTS_H_
16
17#include <memory>
18#include <ostream>
19#include <string>
20#include <vector>
21
22#include "absl/status/statusor.h"
23#include "gtest/gtest.h"
26#include "ortools/math_opt/parameters.pb.h"
29
30namespace operations_research {
31namespace math_opt {
32
45
46// To use these tests, in file <solver>_test.cc, write:
47// INSTANTIATE_TEST_SUITE_P(
48// <Solver>InvalidInputTest, InvalidInputTest,
49// testing::Values(InvalidInputTestParameters(
50// SolverType::k<Solver>, /*use_integer_variables=*/true)));
51// TODO(b/172553545): this test should not be repeated for each solver since it
52// tests that the Solver class validates the model before calling the
53// interface.
55 : public ::testing::TestWithParam<InvalidInputTestParameters> {
56 protected:
57 SolverType TestedSolver() const { return GetParam().solver_type; }
58};
59
72
74 : public ::testing::TestWithParam<InvalidParameterTestParams> {
75 protected:
77
78 absl::StatusOr<SolveResult> SimpleSolve(
79 const SolveParameters& parameters = GetParam().solve_parameters) {
80 return Solve(model_, GetParam().solver_type, {.parameters = parameters});
81 }
82
84 const Variable x_;
85};
86
87} // namespace math_opt
88} // namespace operations_research
89
90#endif // OR_TOOLS_MATH_OPT_SOLVER_TESTS_INVALID_INPUT_TESTS_H_
absl::StatusOr< SolveResult > SimpleSolve(const SolveParameters &parameters=GetParam().solve_parameters)
SatParameters parameters
SolverType
The solvers supported by MathOpt.
Definition parameters.h:42
absl::StatusOr< SolveResult > Solve(const Model &model, const SolverType solver_type, const SolveArguments &solve_args, const SolverInitArguments &init_args)
Definition solve.cc:62
In SWIG mode, we don't want anything besides these top-level includes.
InvalidInputTestParameters(const SolverType solver_type, const bool use_integer_variables)
friend std::ostream & operator<<(std::ostream &out, const InvalidInputTestParameters &params)
InvalidParameterTestParams(SolverType solver_type, SolveParameters solve_parameters, std::vector< std::string > expected_error_substrings)
friend std::ostream & operator<<(std::ostream &out, const InvalidParameterTestParams &params)