[ 
https://issues.apache.org/jira/browse/COLLECTIONS-860?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniele updated COLLECTIONS-860:
--------------------------------
    Description: 
*CollectionBag.add(E):*

Using "null" as parameter the method throws a "NullPointerException", but not 
signed into the specification.

*CollectionBag.add(E, int):*

A "ClassCastException" can be generated, but not signed into the specification.

 
{code:java}
Test used (generated by EvoSuite):
/*
 * This file was automatically generated by EvoSuite
 * Sun May 05 21:30:41 GMT 2024
 */
package org.apache.commons.collections4.bag;
import org.junit.Test;
import static org.junit.Assert.*;
import static shaded.org.evosuite.runtime.EvoAssertions.*;
import java.util.Collection;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.collections4.bag.CollectionBag;
import org.apache.commons.collections4.bag.TreeBag;
import org.apache.commons.collections4.functors.NonePredicate;
import org.junit.runner.RunWith;
import shaded.org.evosuite.runtime.EvoRunner;
import shaded.org.evosuite.runtime.EvoRunnerParameters;
@RunWith(EvoRunner.class)
@EvoRunnerParameters(mockJVMNonDeterminism = true, useVNET = true, 
separateClassLoader = true)
public class CollectionBag_4_failure_Test extends 
CollectionBag_4_failure_Test_scaffolding {
    //Covered goal: 
org.apache.commons.collections4.bag.CollectionBag.add(Ljava/lang/Object;I)Z: 
true ---> methodResultID==true – path condition 
org.apache.commons.collections4.bag.EvoSuiteEvaluator_4_failure (id = 7)
    @Test(timeout = 4000)
    public void testAdd_Always() throws Throwable {
        TreeBag<Predicate<Object>> treeBag0 = new TreeBag<Predicate<Object>>();
        CollectionBag<Predicate<Object>> collectionBag0 = new 
CollectionBag<Predicate<Object>>(treeBag0);
        Predicate<Object> predicate0 = 
NonePredicate.nonePredicate((Collection<? extends Predicate<? super Object>>) 
collectionBag0);
        // Undeclared exception!
        try
{             //** Guard on which the oracle of method add depends: true        
     org.junit.Assume.assumeTrue(true);             //** Automatically 
generated test oracle is: true, always., with guard: \{ description: true, 
always., conditionText: true }
            boolean //** Automatically generated test oracle is: true, always., 
with guard: { description: true, always., conditionText: true }
            methodResult_ = collectionBag0.add(predicate0, 24);
            //** Postcondition on which the oracle of method add depends: 
methodResultID==true
            org.junit.Assert.assertTrue(methodResult_ == true);
        } catch (ClassCastException e)
{             //             // 
org.apache.commons.collections4.functors.TruePredicate cannot be cast to 
java.lang.Comparable             //             
verifyException("java.util.TreeMap", e);             org.junit.Assert.fail();   
      }
        if (true)
            throw new RuntimeException("Failure-driven test case completed 
without pinpointing any failure. This should not happen. Please check");
    }
}
 
{code}
 

  was:
*CollectionBag.add(E):*

Using "null" as parameter the method throws a "NullPointerException", but not 
signed into the specification.

*CollectionBag.add(E, int):*

A "ClassCastException" can be generated, but not signed into the specification.

*Test used (generated by EvoSuite):*

/*
 * This file was automatically generated by EvoSuite
 * Sun May 05 21:30:41 GMT 2024
 */

package org.apache.commons.collections4.bag;

import org.junit.Test;
import static org.junit.Assert.*;
import static shaded.org.evosuite.runtime.EvoAssertions.*;
import java.util.Collection;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.collections4.bag.CollectionBag;
import org.apache.commons.collections4.bag.TreeBag;
import org.apache.commons.collections4.functors.NonePredicate;
import org.junit.runner.RunWith;
import shaded.org.evosuite.runtime.EvoRunner;
import shaded.org.evosuite.runtime.EvoRunnerParameters;

@RunWith(EvoRunner.class)
@EvoRunnerParameters(mockJVMNonDeterminism = true, useVNET = true, 
separateClassLoader = true)
public class CollectionBag_4_failure_Test extends 
CollectionBag_4_failure_Test_scaffolding {

    //Covered goal: 
org.apache.commons.collections4.bag.CollectionBag.add(Ljava/lang/Object;I)Z: 
true ---> methodResultID==true -- path condition 
org.apache.commons.collections4.bag.EvoSuiteEvaluator_4_failure (id = 7)
    @Test(timeout = 4000)
    public void testAdd_Always() throws Throwable {
        TreeBag<Predicate<Object>> treeBag0 = new TreeBag<Predicate<Object>>();
        CollectionBag<Predicate<Object>> collectionBag0 = new 
CollectionBag<Predicate<Object>>(treeBag0);
        Predicate<Object> predicate0 = 
NonePredicate.nonePredicate((Collection<? extends Predicate<? super Object>>) 
collectionBag0);
        // Undeclared exception!
        try {
            //** Guard on which the oracle of method add depends: true
            org.junit.Assume.assumeTrue(true);
            //** Automatically generated test oracle is: true, always., with 
guard: \{ description: true, always., conditionText: true }
            boolean //** Automatically generated test oracle is: true, always., 
with guard: \{ description: true, always., conditionText: true }
            _methodResult__ = collectionBag0.add(predicate0, 24);
            //** Postcondition on which the oracle of method add depends: 
methodResultID==true
            org.junit.Assert.assertTrue(_methodResult__ == true);
        } catch (ClassCastException e) {
            //
            // org.apache.commons.collections4.functors.TruePredicate cannot be 
cast to java.lang.Comparable
            //
            verifyException("java.util.TreeMap", e);
            org.junit.Assert.fail();
        }
        if (true)
            throw new RuntimeException("Failure-driven test case completed 
without pinpointing any failure. This should not happen. Please check");
    }
}

 


> Documentation Bug: CollectionBag.add(E), CollectionBag.add(E, int)
> ------------------------------------------------------------------
>
>                 Key: COLLECTIONS-860
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-860
>             Project: Commons Collections
>          Issue Type: Bug
>            Reporter: Daniele
>            Priority: Minor
>
> *CollectionBag.add(E):*
> Using "null" as parameter the method throws a "NullPointerException", but not 
> signed into the specification.
> *CollectionBag.add(E, int):*
> A "ClassCastException" can be generated, but not signed into the 
> specification.
>  
> {code:java}
> Test used (generated by EvoSuite):
> /*
>  * This file was automatically generated by EvoSuite
>  * Sun May 05 21:30:41 GMT 2024
>  */
> package org.apache.commons.collections4.bag;
> import org.junit.Test;
> import static org.junit.Assert.*;
> import static shaded.org.evosuite.runtime.EvoAssertions.*;
> import java.util.Collection;
> import org.apache.commons.collections4.Predicate;
> import org.apache.commons.collections4.bag.CollectionBag;
> import org.apache.commons.collections4.bag.TreeBag;
> import org.apache.commons.collections4.functors.NonePredicate;
> import org.junit.runner.RunWith;
> import shaded.org.evosuite.runtime.EvoRunner;
> import shaded.org.evosuite.runtime.EvoRunnerParameters;
> @RunWith(EvoRunner.class)
> @EvoRunnerParameters(mockJVMNonDeterminism = true, useVNET = true, 
> separateClassLoader = true)
> public class CollectionBag_4_failure_Test extends 
> CollectionBag_4_failure_Test_scaffolding {
>     //Covered goal: 
> org.apache.commons.collections4.bag.CollectionBag.add(Ljava/lang/Object;I)Z: 
> true ---> methodResultID==true – path condition 
> org.apache.commons.collections4.bag.EvoSuiteEvaluator_4_failure (id = 7)
>     @Test(timeout = 4000)
>     public void testAdd_Always() throws Throwable {
>         TreeBag<Predicate<Object>> treeBag0 = new 
> TreeBag<Predicate<Object>>();
>         CollectionBag<Predicate<Object>> collectionBag0 = new 
> CollectionBag<Predicate<Object>>(treeBag0);
>         Predicate<Object> predicate0 = 
> NonePredicate.nonePredicate((Collection<? extends Predicate<? super Object>>) 
> collectionBag0);
>         // Undeclared exception!
>         try
> {             //** Guard on which the oracle of method add depends: true      
>        org.junit.Assume.assumeTrue(true);             //** Automatically 
> generated test oracle is: true, always., with guard: \{ description: true, 
> always., conditionText: true }
>             boolean //** Automatically generated test oracle is: true, 
> always., with guard: { description: true, always., conditionText: true }
>             methodResult_ = collectionBag0.add(predicate0, 24);
>             //** Postcondition on which the oracle of method add depends: 
> methodResultID==true
>             org.junit.Assert.assertTrue(methodResult_ == true);
>         } catch (ClassCastException e)
> {             //             // 
> org.apache.commons.collections4.functors.TruePredicate cannot be cast to 
> java.lang.Comparable             //             
> verifyException("java.util.TreeMap", e);             org.junit.Assert.fail(); 
>         }
>         if (true)
>             throw new RuntimeException("Failure-driven test case completed 
> without pinpointing any failure. This should not happen. Please check");
>     }
> }
>  
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to