More Comprehensive Edge Case Testing #1294
Open
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.
This PR improves the ArrayFillTest class in the org.apache.commons.lang3 package by addressing null safety, adding edge case coverage, and refactoring redundant test code for better readability and maintainability.
Changes:
Refactor Using @ParameterizedTest:
Combined similar test cases into a single parameterized test method using @ParameterizedTest and @MethodSource, reducing redundancy in tests for different data types (e.g., byte[], char[], double[], String[]).
Null Safety Enhancements:
Updated tests for null arrays to explicitly check that ArrayFill.fill() returns null when a null array is passed.
Example: testFillByteArrayNull, testFillCharArrayNull, etc., now include assertions to verify null handling.
Improved Readability:
Replaced numeric literals for char arrays with more readable character literals (e.g., 'A' instead of 1) in testFillCharArray.
Edge Case Coverage:
Added new test cases for:
Empty Arrays: Verifying behavior when filling an empty array.
Arrays with Default Values: Ensuring ArrayFill.fill() correctly handles arrays already populated with default values.
Object Arrays with null Values: Added a test to ensure ArrayFill.fill() can handle filling object arrays with null values.
New Test Methods:
testFillEmptyArray: Ensures the method works correctly for empty arrays.
testFillObjectArrayWithNull: Tests behavior when filling an object array with null values.
testFillArrayWithDefaultValues: Verifies behavior when arrays already have default values.