Skip to content

Commit

Permalink
Add tests for invalid arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
csbnw committed Sep 20, 2023
1 parent 32d06e6 commit 6d18c82
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_vector_add.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,17 @@ TEST_CASE("Vector add") {
check_arrays_equal(h_c, reference_c.data(), N);
}
}

SECTION("Pass invalid CUmemorytype to cu::DeviceMemory constructor") {
CHECK_THROWS(cu::DeviceMemory(bytesize, CU_MEMORYTYPE_ARRAY));
CHECK_THROWS(cu::DeviceMemory(bytesize, CU_MEMORYTYPE_HOST));
}

SECTION("Pass flags with CU_MEMORYTYPE_DEVICE") {
CHECK_NOTHROW(cu::DeviceMemory(bytesize, CU_MEMORYTYPE_DEVICE, 0));
CHECK_THROWS(
cu::DeviceMemory(bytesize, CU_MEMORYTYPE_DEVICE, CU_MEM_ATTACH_GLOBAL));
CHECK_THROWS(
cu::DeviceMemory(bytesize, CU_MEMORYTYPE_DEVICE, CU_MEM_ATTACH_HOST));
}
}

0 comments on commit 6d18c82

Please sign in to comment.