[
https://issues.apache.org/jira/browse/LANG-1615?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gary D. Gregory resolved LANG-1615.
-----------------------------------
Fix Version/s: 3.12
Resolution: Fixed
[~arturobernalg]
In git master now; please verify and close this ticket.
TY!
> ArrayUtils contains() and 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
> Assignee: Gary D. Gregory
> Priority: Major
> Labels: pull-request-available
> Fix For: 3.12
>
> Time Spent: 1h
> 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)