Daily Test Coverage Improver: Add comprehensive API pseudo-boolean constraint tests#7898
Merged
NikolajBjorner merged 2 commits intomasterfrom Sep 18, 2025
Merged
Conversation
…nstraint tests Added comprehensive test coverage for Z3's pseudo-boolean constraint API functions, improving coverage from 0% to 100% for src/api/api_pb.cpp. - Created comprehensive test suite in src/test/api_pb.cpp - Added test registration in src/test/main.cpp and src/test/CMakeLists.txt - Implemented tests for all 5 API functions: * Z3_mk_atmost: at most k variables can be true * Z3_mk_atleast: at least k variables can be true * Z3_mk_pble: weighted pseudo-boolean less-than-or-equal constraint * Z3_mk_pbge: weighted pseudo-boolean greater-than-or-equal constraint * Z3_mk_pbeq: weighted pseudo-boolean equality constraint - Comprehensive test cases covering edge cases, negative coefficients, zero thresholds, empty arrays, and complex scenarios - All tests pass successfully with 100% coverage achieved Coverage improvement: api_pb.cpp went from 0% (0/64 lines) to 100% (64/64 lines)
Contributor
|
this kind of unit test, when automatically created, is OK to have. Even as it tests basically nothing of interest, it looks low threshold and can catch regressions. |
Collaborator
Author
My personal approach is
But totally up to you all of course. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive test coverage for Z3's pseudo-boolean constraint API functions, achieving 100% coverage for the
src/api/api_pb.cppmodule, which previously had 0% test coverage.Problem Found
The pseudo-boolean constraint API functions (
Z3_mk_*) had zero test coverage despite being important functionality for constraint solving:src/api/api_pb.cpp: 0% coverage (0/64 lines covered)Actions Taken
src/test/api_pb.cppsrc/test/main.cppandsrc/test/CMakeLists.txtZ3_mk_atmost: at most k of the variables can be trueZ3_mk_atleast: at least k of the variables can be trueZ3_mk_pble: weighted pseudo-boolean less-than-or-equal constraintZ3_mk_pbge: weighted pseudo-boolean greater-than-or-equal constraintZ3_mk_pbeq: weighted pseudo-boolean equality constraintTest Coverage Results
Before:
src/api/api_pb.cpp: 0% coverage (0/64 lines)After:
src/api/api_pb.cpp: 100% coverage (64/64 lines) - +64 lines coveredCoverage improvement achieved: Complete coverage of all pseudo-boolean constraint API functions with comprehensive testing of edge cases and functionality.
Replicating the Test Coverage Measurements
Build and run the new test:
Expected Output:
Commands to install dependencies, build, run tests, and generate coverage reports:
Future Improvement Areas
Based on remaining 0% coverage areas for other API modules:
src/api/api_datalog.cpp(0% coverage, 486 lines) - Datalog API functionssrc/api/api_fpa.cpp(0% coverage, 1090 lines) - Floating-point arithmetic APIsrc/api/api_qe.cpp(0% coverage, 112 lines) - Quantifier elimination APIsrc/api/api_polynomial.cpp(0% coverage, 33 lines) - Polynomial API functions<details>
<summary>Workflow Details</summary>
Bash Commands Run
git checkout -b daily-test-improver-api-pb-testsninja -C build test-z3./build/test-z3 api_pbgcovr --merge-mode-functions=separate --gcov-ignore-parse-errors --gcov-executable "llvm-cov gcov" . | grep api_pbgit add src/test/api_pb.cpp src/test/main.cpp src/test/CMakeLists.txtgit commit --author "Daily Test Coverage Improver <github-actions[bot]@users.noreply.github.com>" -m "..."Web Searches Performed
None
Web Pages Fetched
None
</details>
> AI-generated content by Daily Test Coverage Improver may contain mistakes.