-
Notifications
You must be signed in to change notification settings - Fork 20.4k
Fix MiniMaxAlgorithm setScores bug and add comprehensive tests #6566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix MiniMaxAlgorithm setScores bug and add comprehensive tests #6566
Conversation
- Fix bug in setScores method where scores.length % 1 == 0 always returned true - Add isPowerOfTwo helper method to properly validate array length - Add comprehensive unit tests covering edge cases and algorithm correctness - Tests include validation for power of 2 check, minimax logic, and error handling Fixes issue with incorrect validation logic in MiniMaxAlgorithm.setScores()
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6566 +/- ##
============================================
+ Coverage 75.31% 75.49% +0.18%
- Complexity 5659 5679 +20
============================================
Files 693 693
Lines 19552 19554 +2
Branches 3786 3786
============================================
+ Hits 14725 14763 +38
+ Misses 4252 4215 -37
- Partials 575 576 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Replace star imports with explicit imports in test file - Remove trailing whitespaces from all lines - Add proper file ending newline - Improve setScores method to handle edge cases properly - Use direct bit manipulation for power-of-2 check as suggested - Ensure error message is printed and scores remain unchanged for invalid input All Checkstyle violations resolved and tests pass successfully.
- Fix Checkstyle violation: NewlineAtEndOfFile - Ensure file ends with proper newline character - All tests continue to pass successfully
- Replace inline bit manipulation with isPowerOfTwo method call - Resolves PMD UnusedPrivateMethod violation - Maintains same validation logic and error handling - All tests continue to pass successfully
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks
- Add comprehensive test cases for isPowerOfTwo function edge cases - Test setScores method with various invalid array lengths (0, 3, 5, 6, 7, 9, 10, 15) - Add tests for large valid powers of 2 (up to 64 elements) - Ensure complete coverage of error handling branches - Increase test count from 14 to 19 tests - Fix partial coverage issues identified in CodeCov report Resolves CodeCov coverage gaps in MiniMaxAlgorithm.java
Head branch was pushed to by a user without write access
Hi @DenizAltunkapan , could you please re-review my PR? I've added some additional test cases to increase the code coverage. |
Issue
Fixes #6563
Fixes issue with incorrect validation logic in MiniMaxAlgorithm.setScores()
clang-format -i --style=file path/to/your/file.java