diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3739b0f..6a1f8d7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,6 +22,7 @@ include(CatchAddTests) add_executable(tests tests_stream.cpp + tests_safe_allocation.cpp ) target_link_libraries(tests Catch2::Catch2WithMain raiiSafeCuda) set_target_properties(tests PROPERTIES diff --git a/tests/tests_safe_allocation.cpp b/tests/tests_safe_allocation.cpp new file mode 100644 index 0000000..8ba3e89 --- /dev/null +++ b/tests/tests_safe_allocation.cpp @@ -0,0 +1,16 @@ +// +// Created by postaron on 13/12/2025. +// + +#include +#include + +#include "../include/malloc_unmanaged.hpp" + +TEST_CASE("Managed allocation", "[safe_alloc][0]") { + std::cout << "Safely allocates memory in CUDA" << std::endl; + const auto [safe_ptr, error] = safe_cuda::cuda_malloc(sizeof(int)); + REQUIRE(safe_ptr != nullptr); + REQUIRE(error == cudaSuccess); + std::cout << "Safely deallocates memory in CUDA" << std::endl; +}