[
https://issues.apache.org/jira/browse/LANG-1615?focusedWorklogId=511875&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-511875
]
ASF GitHub Bot logged work on LANG-1615:
----------------------------------------
Author: ASF GitHub Bot
Created on: 15/Nov/20 08:22
Start Date: 15/Nov/20 08:22
Worklog Time Spent: 10m
Work Description: arturobernalg opened a new pull request #651:
URL: https://github.com/apache/commons-lang/pull/651
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 511875)
Remaining Estimate: 0h
Time Spent: 10m
> ArrayUtils contains && indexOf fails to handle Float.NaN
> ---------------------------------------------------------
>
> Key: LANG-1615
> URL: https://issues.apache.org/jira/browse/LANG-1615
> Project: Commons Lang
> Issue Type: Bug
> Affects Versions: 3.11
> Reporter: Arturo Bernal
> Priority: Major
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The ArrayUtils.contains (float [], Float.NaN) and ArrayUtils.indexOf (float
> [], Float.NaN) methods do not handle correctly when the array contains
> Float.NaN. It should return that finds the element, but instead returns -1.
> For example, consider the following:
> {code:java}
> @Test
> public void testContainsFloatNaN() {
> float[] a = new float[] { Float.NEGATIVE_INFINITY, Float.NaN,
> Float.POSITIVE_INFINITY };
> assertTrue(ArrayUtils.contains(a, Float.POSITIVE_INFINITY));
> assertTrue(ArrayUtils.contains(a, Float.NEGATIVE_INFINITY));
> assertTrue(ArrayUtils.contains(a, Float.NaN)); // Error
> }{code}
>
> And
> {code:java}
> @Test
> public void testIndexOfFloatNaN() {
> float[] array = new float[] { Float.NEGATIVE_INFINITY, Float.NaN,
> Float.POSITIVE_INFINITY, Float.NaN };
> assertEquals(0, ArrayUtils.indexOf(array, Float.NEGATIVE_INFINITY));
> assertEquals(1, ArrayUtils.indexOf(array, Float.NaN)); // Error
> assertEquals(2, ArrayUtils.indexOf(array, Float.POSITIVE_INFINITY));
> }{code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)