Skip to content
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

More Comprehensive Edge Case Testing #1294

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Bhavesh9908
Copy link

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.

@garydgregory
Copy link
Member

Hello @Bhavesh9908
The code coverage for ArrayFill is already at 100%:
https://commons.apache.org/proper/commons-lang/jacoco/org.apache.commons.lang3/ArrayFill.html#dn-a

Feel free to increase code coverage elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants