Make candidate ordering an explicit deterministic policy and benchmark ascending, descending, and exact-width-first choices. Keep ascending as the default because it produces the best measured time to first solution despite best-fit's slightly smaller tree. Retain the benchmark v1 interface and document why randomized and duplicate-work portfolio policies are deferred. Tests: Release and Debug CTest (10 passed each) Refs: #12
2.5 KiB
Testing
The default test suite is deterministic and has no elapsed-time assertions. Configure a build, compile it, and run the tests with CTest:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
ctest --test-dir build --output-on-failure
The tests independently check board dimensions, square multiplicities, bounds, overlap, and complete coverage. They cover small unsatisfiable solver inputs, a known order-8 solution, invalid placement diagnostics, and construction of an order-9 solution from the order-8 fixture. The routed best-fit order-9 solver test checks that its search counters exactly match order 8. The skyline tests check smallest-width valley selection and deterministic tie-breaking, validate an order-8 result with descending candidates, and independently validate a direct order-9 search with ascending candidates. An exhaustive infeasible order also checks that all three policies visit the same search space. The direct order-9 test is deliberately separate from the public order-9 route, which uses even-predecessor construction. Orders 10 and 11 are not routine tests because both public routes require the same long direct order-10 search; the route-boundary test still checks that order 11 selects odd construction. The rendering test also formats the known order-8 solution and checks the resulting grid dimensions and coverage.
When Python is available, reference-support also tests the dependency-free
placement JSON validator. If the optional OR-Tools package is present, it
additionally builds and solves the trivial order-1 CP-SAT model; otherwise that
part is skipped without changing the default test result.
Debug and sanitizers
Use a separate build directory for each configuration:
cmake -S . -B build-debug -DCMAKE_BUILD_TYPE=Debug
cmake --build build-debug
ctest --test-dir build-debug --output-on-failure
cmake -S . -B build-asan -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
cmake --build build-asan
ctest --test-dir build-asan --output-on-failure
cmake -S . -B build-ubsan -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_CXX_FLAGS="-fsanitize=undefined -fno-omit-frame-pointer" \
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=undefined"
cmake --build build-ubsan
ctest --test-dir build-ubsan --output-on-failure
The sanitizer flags shown are supported by Clang and GCC. Other compilers may require different flags.