content: /*
   * This file was automatically generated by UTestGen and EvoSuite
   * Tue Mar 19 18:02:50 GMT 2024
   */
  
  package net.sf.javaml.core;
  
  import org.junit.jupiter.api.Test;
  import static org.junit.jupiter.api.Assertions.*;
  import org.junit.jupiter.api.Timeout;
  import java.util.concurrent.TimeUnit;
  import java.util.Collection;
  import java.util.Map;
  import java.util.Set;
  import java.util.SortedSet;
  import java.util.TreeSet;
  import net.sf.javaml.core.AbstractInstance;
  import net.sf.javaml.core.DenseInstance;
  import net.sf.javaml.core.Instance;
  import net.sf.javaml.core.SparseInstance;
  import org.evosuite.runtime.EvoRunner;
  import org.evosuite.runtime.EvoRunnerParameters;
  import org.junit.runner.RunWith;
  
  @RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true) 
  public class SparseInstance_ESTest extends SparseInstance_ESTest_scaffolding {
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testValueReturningPositive() throws Throwable  {
        // Arrange
        Object arg2 = new Object();
        SparseInstance sparseInstance = new SparseInstance(1, 1602.16578, arg2);
        
        // Act
        double value = sparseInstance.value(1);
        
        // Assert
        assertEquals(1602.16578, value, 0.01);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testValueReturningNegative() throws Throwable  {
        // Given a SparseInstance with no features and a non-zero value
        double[] arg0 = new double[0];
        Object arg2 = new Object();
        SparseInstance sparseInstance = new SparseInstance(arg0, (-269.3), arg2);
        
        // When the value method is called with an index of 0
        double value = sparseInstance.value(0);
        
        // Then the result should be the non-zero value
        assertEquals((-269.3), value, 0.01);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSizeReturningPositive() throws Throwable  {
        // Given a SparseInstance with 3 non-zero elements
        double[] arg0 = new double[3];
        SparseInstance sparseInstance = new SparseInstance(arg0, (-1941.43465972));
        
        // When the size of the SparseInstance is queried
        int size = sparseInstance.size();
        
        // Then the size should be 3
        assertEquals(3, size);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testRemoveReturningPositive() throws Throwable  {
        // Test the removal of a value from a sparse instance by removing the null key
        SparseInstance sparseInstance = new SparseInstance();
        sparseInstance.put((Integer) null, (Double) 1.0); // Add a value with a null key to the sparse instance
        Double remove = sparseInstance.remove((Object) null); // Remove the value with a null key from the sparse instance
        assertEquals(1.0, (double)remove, 0.01); // Assert that the removed value is equal to 1.0 within a tolerance of 0.01
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testPutReturningZero() throws Throwable  {
        // Given a SparseInstance object and two arguments, arg0 and arg1
        SparseInstance sparseInstance = new SparseInstance();
        Double arg1 = new Double(0.0);
        Integer arg0 = new Integer(2146748957);
        
        // When the put method is called with these arguments
        sparseInstance.put(arg0, arg1);
        
        // Then the value stored for key arg0 should be equal to arg1
        Double put = sparseInstance.put(arg0, arg1);
        assertEquals(0.0, (double)put, 0.01);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsEmptyReturningFalse() throws Throwable  {
        // Given a SparseInstance with 6 elements and the first element is -835.72986484
        double[] arg0 = new double[6];
        arg0[0] = (-835.72986484);
        SparseInstance sparseInstance = new SparseInstance(arg0, (Object) null);
        
        // When the method is called to check if it is empty
        boolean empty = sparseInstance.isEmpty();
        
        // Then the size of the SparseInstance should be 1
        assertEquals(1, sparseInstance.size());
        
        // And the SparseInstance should not be empty
        assertFalse(empty);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGet() throws Throwable  {
        // Given a SparseInstance with some data
        double[] arg0 = new double[7];
        Object arg2 = new Object();
        SparseInstance sparseInstance = new SparseInstance(arg0, 5771.13342, arg2);
        
        // When we call the get method with an index that exists in the instance
        Double get = sparseInstance.get(0.0);
        
        // Then the value at that index should be returned
        assertEquals(5771.13342, (double)get, 0.01);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCopyReturningInstanceWhereIsEmptyIsFalse() throws Throwable  {
        // No Comments were added
        Double arg2 = new Double(1);
        SparseInstance sparseInstance = new SparseInstance(1, 1, arg2);
        Integer arg0 = new Integer(1218);
        sparseInstance.replace(arg0, arg2, arg2);
        sparseInstance.copy();
        assertEquals(1, sparseInstance.size());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCopyReturningInstanceWhereGetIDIsZero() throws Throwable  {
        // Given: A SparseInstance with ID 0 and a copy of the instance
        SparseInstance sparseInstance = new SparseInstance(0);
        AbstractInstance.nextID = 0;
        Instance copy = sparseInstance.copy();
        
        // When: The instance is compared to its copy
        assertNotSame(copy, sparseInstance); // Verify that the copy is not the same as the original instance
        assertTrue(copy.equals((Object)sparseInstance)); // Verify that the copy is equal to the original instance
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCopyReturningInstanceWhereGetIDIsNegative() throws Throwable  {
        // Arrange
        Object arg2 = new Object();
        SparseInstance sparseInstance = new SparseInstance(1, 1, arg2);
        AbstractInstance.nextID = 1;
        
        // Act
        Instance copy = sparseInstance.copy();
        
        // Assert
        assertEquals(1, copy.getID());
        assertTrue(copy.equals((Object)sparseInstance));
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testContainsValueReturningFalse() throws Throwable  {
        // Given a sparse instance with a single value at index -1146
        SparseInstance arg0 = new SparseInstance((-1146));
        
        // When the containsValue method is called with the same sparse instance
        boolean containsValue = arg0.containsValue(arg0);
        
        // Then the result should be false, since the value at index -1146 is not present in the sparse instance
        assertFalse(containsValue);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSizeReturningZero() throws Throwable  {
        // Create a new sparse instance with 2 values and a third value that is not in the sparse array
        Object arg2 = new Object();
        SparseInstance sparseInstance = new SparseInstance((-2133493526), (-2133493526), arg2);
        
        // Check the size of the sparse instance, it should be 0 since there are no non-default values in the array
        int size = sparseInstance.size();
        assertEquals(0, size);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesSparseInstanceTaking3ArgumentsAndCallsCopy() throws Throwable  {
        // Given a sparse instance with ID 1 and two values, -2133493526 and -2133493526
        Object arg2 = new Object();
        SparseInstance sparseInstance = new SparseInstance((-2133493526), (-2133493526), arg2);
        
        // When we copy the sparse instance
        Instance arg0 = sparseInstance.copy();
        
        // Then the copied instance should be equal to the original instance
        assertEquals(1, arg0.getID());
        boolean equals = sparseInstance.equals(arg0);
        assertTrue(equals);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesSparseInstanceTakingInt() throws Throwable  {
        // Create a new sparse instance with the value -1146
        SparseInstance arg0 = new SparseInstance((-1146));
        
        // Check if the instance is equal to itself
        boolean equals = arg0.equals(arg0);
        
        // Assert that the instance is equal to itself
        assertTrue(equals);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testEqualsWithNull() throws Throwable  {
        // Given a SparseInstance object and a null reference
        SparseInstance sparseInstance = new SparseInstance();
        Object nullReference = null;
        
        // When we call equals() on the SparseInstance with the null reference as argument
        boolean equals = sparseInstance.equals(nullReference);
        
        // Then the result is false, indicating that the SparseInstance and null reference are not equal
        assertFalse(equals);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testHashCode() throws Throwable  {
        // Given a SparseInstance object with specific values for its fields
        Object arg2 = new Object();
        SparseInstance sparseInstance = new SparseInstance((-2133493526), (-2133493526), arg2);
        
        // When the hashCode method is called on this object
        int result = sparseInstance.hashCode();
        
        // Then the returned value should be a hash of the field values
        assertEquals(result, (-2133493526));
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testRemoveAttributeWithNegative() throws Throwable  {
        // This test verifies that the SparseInstance class can correctly remove an attribute from a list of attributes.
        // Setup
        double[] arg0 = new double[5];
        arg0[0] = 2663.0022;
        SparseInstance arg1 = new SparseInstance((-4666));
        SparseInstance sparseInstance = new SparseInstance(arg0, arg1);
        
        // Execution
        sparseInstance.removeAttribute(-2146663268);
        
        // Verification
        assertEquals(1, sparseInstance.size());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testRemoveAttributeWithPositive() throws Throwable  {
        // Given: A SparseInstance with a list of attributes and a value for the attribute at index 0.
        double[] arg0 = new double[5];
        arg0[0] = 237.45;
        Object arg1 = new Object();
        SparseInstance sparseInstance = new SparseInstance(arg0, arg1);
        
        // When: The removeAttribute method is called with the index of an attribute that exists in the SparseInstance.
        sparseInstance.removeAttribute(1749);
        
        // Then: The size of the SparseInstance should be 1, as only one attribute was removed.
        assertEquals(1, sparseInstance.size());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testRemoveAttributes() throws Throwable  {
        // No Comments were added
        SparseInstance sparseInstance = new SparseInstance();
        DenseInstance denseInstance = new DenseInstance(3209);
        SortedSet<Integer> arg0 = denseInstance.keySet();
        sparseInstance.removeAttributes(arg0);
        assertEquals(0, sparseInstance.getID());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testNoAttributesReturningNegative() throws Throwable  {
        // Given a SparseInstance object with a single attribute that has a value of -1024
        SparseInstance sparseInstance = new SparseInstance();
        Integer arg0 = new Integer((-1024));
        sparseInstance.replace(arg0, (Double) null);
        
        // When the noAttributes method is called on the SparseInstance object
        int noAttributes = sparseInstance.noAttributes();
        
        // Then the number of attributes in the SparseInstance should be (-1023), since it has only one attribute with a value of -1024
        assertEquals((-1023), noAttributes);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testNoAttributesReturningZero() throws Throwable  {
        // Given: A SparseInstance object with no attributes
        SparseInstance sparseInstance = new SparseInstance();
        
        // When: We call the noAttributes() method
        int noAttributes = sparseInstance.noAttributes();
        
        // Then: The returned value should be 0, indicating that the instance has no attributes
        assertEquals(0, noAttributes);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesSparseInstanceTaking2ArgumentsAndCreatesSparseInstanceTaking2Arguments0() throws Throwable  {
        // Given a SparseInstance with 3 elements and a value of -1146.0
        double[] arg0 = new double[3];
        SparseInstance sparseInstance = new SparseInstance(arg0, (-1146.0));
        
        // When the sqrt method is called on the SparseInstance
        Instance sqrt = sparseInstance.sqrt();
        
        // Then the size of the SparseInstance and the result of the sqrt method should be 3
        assertEquals(3, sparseInstance.size());
        assertEquals(3, sqrt.size());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testPutAll() throws Throwable  {
        // Create a new SparseInstance object and put all the values into it.
        SparseInstance arg0 = new SparseInstance();
        arg0.putAll(arg0);
        
        // Assert that the ID of the SparseInstance is 0.
        assertEquals(0, arg0.getID());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testRemoveReturningNull() throws Throwable  {
        // rollbacked to evosuite
        SparseInstance sparseInstance = new SparseInstance();
        Double remove = sparseInstance.remove((Object) 1);
        assertNull(remove);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testKeySet() throws Throwable  {
        // Test that the key set does not contain the given value
        Object arg2 = new Object();
        SparseInstance sparseInstance = new SparseInstance((-2133493526), (-2133493526), arg2);
        TreeSet<Integer> keySet = sparseInstance.keySet();
        assertFalse(keySet.contains((-2133493526)), "The key set should not contain the given value");
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetNoAttributes() throws Throwable  {
        // Given a sparse instance with no attributes
        double[] arg0 = new double[1];
        SparseInstance sparseInstance = new SparseInstance(arg0, 0.0);
        assertTrue(sparseInstance.isEmpty());
        
        // When the method is called to check if it is empty
        boolean result = sparseInstance.isEmpty();
        
        // Then the result should be true
        assertTrue(result);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testValueReturningZero() throws Throwable  {
        // Given a SparseInstance object with 0 features and a value for the first feature
        Object arg2 = new Object();
        SparseInstance sparseInstance = new SparseInstance(0, 0, arg2);
        
        // When the value method is called with argument 0
        double value = sparseInstance.value(0);
        
        // Then the value returned should be 0.0 within a tolerance of 0.01
        assertEquals(0.0, value, 0.01);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testToString() throws Throwable  {
        // Given a SparseInstance object with an ID and a value
        Object arg2 = new Object();
        SparseInstance sparseInstance = new SparseInstance((-2133493526), (-2133493526), arg2);
        
        // When the toString() method is called on the instance
        String string = sparseInstance.toString();
        
        // Then the resulting string should not be null
        assertNotNull(string);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsEmptyReturningTrue() throws Throwable  {
        // Given a SparseInstance with 6 elements, but all of them are zero
        double[] arg0 = new double[6];
        SparseInstance sparseInstance = new SparseInstance(arg0, (Object) null);
        
        // When we check if the SparseInstance is empty
        boolean empty = sparseInstance.isEmpty();
        
        // Then we expect the result to be true
        assertTrue(empty);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesSparseInstanceTaking2ArgumentsAndCallsEntrySet() throws Throwable  {
        // No Comments were added
        Object arg2 = new Object();
        SparseInstance sparseInstance = new SparseInstance((-2133493526), (-2133493526), arg2);
        Set<Map.Entry<Integer, Double>> arg1 = (Set<Map.Entry<Integer, Double>>)sparseInstance.entrySet();
        SparseInstance arg0 = new SparseInstance(1, arg1);
        boolean equals = sparseInstance.equals(arg0);
        assertFalse(arg0.equals((Object)sparseInstance));
        assertFalse(equals);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testValues() throws Throwable  {
        // Given a SparseInstance with some initial values
        Object arg2 = new Object();
        SparseInstance sparseInstance = new SparseInstance((-2133493526), (-2133493526), arg2);
        
        // When I call the `values` method
        Collection<Double> values = sparseInstance.values();
        
        // Then the returned collection should not be null
        assertNotNull(values);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testClear() throws Throwable  {
        // Given: A SparseInstance object with some elements
        Object arg = new Object();
        SparseInstance instance = new SparseInstance((-2133493526), (-2133493526), arg);
        int expectedSize = 3; // The number of elements in the instance
        
        // When: The clear method is called on the instance
        instance.clear();
        
        // Then: The size of the instance should be zero
        assertEquals(0, instance.size());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testContainsKeyReturningFalse() throws Throwable  {
        // Given a SparseInstance object and a null key
        SparseInstance sparseInstance = new SparseInstance();
        Object nullKey = null;
        
        // When the containsKey method is called with the null key as an argument
        boolean containsKey = sparseInstance.containsKey(nullKey);
        
        // Then it should return false, since the sparse instance does not contain any entries with a null key
        assertFalse(containsKey);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesSparseInstanceTakingDoubleArray() throws Throwable  {
        // Create a new SparseInstance with 3 attributes
        double[] arg0 = new double[3];
        SparseInstance sparseInstance = new SparseInstance(arg0);
        
        // Check that the number of attributes is correct
        int noAttributes = sparseInstance.noAttributes();
        assertEquals(3, noAttributes);
        
        // Check that the size is 0 (since there are no values)
        assertEquals(0, sparseInstance.size());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testContainsValueReturningTrue() throws Throwable  {
        // Test if SparseInstance contains a specific value
        double[] arg0 = new double[2];
        SparseInstance sparseInstance = new SparseInstance(arg0, 2907.154512804876, 0.0);
        
        // Verify that the instance has a size of 2
        assertEquals(2, sparseInstance.size());
        
        // Test if the instance contains a specific value
        boolean containsValue = sparseInstance.containsValue(0.0);
        assertTrue(containsValue);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testContainsKeyReturningTrue() throws Throwable  {
        // Create a new SparseInstance object with null value
        SparseInstance sparseInstance = new SparseInstance();
        
        // Replace the key-value pair with null as the value
        sparseInstance.replace((Integer) null, (Double) null);
        
        // Check if the key is present in the instance
        boolean containsKey = sparseInstance.containsKey((Object) null);
        
        // Assert that the instance is not empty and the key is present
        assertFalse(sparseInstance.isEmpty());
        assertTrue(containsKey);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesSparseInstanceTaking2ArgumentsAndCreatesSparseInstanceTaking2Arguments1() throws Throwable  {
        // Given a SparseInstance with an ID of 42
        SparseInstance sparseInstance = new SparseInstance(42, 42);
        
        // When the getID method is called
        int id = sparseInstance.getID();
        
        // Then the returned ID should be 0
        assertEquals(0, id);
    }
  }
  