-
Notifications
You must be signed in to change notification settings - Fork 593
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
Unit tests for Utils.concat() #7918
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7918 +/- ##
===============================================
+ Coverage 86.981% 87.082% +0.101%
+ Complexity 36962 36961 -1
===============================================
Files 2221 2215 -6
Lines 173894 173717 -177
Branches 18785 18778 -7
===============================================
+ Hits 151254 151276 +22
+ Misses 15998 15816 -182
+ Partials 6642 6625 -17
|
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.
@orlicohen Looks good, just a few minor changes needed
new Object[]{ new byte[] {100, 100}, new byte[] {100, 100}, new byte[] { } }, | ||
new Object[]{ ArrayUtils.EMPTY_BYTE_ARRAY, new byte[] { }, new byte[] { } }, | ||
new Object[]{ new byte[] {100, 100, 100, 100}, new byte[] {100, 100}, new byte[] {100, 100} }, | ||
}; |
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.
Comments on the test cases for the varargs version of concat():
- Calling concat() with 2 byte arrays actually calls the two-arg specialization of concat(), not the varargs version, so none of your test cases here should have 2 input arrays. Call concat() with 0, 1, or 3+ arrays to test the varargs version.
- The values inside your arrays should not all be the same (100), otherwise you are not actually testing whether the method is preserving the original order of the values correctly during concatenation.
new Object[]{ new byte[] { }, new byte[] { }, ArrayUtils.EMPTY_BYTE_ARRAY }, | ||
new Object[]{ new byte[] {100, 100}, new byte[] { }, new byte[] {100, 100} }, | ||
new Object[]{ new byte[] { }, new byte[] {100, 100}, new byte[] {100, 100} }, | ||
new Object[]{ new byte[] {100, 100}, new byte[] {100, 100}, new byte[] {100, 100, 100, 100} }, |
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.
Comments on the test cases for the two-arg version of concat():
- As above, the values inside your arrays should not all be the same (100), otherwise you are not actually testing whether the method is preserving the original order of the values correctly during concatenation.
- Include at least one additional test case involving an array of length 1, as that is a common edge case for methods like this.
new Integer[] {4, 5, 6} }, | ||
new Object[]{ new Integer[] {1, 2, 3}, new Integer[] {4, 5, 6}, (IntFunction<Integer[]>)Integer[]::new, | ||
new Integer[] {1, 2, 3, 4, 5, 6} }, | ||
}; |
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.
Comments on the test cases for the generic version of concat():
- Include an additional test case with { 4, 5, 6 } and { 1, 2, 3 } passed in the reverse order, giving { 4, 5, 6, 1, 2, 3 }. This will demonstrate that the method is preserving input order correctly and not doing something silly like sorting the values during concatenation.
|
||
@Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "concatAnyTypeWithNullArrayData") | ||
public void testConcatAnyTypeWithNullArray(Integer[] arr1, Integer[] arr2, IntFunction<Integer[]> constructor){ | ||
Utils.concat(arr1, arr2, constructor); |
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.
Null tests look good 👍
@@ -28,7 +30,8 @@ | |||
* Testing framework for general purpose utilities class. | |||
* | |||
*/ | |||
public final class UtilsUnitTest extends GATKBaseTest { | |||
public final class | |||
UtilsUnitTest extends GATKBaseTest { |
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.
Class name should be on the same line as the declaration
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.
@orlicohen Two quick remaining comments, then this should be good to go
new Object[]{ new byte[] {100, 100}, new byte[] {100, 100} }, | ||
new Object[]{ new byte[] {100, 100, 10, 10}, new byte[] {100, 100}, new byte[] { }, new byte[] {10,10} }, | ||
new Object[]{ ArrayUtils.EMPTY_BYTE_ARRAY, new byte[] { }, new byte[] { }, new byte[] { } }, | ||
new Object[]{ new byte[] {10, 10, 15, 15, 20, 20}, new byte[] {10, 10}, new byte[] {15, 15}, new byte[] {20, 20} }, |
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.
This test case checks that the method is preserving the relative ordering of the separate byte arrays, but does not test whether the ordering within each array is also preserved. You can fix this by having the values within one of the arrays differ as well, and ideally not be sorted -- for example, changing the first array to { 12, 10 }
new Object[]{ new byte[] {10, 10}, new byte[] { }, new byte[] {10, 10} }, | ||
new Object[]{ new byte[] { }, new byte[] {10, 10}, new byte[] {10, 10} }, | ||
new Object[]{ new byte[] {10}, new byte[] {15, 15}, new byte[] {10, 15, 15} }, | ||
new Object[]{ new byte[] {10, 10}, new byte[] {15, 15}, new byte[] {10, 10, 15, 15} }, |
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.
Same comment here: change the first array to something like { 12, 10 }
to demonstrate that ordering within each input array is being preserved.
Added comprehensive unit tests for the various overloads of Utils.concat(), which were not previously covered by tests. Resolves #7916
Fixes #7916. Data providers and unit tests for the various overloads of Utils.concat()