macro_rules! graph_problem_tests {
(
problem_type: $problem:ty,
constraint_type: $constraint:ty,
test_cases: [
$(
($name:ident, $n:expr, [$($edge:expr),*], [$($sol:expr),*], $size:expr, $is_max:expr)
),* $(,)?
]
) => { ... };
}Expand description
Generate standard tests for a graph problem using the template.
This macro generates tests for:
- Problem creation
- Solution validity
- Brute force solving (for small instances)
- CSP interface
- Metadata (if ProblemMetadata is implemented)
§Example
ⓘ
use problemreductions::testing::graph_problem_tests;
use problemreductions::models::graph::{IndependentSetT, IndependentSetConstraint};
graph_problem_tests! {
problem_type: IndependentSetT<i32>,
constraint_type: IndependentSetConstraint,
test_cases: [
// (name, num_vertices, edges, valid_solution, expected_size, is_maximization)
(triangle, 3, [(0, 1), (1, 2), (0, 2)], [1, 0, 0], 1, true),
(path3, 3, [(0, 1), (1, 2)], [1, 0, 1], 2, true),
]
}