Skip to content

Commit c87a348

Browse files
committed
add a clCreateContext test with an empty device vector
1 parent 6854f63 commit c87a348

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

tests/test_openclhpp.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,40 @@ void testMoveConstructContextNonNull(void);
535535
void testMoveConstructContextNull(void);
536536
MAKE_MOVE_TESTS(Context, make_context, clReleaseContext, contextPool)
537537

538+
static cl_context clCreateContext_testEmptyDevices(
539+
const cl_context_properties* properties,
540+
cl_uint num_devices,
541+
const cl_device_id* devices,
542+
void (CL_CALLBACK* pfn_notify)(const char* errinfo, const void* private_info, size_t cb, void* user_data),
543+
void* user_data,
544+
cl_int* errcode_ret,
545+
int num_calls)
546+
{
547+
TEST_ASSERT_EQUAL(properties, nullptr);
548+
TEST_ASSERT_EQUAL(num_devices, 0);
549+
TEST_ASSERT_EQUAL(devices, nullptr);
550+
TEST_ASSERT_EQUAL(pfn_notify, nullptr);
551+
TEST_ASSERT_EQUAL(user_data, nullptr);
552+
553+
if (errcode_ret) {
554+
errcode_ret[0] = CL_INVALID_VALUE;
555+
}
556+
557+
return nullptr;
558+
}
559+
560+
void testContextCreateEmptyDevices(void)
561+
{
562+
#ifndef CL_HPP_ENABLE_EXCEPTIONS
563+
clCreateContext_StubWithCallback(clCreateContext_testEmptyDevices);
564+
565+
cl::vector<cl::Device> vec;
566+
cl::Context context(vec);
567+
568+
TEST_ASSERT_EQUAL(nullptr, context());
569+
#endif
570+
}
571+
538572
/// Stub for querying CL_CONTEXT_DEVICES that returns two devices
539573
static cl_int clGetContextInfo_testContextGetDevices(
540574
cl_context context,

0 commit comments

Comments
 (0)