mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
* Fix MiniMaxAlgorithm setScores bug and add comprehensive tests - 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() * Fix Checkstyle violations and improve setScores validation - 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. * Add missing newline at end of MiniMaxAlgorithmTest.java - Fix Checkstyle violation: NewlineAtEndOfFile - Ensure file ends with proper newline character - All tests continue to pass successfully * Fix PMD violation by utilizing isPowerOfTwo method - 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 * test: improve MiniMaxAlgorithm test coverage for CodeCov - 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 * Fix checkstyle errors * Fix checkstyle errors --------- Co-authored-by: ssaha <ssaha@wiley.com> Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>