Skip to content

Fix NumberUtilsTest#testMaxDouble() and testMaxFloat()#1506

Merged
garydgregory merged 3 commits intoapache:masterfrom
TheRealHaui:Correct-NumberUtils-getMax-tests
Nov 28, 2025
Merged

Fix NumberUtilsTest#testMaxDouble() and testMaxFloat()#1506
garydgregory merged 3 commits intoapache:masterfrom
TheRealHaui:Correct-NumberUtils-getMax-tests

Conversation

@TheRealHaui
Copy link
Copy Markdown
Contributor

Corrected tests related to getMax in NumberUtilsTest

@Test
void testMaxDouble_nullArray() {
assertNullPointerException(() -> NumberUtils.max((double[]) null));
assertNullPointerException(() -> NumberUtils.max((double[]) null), "No exception was thrown for null input.");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this extra message IMO, it doesn't help more than the actual assert.

void testMaxDouble_emptyArray() {
assertIllegalArgumentException(NumberUtils::max);
final double[] d = new double[0];
assertIllegalArgumentException(() -> NumberUtils.max(d), "No exception was thrown for empty input.");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to clutter things up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@garydgregory,
the reason why I changed it and/or propose to change it is the pattern of the tests or better test names in the NumberUtilsTest class.
The name of the test - testMaxDouble_emptyArray - imposes that method "public static double max(final double... array) ..." gets called.
However, because of the used Lamba/method reference "NumberUtils::max" actually "public static byte max(final byte... array) ..." gets called.

Don't get me wrong I do NOT want to be super picky or appear super-smart!
Just want to explain why I proposed to change it.

@garydgregory garydgregory changed the title Corrected NumberUtilsTest#getMax... tests Fix NumberUtilsTest#testMaxDouble() and testMaxFloat() Nov 28, 2025
@garydgregory garydgregory merged commit 7e0cc1e into apache:master Nov 28, 2025
19 of 20 checks passed
@TheRealHaui
Copy link
Copy Markdown
Contributor Author

@garydgregory,
thanks for merging!

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