import pytest
from hypothesis import given, strategies as st
import time
from robobench.core.utils import get_memory_usage, measure_time, MemorySnapshot

def test_memory_snapshot_creation():
    snapshot = MemorySnapshot(ram_used=100.0)
    assert snapshot.ram_used == 100.0
    assert snapshot.gpu_memory_used is None

def test_get_memory_usage():
    snapshot = get_memory_usage()
    assert isinstance(snapshot, MemorySnapshot)
    assert snapshot.ram_used > 0

@given(st.integers(min_value=0, max_value=1000))
def test_measure_time_decorator(sleep_ms):
    @measure_time
    def dummy_function(ms):
        time.sleep(ms / 1000)
        return "result"

    result, duration = dummy_function(sleep_ms)
    assert result == "result"
    assert duration >= (sleep_ms / 1000)
