content: /*
   * This file was automatically generated by UTestGen and EvoSuite
   * Mon Mar 18 11:44:14 GMT 2024
   */
  
  package org.apache.commons.collections.primitives;
  
  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 org.apache.commons.collections.primitives.ArrayByteList;
  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 ArrayByteList_ESTest extends ArrayByteList_ESTest_scaffolding {
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSizeReturningPositive() throws Throwable  {
        // Create a new instance of ArrayByteList and add an element to it
        ArrayByteList arrayByteList = new ArrayByteList();
        arrayByteList.add(0, (byte) (-24));
        
        // Verify that the size of the list is 1
        int size = arrayByteList.size();
        assertEquals(1, size);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetReturningZero() throws Throwable  {
        // Given an empty ArrayByteList with size 0
        ArrayByteList arrayByteList = new ArrayByteList(0);
        
        // When adding a value to the list at index 0
        arrayByteList.add(0, (byte)0);
        
        // Then the set method should return the added value
        byte set = arrayByteList.set((byte)0, (byte)0);
        assertEquals((byte)0, set);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetReturningPositive() throws Throwable  {
        ArrayByteList arrayByteList = new ArrayByteList();
        // Given a list with one element at index 0
        arrayByteList.add(0, (byte)26);
        // When we set the value of that element to 31
        byte set = arrayByteList.set(0, (byte)31);
        // Then the new value should be 31
        assertEquals((byte)31, set);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetReturningNegative() throws Throwable  {
        // Given a new ArrayByteList with size 0
        ArrayByteList arrayByteList = new ArrayByteList(0);
        
        // When adding an element to the list at index 0 with value -1
        arrayByteList.add(0, (byte) (-1));
        
        // Then the list size should be 1
        assertEquals(1, arrayByteList.size());
        
        // Given the list has a single element with value -1
        
        // When setting an element at index 1 to the value 1
        arrayByteList.add(0, (byte)1);
        
        // Then the returned value should be 1
        byte set = arrayByteList.set(1, (byte) (-1));
        assertEquals((byte) (-1), set);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testRemoveElementAtReturningNegative() throws Throwable  {
        // Create an empty byte list and add a single element
        ArrayByteList arrayByteList = new ArrayByteList();
        arrayByteList.add((byte) (-24));
        
        // Remove the added element from the list
        byte removedElement = arrayByteList.removeElementAt(0);
        
        // Assert that the size of the list is 0 and that the removed element is equal to the expected value
        assertEquals(0, arrayByteList.size());
        assertEquals((byte) (-24), removedElement);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetReturningZero() throws Throwable  {
        // Test that an empty ArrayByteList has a size of 0 and is not null.
        ArrayByteList arrayByteList = new ArrayByteList(0);
        assertNotNull(arrayByteList);
        assertEquals(0, arrayByteList.size());
        
        // Test that an ArrayByteList with one element has a size of 1 and the correct value.
        arrayByteList.add(0, (byte)0);
        assertEquals(1, arrayByteList.size());
        byte get = arrayByteList.get(0);
        assertEquals((byte)0, get);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetReturningPositive() throws Throwable  {
        // Create a new ArrayByteList with initial size 0
        ArrayByteList arrayByteList = new ArrayByteList(0);
        
        // Add an element to the list at index 0 with value (byte)2
        arrayByteList.add(0, (byte)2);
        
        // Get the element at index 0 from the list
        byte get = arrayByteList.get(0);
        
        // Assert that the list size is 1
        assertEquals(1, arrayByteList.size());
        
        // Assert that the value of the element at index 0 is (byte)2
        assertEquals((byte)2, get);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetReturningNegative() throws Throwable  {
        // Given: an ArrayByteList instance with a single element of value -10
        ArrayByteList arrayByteList = new ArrayByteList();
        arrayByteList.add((byte) (-10));
        
        // When: retrieving the first element from the list
        byte get = arrayByteList.get(0);
        
        // Then: the returned element should be equal to the expected value of -10
        assertEquals(1, arrayByteList.size());
        assertEquals((byte) (-10), get);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testEnsureCapacityWithZero() throws Throwable  {
        // Given an empty ArrayByteList
        ArrayByteList arrayByteList = new ArrayByteList();
        
        // When we ensure capacity of 0
        arrayByteList.ensureCapacity(0);
        
        // Then the size should be 0
        assertEquals(0, arrayByteList.size());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testAddWithPositive() throws Throwable  {
        ArrayByteList arrayByteList = new ArrayByteList(0);
        
        // Given: An empty list with a size of 0
        assertEquals(0, arrayByteList.size());
        
        try {
        // When: We attempt to add an element at index 4, which is out of bounds
        arrayByteList.add((int) (byte) 4, (byte) 4);
        
        // Then: An IndexOutOfBoundsException should be thrown
        fail("Expecting exception: IndexOutOfBoundsException");
        } catch(IndexOutOfBoundsException e) {
        // Should be at least 0 and at most 0, found 4
        verifyException("org.apache.commons.collections.primitives.ArrayByteList", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetWithNegative() throws Throwable  {
        ArrayByteList arrayByteList = new ArrayByteList();
        // Undeclared exception!
        try {
        arrayByteList.get((byte) (-24));
        fail("Expecting exception: IndexOutOfBoundsException");
        
        } catch(IndexOutOfBoundsException e) {
        // This test is verifying that the ArrayByteList class throws an IndexOutOfBoundsException when an invalid index is passed to the get method.
        // The value of -24 is not a valid index for the array, so this test should fail.
        verifyException("org.apache.commons.collections.primitives.ArrayByteList", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testTrimToSize() throws Throwable  {
        // Given: an empty ArrayByteList instance
        ArrayByteList arrayByteList = new ArrayByteList();
        
        // When: we call trimToSize() twice on the list
        arrayByteList.trimToSize();
        arrayByteList.trimToSize();
        
        // Then: the size of the list should be 0, as both calls to trimToSize() did nothing
        assertEquals(0, arrayByteList.size());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testEnsureCapacityWithPositive() throws Throwable  {
        // Given: A new instance of ArrayByteList and a valid input for capacity
        ArrayByteList arrayByteList = new ArrayByteList();
        int expectedSize = 4693;
        
        // When: The ensureCapacity method is called with the given capacity
        arrayByteList.ensureCapacity(expectedSize);
        
        // Then: The size of the list should be equal to the expected size
        assertEquals(expectedSize, arrayByteList.size());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesArrayByteListTakingNoArguments() throws Throwable  {
        // Given an empty byte list with a capacity of 10
        ArrayByteList arrayByteList = new ArrayByteList();
        
        // When the ensureCapacity method is called with a size of 10
        arrayByteList.ensureCapacity(10);
        
        // Then the size of the list should be 0
        assertEquals(0, arrayByteList.size());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testRemoveElementAtReturningPositive() throws Throwable  {
        // Create an ArrayByteList and add two elements to it
        ArrayByteList arrayByteList = new ArrayByteList();
        arrayByteList.add((byte) -76);
        arrayByteList.add(0, (byte)2);
        
        // Remove the first element from the list using removeElementAt() method
        byte removedElement = arrayByteList.removeElementAt(0);
        
        // Assert that the size of the list is 1 and that the removed element is equal to the expected value
        assertEquals(1, arrayByteList.size());
        assertEquals((byte)2, removedElement);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testRemoveElementAtReturningZero() throws Throwable  {
        ArrayByteList arrayByteList = new ArrayByteList();
        // Add a single element to the list
        arrayByteList.add((byte)0);
        assertEquals(1, arrayByteList.size());
        
        // Remove the first element from the list and store it in a variable
        byte removeElementAt = arrayByteList.removeElementAt((byte)0);
        
        // Verify that the removed element is the one we expected
        assertEquals((byte)0, removeElementAt);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testFailsToCreateArrayByteListTakingIntThrowsIllegalArgumentException() throws Throwable  {
        // Test the constructor with a negative capacity value, which is expected to throw an IllegalArgumentException.
        ArrayByteList arrayByteList = null;
        try {
        arrayByteList = new ArrayByteList(-5);
        fail("Expecting exception: IllegalArgumentException");
        } catch(IllegalArgumentException e) {
        // Verify that the correct exception is thrown.
        verifyException("org.apache.commons.collections.primitives.ArrayByteList", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetWithPositive() throws Throwable  {
        // Test that an IndexOutOfBoundsException is thrown when trying to access an element outside the bounds of the list
        ArrayByteList arrayByteList = new ArrayByteList();
        
        try {
        // Attempting to access the 101st element in the list, which is beyond the last index (100)
        arrayByteList.get(101);
        
        // We expect an IndexOutOfBoundsException to be thrown since we are trying to access an element outside the bounds of the list
        fail("Expecting exception: IndexOutOfBoundsException");
        } catch(IndexOutOfBoundsException e) {
        // Verify that the exception is the expected type and has the correct message
        verifyException("org.apache.commons.collections.primitives.ArrayByteList", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesArrayByteListTakingByteCollection() throws Throwable  {
        // Given: An instance of ArrayByteList and an empty array
        ArrayByteList arg0 = new ArrayByteList();
        
        // When: The ArrayByteList is created with the empty array
        ArrayByteList arrayByteList = new ArrayByteList(arg0);
        
        // Then: The size of the list should be 0 and the list should equal to the original array
        assertEquals(0, arg0.size());
        assertTrue(arrayByteList.equals((Object)arg0));
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testAddWithNegative() throws Throwable  {
        // Arrange
        ArrayByteList arrayByteList = new ArrayByteList();
        
        // Act and Assert
        try {
        arrayByteList.add(-984, (byte) 116);
        fail("Expecting exception: IndexOutOfBoundsException");
        } catch(IndexOutOfBoundsException e) {
        // Should be at least 0 and at most 0, found -984
        verifyException("org.apache.commons.collections.primitives.ArrayByteList", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSizeReturningZero() throws Throwable  {
        // Given an empty ArrayByteList instance
        ArrayByteList arrayByteList = new ArrayByteList();
        
        // When we retrieve the size of the list
        int size = arrayByteList.size();
        
        // Then the size should be 0
        assertEquals(0, size);
    }
  }
  