1
0
Fork 0

Adding a test

This commit is contained in:
Pcornat 2025-12-13 12:34:38 +01:00
commit a53e5f87be
Signed by: Pcornat
GPG key ID: E0326CC678A00BDD
2 changed files with 17 additions and 0 deletions

View file

@ -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

View file

@ -0,0 +1,16 @@
//
// Created by postaron on 13/12/2025.
//
#include <iostream>
#include <catch2/catch_all.hpp>
#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<int, safe_cuda::allocType::Managed>(sizeof(int));
REQUIRE(safe_ptr != nullptr);
REQUIRE(error == cudaSuccess);
std::cout << "Safely deallocates memory in CUDA" << std::endl;
}