Compare commits
2
Commits
ebfc80546a
...
ce39d0a4d0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce39d0a4d0 | ||
|
|
ccdcf03fa8 |
@@ -15,4 +15,5 @@ if(BUILD_TESTING)
|
|||||||
add_test(NAME construction COMMAND partridge_tests construction)
|
add_test(NAME construction COMMAND partridge_tests construction)
|
||||||
add_test(NAME rendering COMMAND partridge_tests rendering)
|
add_test(NAME rendering COMMAND partridge_tests rendering)
|
||||||
add_test(NAME solver-small COMMAND partridge_tests solver-small)
|
add_test(NAME solver-small COMMAND partridge_tests solver-small)
|
||||||
|
add_test(NAME solver-completion COMMAND partridge_tests solver-completion)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -297,10 +297,11 @@ namespace {
|
|||||||
sqs.push_back(sq);
|
sqs.push_back(sq);
|
||||||
|
|
||||||
pos = grid.next_pos(pos + idx);
|
pos = grid.next_pos(pos + idx);
|
||||||
idx = grid.largest_square(pos, n);
|
|
||||||
|
|
||||||
// Have we reached the end? If so success!
|
// Have we reached the end? If so success!
|
||||||
if (pos == grid.end()) { break; }
|
if (pos == grid.end()) { break; }
|
||||||
|
|
||||||
|
idx = grid.largest_square(pos, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {length, sqs};
|
return {length, sqs};
|
||||||
|
|||||||
@@ -280,6 +280,19 @@ namespace {
|
|||||||
"result adapter did not convert encoded placement coordinates");
|
"result adapter did not convert encoded placement coordinates");
|
||||||
return failures;
|
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) {
|
int main(int argc, char **argv) {
|
||||||
@@ -301,6 +314,9 @@ int main(int argc, char **argv) {
|
|||||||
if (test == "solver-small") {
|
if (test == "solver-small") {
|
||||||
return test_small_solver();
|
return test_small_solver();
|
||||||
}
|
}
|
||||||
|
if (test == "solver-completion") {
|
||||||
|
return test_solver_completion();
|
||||||
|
}
|
||||||
std::cerr << "unknown test: " << test << '\n';
|
std::cerr << "unknown test: " << test << '\n';
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user