test: cover completed solver boards
Exercise both the trivial order-1 solution and the feasible order-8 solution through the independent placement validator. With the existing completion ordering, the focused test reports a heap-buffer-overflow under AddressSanitizer before validation can run. Refs: #14
This commit is contained in:
@@ -15,4 +15,5 @@ if(BUILD_TESTING)
|
||||
add_test(NAME construction COMMAND partridge_tests construction)
|
||||
add_test(NAME rendering COMMAND partridge_tests rendering)
|
||||
add_test(NAME solver-small COMMAND partridge_tests solver-small)
|
||||
add_test(NAME solver-completion COMMAND partridge_tests solver-completion)
|
||||
endif()
|
||||
|
||||
@@ -280,6 +280,19 @@ namespace {
|
||||
"result adapter did not convert encoded placement coordinates");
|
||||
return failures;
|
||||
}
|
||||
|
||||
auto test_solver_completion() -> int {
|
||||
int failures = 0;
|
||||
for (auto const order: std::array<std::uint64_t, 2>{1, 8}) {
|
||||
auto const solution = find_solution(order);
|
||||
auto const validation = validate(order, solution);
|
||||
failures += expect(
|
||||
validation.valid(),
|
||||
"solver returned an invalid order-" + std::to_string(order) +
|
||||
" solution:\n" + validation.text());
|
||||
}
|
||||
return failures;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
@@ -301,6 +314,9 @@ int main(int argc, char **argv) {
|
||||
if (test == "solver-small") {
|
||||
return test_small_solver();
|
||||
}
|
||||
if (test == "solver-completion") {
|
||||
return test_solver_completion();
|
||||
}
|
||||
std::cerr << "unknown test: " << test << '\n';
|
||||
return 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user