find_package(cmocka REQUIRED)

add_executable(test_arena test_arena.c)

target_link_libraries(test_arena
    arena
    cmocka::cmocka
)

# Sanitizers (solo si están activados y el compilador lo soporta)
if(ARENA_ENABLE_SANITIZERS)
    if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
        target_compile_options(test_arena PRIVATE
            -fsanitize=address
            -fno-omit-frame-pointer
        )
        target_link_options(test_arena PRIVATE
            -fsanitize=address
        )
    endif()
endif()

add_test(NAME arena_tests COMMAND test_arena)
