content: /*
   * This file was automatically generated by UTestGen and EvoSuite
   * Sun Mar 17 21:52:16 GMT 2024
   */
  
  package weka.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.awt.HeadlessException;
  import org.evosuite.runtime.EvoRunner;
  import org.evosuite.runtime.EvoRunnerParameters;
  import org.junit.runner.RunWith;
  import weka.core.Memory;
  
  @RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true) 
  public class Memory_ESTest extends Memory_ESTest_scaffolding {
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testToMegaByteReturningZero() throws Throwable  {
        // Given: We have a method that converts bytes to megabytes
        // When: We pass 0 bytes as an argument
        double megaByte = Memory.toMegaByte(0L);
        
        // Then: The method should return 0.0, with a tolerance of +/- 0.01
        assertEquals(0.0, megaByte, 0.01);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testToMegaByteReturningNegative() throws Throwable  {
        // No Comments were added
        double megaByte = Memory.toMegaByte((-641L));
        assertEquals((-6.113052368164062E-4), megaByte, 0.01);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsEnabledReturningFalse() throws Throwable  {
        // Create a new Memory object and assert that it is initially enabled
        Memory memory = new Memory();
        assertTrue(memory.isEnabled(), "The memory should be enabled by default");
        
        // Disable the memory and check if it is disabled
        memory.setEnabled(false);
        boolean enabled = memory.isEnabled();
        assertFalse(enabled, "The memory should be disabled after calling setEnabled(false)");
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetUseGUIReturningTrue() throws Throwable  {
        // Given a Memory instance with the useGUI flag set to true
        Memory memory = new Memory(true);
        
        // When we call getUseGUI on this instance
        boolean actualValue = memory.getUseGUI();
        
        // Then we should get the expected value of true
        assertTrue(actualValue);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetMaxReturningZero() throws Throwable  {
        // Given a Memory object with a maximum value of 0
        Memory memory = new Memory(false);
        memory.m_Max = 0L;
        
        // When the getMax method is called
        long max = memory.getMax();
        
        // Then the maximum value returned should be 0
        assertEquals(0L, max);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetMaxReturningNegative() throws Throwable  {
        // Given: A Memory object with negative values set for m_Max
        Memory memory = new Memory();
        memory.m_Max = 1029L;
        memory.m_Max = 0L;
        memory.m_Max = (-2915L);
        
        // When: The getMax method is called on the Memory object
        long max = memory.getMax();
        
        // Then: The negative value of m_Max should be returned
        assertEquals((-2915L), max);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetInitialReturningZero() throws Throwable  {
        // No Comments were added
        Memory memory = new Memory();
        Memory.m_Initial = (-1206L);
        Memory.m_Initial = 0L;
        long initial = memory.getInitial();
        assertEquals(0L, initial);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetInitialReturningNegative() throws Throwable  {
        // Given a memory object with an initial value of -1L
        Memory memory = new Memory();
        memory.m_Initial = (-1L);
        
        // When we call getInitial() on this memory object
        long initial = memory.getInitial();
        
        // Then the initial value should be equal to -1L
        assertEquals((-1L), initial);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsEnabledReturningTrue() throws Throwable  {
        // Given: A Memory object with the enabled flag set to true
        Memory memory = new Memory();
        memory.setEnabled(true);
        
        // When: The isEnabled method is called on the Memory object
        boolean enabled = memory.isEnabled();
        
        // Then: The returned value should be true
        assertTrue(enabled);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetCurrent() throws Throwable  {
        // Given: we have a Memory object with some initial state
        Memory memory = new Memory();
        // When: we retrieve the current memory usage of the object
        long current = memory.getCurrent();
        // Then: the returned value should be 400L, which is the expected value
        assertEquals(400L, current);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetMaxReturningPositive() throws Throwable  {
        // Given a Memory object that has been initialized with some data
        Memory memory = new Memory();
        
        // When we retrieve the maximum value from the Memory object
        long max = memory.getMax();
        
        // Then we expect the result to be 500L, which is the maximum value in the test data
        assertEquals(500L, max);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetUseGUIReturningFalse() throws Throwable  {
        // Given: A Memory object with the useGUI flag set to false
        Memory memory = new Memory(false);
        
        // When: The getUseGUI method is called on the Memory object
        boolean useGUI = memory.getUseGUI();
        
        // Then: The value returned by the getUseGUI method should be false
        assertFalse(useGUI);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testToMegaByteReturningPositive() throws Throwable  {
        // No Comments were added
        double megaByte = Memory.toMegaByte(1234567890L);
        assertEquals(1177.3756885528564, megaByte, 0.01);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetInitialReturningPositive() throws Throwable  {
        // Given a Memory instance with an initial value of 400
        Memory memory = new Memory();
        long expectedInitialValue = 400L;
        
        // When the getInitial method is called
        long actualInitialValue = memory.getInitial();
        
        // Then the returned value should be equal to the expected initial value
        assertEquals(expectedInitialValue, actualInitialValue);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testStopThreads() throws Throwable  {
        // rollbacked to evosuite
        Memory memory = new Memory();
        memory.stopThreads();
        assertEquals(400L, memory.getInitial());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testShowOutOfMemoryThrowsHeadlessException() throws Throwable  {
        // Create a new Memory object with the flag to indicate that it is headless (no GUI)
        Memory memory = new Memory(true);
        
        // Expect an exception to be thrown when trying to show out of memory message
        try {
        // Try to show out of memory message
        memory.showOutOfMemory();
        
        // Fail the test if no exception was thrown, indicating that an expected exception was not thrown
        fail("Expected exception: HeadlessException");
        
        } catch(HeadlessException e) {
        // Verify that the exception is an instance of HeadlessException
        verifyException("java.awt.GraphicsEnvironment", e);
        
        // No message in exception (getMessage() returned null)
        assertNull(e.getMessage());}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testShowOutOfMemory() throws Throwable  {
        // rollbacked to evosuite
        Memory memory = new Memory(false);
        assertTrue(memory.isEnabled());
        
        memory.setEnabled(false);
        memory.showOutOfMemory();
        assertFalse(memory.isEnabled());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesMemoryTakingNoArgumentsAndCallsIsOutOfMemory() throws Throwable  {
        // No Comments were added
        Memory memory = new Memory();
        memory.m_Max = 2617L;
        Memory.m_Initial = (-1877L);
        memory.m_Max = (-1877L);
        memory.m_Max = 262L;
        memory.m_Max = 200197L;
        boolean outOfMemory = memory.isOutOfMemory();
        assertEquals((-1877L), memory.getInitial());
        assertFalse(outOfMemory);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsOutOfMemory() throws Throwable  {
        // No Comments were added
        Memory memory = new Memory(false);
        assertTrue(memory.isEnabled());
        
        memory.setEnabled(false);
        boolean outOfMemory = memory.isOutOfMemory();
        assertFalse(memory.isEnabled());
        assertFalse(outOfMemory);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsOutOfMemoryReturningTrue() throws Throwable  {
        // Given: A Memory object is created and its initial state is unknown
        Memory memory = new Memory();
        
        // When: The isOutOfMemory() method is called on the Memory object
        boolean outOfMemory = memory.isOutOfMemory();
        
        // Then: The isOutOfMemory() method returns true, indicating that the Memory object has exceeded its maximum limit of 500 bytes
        assertEquals(true, outOfMemory);
        
        // Given: The maximum limit of the Memory object has been reached
        assertEquals(500L, memory.getMax());
        
        // When: The getInitial() method is called on the Memory object
        long initial = memory.getInitial();
        
        // Then: The getInitial() method returns 400 bytes, indicating that the Memory object was initially allocated 400 bytes of memory
        assertEquals(400L, initial);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testMain() throws Throwable  {
        // No Comments were added
        Memory.main((String[]) null);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetRevision() throws Throwable  {
        // Test that we can get the revision number from the memory
        Memory memory = new Memory();
        String expectedRevision = "8034"; // The expected revision number
        String actualRevision = memory.getRevision();
        assertEquals(expectedRevision, actualRevision);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesMemoryTakingNoArgumentsAndCallsShowOutOfMemory() throws Throwable  {
        // Given a memory object with the use of GUI disabled
        Memory memory = new Memory();
        assertFalse(memory.getUseGUI());
        
        // When showOutOfMemory method is called on the memory object
        memory.showOutOfMemory();
        
        // Then the isEnabled method should return true
        assertTrue(memory.isEnabled());
    }
  }
  