[ 
https://issues.apache.org/jira/browse/LANG-1615?focusedWorklogId=511983&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-511983
 ]

ASF GitHub Bot logged work on LANG-1615:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 15/Nov/20 16:59
            Start Date: 15/Nov/20 16:59
    Worklog Time Spent: 10m 
      Work Description: garydgregory commented on a change in pull request #651:
URL: https://github.com/apache/commons-lang/pull/651#discussion_r523784572



##########
File path: src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
##########
@@ -309,6 +309,14 @@ public void testContainsFloat() {
         assertFalse(ArrayUtils.contains(array, (float) 99));
     }
 
+    @Test
+    public void testContainsFloatNaN() {
+        float[] a = new float[] { Float.NEGATIVE_INFINITY, Float.NaN, 
Float.POSITIVE_INFINITY };

Review comment:
       a -> array




----------------------------------------------------------------
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: 511983)
    Time Spent: 20m  (was: 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: 20m
>  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)

Reply via email to