From a53e5f87be62bf17b5c7b9e6cd53fb4783afea1f Mon Sep 17 00:00:00 2001 From: Pcornat Date: Sat, 13 Dec 2025 12:34:38 +0100 Subject: [PATCH] Adding a test --- tests/CMakeLists.txt | 1 + tests/tests_safe_allocation.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/tests_safe_allocation.cpp 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; +}