content: /*
   * This file was automatically generated by UTestGen and EvoSuite
   * Tue Mar 19 17:53:04 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 static org.evosuite.runtime.EvoAssertions.*;
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.ListIterator;
  import java.util.SortedSet;
  import net.sf.javaml.core.Dataset;
  import net.sf.javaml.core.DefaultDataset;
  import net.sf.javaml.core.Fold;
  import net.sf.javaml.core.Instance;
  import net.sf.javaml.distance.NormalizedEuclideanSimilarity;
  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 Fold_ESTest extends Fold_ESTest_scaffolding {
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSizeReturningPositive() throws Throwable  {
        // rollbacked to evosuite
        DefaultDataset arg0 = new DefaultDataset();
        int[] arg1 = new int[7];
        Fold fold = new Fold(arg0, arg1);
        int size = fold.size();
        assertEquals(7, size);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testListIteratorTakingIntReturningListIteratorWhereHasNextIsTrue() throws Throwable  {
        // Given: A DefaultDataset and an array of ints
        DefaultDataset dataset = new DefaultDataset();
        int[] inputData = new int[1];
        
        // When: Creating a Fold with the DefaultDataset and the input data
        Fold fold = new Fold(dataset, inputData);
        
        // Then: The list iterator should not have any previous elements
        ListIterator<Instance> listIterator = fold.listIterator(0);
        assertFalse(listIterator.hasPrevious());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIterator() throws Throwable  {
        // Given a DefaultDataset and an array of integers
        DefaultDataset dataset = new DefaultDataset();
        int[] labels = new int[8];
        
        // When we create a Fold object using the dataset and labels
        Fold fold = new Fold(dataset, labels);
        
        // Then the iterator should not be null
        assertNotNull(fold.iterator());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCopy() throws Throwable  {
        // Given a DefaultDataset and an array of integers representing the labels
        DefaultDataset dataset = new DefaultDataset();
        int[] labels = new int[0];
        
        // When a Fold object is created with the given dataset and labels
        Fold fold = new Fold(dataset, labels);
        
        // Then the copy method should return an empty Dataset
        Dataset copy = fold.copy();
        assertTrue(copy.isEmpty());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testToArray() throws Throwable  {
        // Given an empty dataset and a fold of length 0
        DefaultDataset data = new DefaultDataset();
        int[] foldLengths = new int[0];
        Fold fold = new Fold(data, foldLengths);
        
        // When the toArray method is called
        Object[] array = fold.toArray();
        
        // Then the resulting array should be empty
        assertEquals(0, array.length);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testListIteratorTakingNoArguments() throws Throwable  {
        // Given an empty dataset
        DefaultDataset arg0 = new DefaultDataset();
        
        // When we create a Fold with the dataset and an array of 0 length
        int[] arg1 = new int[0];
        Fold fold = new Fold(arg0, arg1);
        
        // Then the list iterator should not have any previous elements
        ListIterator<Instance> listIterator = fold.listIterator();
        assertFalse(listIterator.hasPrevious());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testRemoveTakingIntThrowsUnsupportedOperationException() throws Throwable  {
        // Given a dataset and a fold object
        DefaultDataset arg0 = new DefaultDataset();
        Fold fold = new Fold(arg0, null);
        
        // When we try to remove an element from the fold
        try {
        fold.remove(7);
        fail("Expecting exception: UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
        // Then it should throw an exception indicating that this operation is not supported on a fold
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testRemoveTakingObjectThrowsUnsupportedOperationException() throws Throwable  {
        DefaultDataset arg0 = new DefaultDataset();
        Fold fold = new Fold(arg0, null);
        
        // Given a fold and a dataset
        Dataset dataset = arg0;
        
        // When trying to remove the dataset from the fold
        try {
        fold.remove((Object) dataset);
        
        // Then an exception is thrown because it is not possible to remove a dataset from a fold
        fail("Expecting exception: UnsupportedOperationException");
        
        } catch(UnsupportedOperationException e) {
        // Verify that the correct exception was thrown
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testContainsThrowsUnsupportedOperationException() throws Throwable  {
        // Given a Fold instance with a DefaultDataset argument and null fold argument
        DefaultDataset arg0 = new DefaultDataset();
        Fold fold = new Fold(arg0, (int[]) null);
        
        // When the contains method is called on the Fold instance with the DefaultDataset argument
        boolean actual = fold.contains(arg0);
        
        // Then an UnsupportedOperationException should be thrown
        assertThrows(UnsupportedOperationException.class, () -> fold.contains(arg0));
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetThrowsUnsupportedOperationException() throws Throwable  {
        DefaultDataset arg0 = new DefaultDataset();
        Fold fold = new Fold(arg0, (int[]) null);
        try {
        fold.set(-1392, (Instance) null);
        fail("Expecting exception: UnsupportedOperationException");
        } catch(UnsupportedOperationException e) {
        // This is because you cannot add to a Fold. It is only used for partitioning data.
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testContainsAllThrowsUnsupportedOperationException() throws Throwable  {
        DefaultDataset arg0 = new DefaultDataset();
        Fold fold = new Fold(arg0, null);
        
        // Verify that the method is not yet implemented
        try {
        fold.containsAll(arg0);
        fail("Expecting exception: UnsupportedOperationException");
        } catch(UnsupportedOperationException e) {
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testRemoveAllThrowsUnsupportedOperationException() throws Throwable  {
        DefaultDataset arg0 = new DefaultDataset();
        Fold fold = new Fold(arg0, (int[]) null);
        // This test verifies that the removeAll() method throws an UnsupportedOperationException when called on a Fold object.
        try {
        fold.removeAll(arg0);
        fail("Expecting exception: UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
        // This is the expected behavior, as we cannot modify the fold in any way.
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testAddTakingInstanceThrowsUnsupportedOperationException() throws Throwable  {
        // Given a dataset and a fold on it
        DefaultDataset dataset = new DefaultDataset();
        Fold fold = new Fold(dataset, (int[]) null);
        
        // When we try to add a null instance to the fold
        try {
        fold.add((Instance) null);
        } catch (UnsupportedOperationException e) {
        // Then we expect an exception to be thrown
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testClearThrowsUnsupportedOperationException() throws Throwable  {
        DefaultDataset dataset = new DefaultDataset();
        Fold fold = new Fold(dataset, null);
        
        try {
        fold.clear();
        fail("Expecting exception: UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
        // Cannot do this on a fold of a dataset
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testNoAttributes() throws Throwable  {
        DefaultDataset dataset = new DefaultDataset();
        int[] attributeIndices = {1, 2, 3};
        Fold fold = new Fold(dataset, attributeIndices);
        
        // Given: a DefaultDataset and an array of attribute indices
        // When: the Fold class is instantiated with these parameters
        // Then: the Fold object should have the expected number of attributes
        int noAttributes = fold.noAttributes();
        assertEquals(3, noAttributes);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testKNearestThrowsUnsupportedOperationException() throws Throwable  {
        DefaultDataset arg0 = new DefaultDataset();
        Fold fold = new Fold(arg0, (int[]) null);
        NormalizedEuclideanSimilarity arg2 = new NormalizedEuclideanSimilarity(arg0);
        
        // This test verifies that the method "kNearest" is not yet implemented for the class "Fold".
        try {
        fold.kNearest((-1271), (Instance) null, arg2);
        fail("Expecting exception: UnsupportedOperationException");
        } catch(UnsupportedOperationException e) {
        // This is the expected behavior of the method "kNearest" for this class.
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testLastIndexOfThrowsUnsupportedOperationException() throws Throwable  {
        // Given a dataset and a fold object
        DefaultDataset arg0 = new DefaultDataset();
        Fold fold = new Fold(arg0, (int[]) null);
        
        // When trying to get the last index of the folded dataset
        try {
        // Then an UnsupportedOperationException is thrown
        fold.lastIndexOf(arg0);
        fail("Expecting exception: UnsupportedOperationException");
        } catch(UnsupportedOperationException e) {
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSizeReturningZero() throws Throwable  {
        // Test that the size of an empty Fold is 0
        DefaultDataset dataset = new DefaultDataset();
        int[] indices = new int[0];
        Fold fold = new Fold(dataset, indices);
        assertEquals(0, fold.size());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testClassValue() throws Throwable  {
        // Given a dataset and a fold with a class label for a specific instance
        DefaultDataset dataset = new DefaultDataset();
        int[] classLabels = new int[6];
        Fold fold = new Fold(dataset, classLabels);
        
        // When the class value is requested for an instance that does not have a class label
        Object classValue = fold.classValue(205);
        
        // Then the method should return null
        assertNull(classValue);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testListIteratorTakingIntReturningListIteratorWhereHasNextIsFalse() throws Throwable  {
        // Given a dataset and a list of instance indices
        DefaultDataset data = new DefaultDataset();
        int[] instances = new int[0];
        Fold fold = new Fold(data, instances);
        
        // When we get the iterator for the 32nd index in the fold
        ListIterator<Instance> it = fold.listIterator(32);
        
        // Then we should not have a next element in the iterator
        assertFalse(it.hasNext());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIndexOfThrowsUnsupportedOperationException() throws Throwable  {
        DefaultDataset arg0 = new DefaultDataset();
        // Create a new fold instance using the default constructor.
        Fold fold = new Fold(arg0, (int[]) null);
        
        try {
        // Call the indexOf() method on the fold object with the dataset as an argument.
        fold.indexOf(arg0);
        
        // Expecting exception: UnsupportedOperationException.
        fail("Expecting exception: UnsupportedOperationException");
        } catch(UnsupportedOperationException e) {
        //
        // Method is not yet implemented, as it is not supported by the Fold class.
        //
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testAddAllTaking2ArgumentsThrowsUnsupportedOperationException() throws Throwable  {
        // Given a DefaultDataset object "dataset" containing instances
        DefaultDataset dataset = new DefaultDataset();
        
        // When trying to add all instances from "dataset" to a Fold object "fold" at index 0
        Fold fold = new Fold(dataset, (int[]) null);
        
        // Then we expect an UnsupportedOperationException to be thrown
        try {
        fold.addAll(0, dataset);
        fail("Expecting exception: UnsupportedOperationException");
        } catch(UnsupportedOperationException e) {
        // Verify that the correct exception is thrown
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testAddAllTakingCollectionThrowsUnsupportedOperationException() throws Throwable  {
        // Given: A Fold object and a Dataset object
        DefaultDataset dataset = new DefaultDataset();
        int[] foldIndices = new int[6];
        Fold fold = new Fold(dataset, foldIndices);
        
        // When: Adding all elements from the Dataset to the Fold
        try {
        fold.addAll((Collection<? extends Instance>) dataset);
        fail("Expecting exception: UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
        // Then: The operation is not supported and an exception is thrown
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSubListThrowsUnsupportedOperationException() throws Throwable  {
        // Arrange
        DefaultDataset arg0 = new DefaultDataset();
        Fold fold = new Fold(arg0, null);
        
        // Act and Assert
        try {
        fold.subList((-2975), (-2975));
        fail("Expecting exception: UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
        // You cannot do this on a fold.
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testClassIndex() throws Throwable  {
        // Given a dataset with no class labels
        DefaultDataset arg0 = new DefaultDataset();
        
        // When we call the classIndex method with null values
        Fold fold = new Fold(arg0, (int[]) null);
        int classIndex = fold.classIndex((Object) null);
        
        // Then we expect to get -1 as the result
        assertEquals(-1, classIndex);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testClasses() throws Throwable  {
        // Given an empty dataset
        DefaultDataset defaultDataset = new DefaultDataset();
        
        // When a fold is created with the dataset
        Fold fold = new Fold(defaultDataset, null);
        
        // Then the classes of the fold should be empty
        SortedSet<Object> classes = fold.classes();
        assertEquals(0, classes.size());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testRetainAllThrowsUnsupportedOperationException() throws Throwable  {
        // Given a fold with null values for the dataset and indices
        Fold fold = new Fold((Dataset) null, (int[]) null);
        
        // When trying to retain all elements from a null collection
        try {
        fold.retainAll((Collection<?>) null);
        } catch (UnsupportedOperationException e) {
        // Then the operation is not supported
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testAddTaking2ArgumentsThrowsUnsupportedOperationException() throws Throwable  {
        DefaultDataset dataset = new DefaultDataset();
        Fold fold = new Fold(dataset, null); // Create a fold of the dataset
        
        // Try to add a new instance (1052) with a null value for the feature
        try {
        fold.add(1052, null); // Add the instance to the fold
        fail("Expecting exception: UnsupportedOperationException");
        } catch(UnsupportedOperationException e) {
        // Verify that an UnsupportedOperationException is thrown as expected
        verifyException("net.sf.javaml.core.Fold", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsEmpty() throws Throwable  {
        // Given: A dataset is created
        DefaultDataset arg0 = new DefaultDataset();
        
        // When: A fold is created with the dataset and no specific folds are provided
        Fold fold = new Fold(arg0, (int[]) null);
        
        // Then: The fold should not be empty
        boolean empty = fold.isEmpty();
        assertFalse(empty);
    }
  }
  