Skip to content

Commit 41289ab

Browse files
UT for createSubBuffer
1 parent 550bec5 commit 41289ab

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

tests/test_openclhpp.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4517,4 +4517,37 @@ void testgetObjectInfo() {
45174517
TEST_ASSERT_EQUAL(type, CL_GL_OBJECT_BUFFER);
45184518
TEST_ASSERT_EQUAL(bufobj, 0);
45194519
}
4520+
#if CL_HPP_TARGET_OPENCL_VERSION >= 110
4521+
static cl_mem clCreateSubBuffer_testCreateSubBuffer(
4522+
cl_mem buffer, cl_mem_flags flags, cl_buffer_create_type buffer_create_type,
4523+
const void *buffer_create_info, cl_int *errcode_ret, int num_calls) {
4524+
(void)errcode_ret;
4525+
TEST_ASSERT_EQUAL(make_mem(0), buffer);
4526+
TEST_ASSERT_EQUAL(0, flags);
4527+
TEST_ASSERT_EQUAL(0, buffer_create_type);
4528+
TEST_ASSERT_EQUAL_PTR(nullptr, buffer_create_info);
4529+
TEST_ASSERT_EQUAL(0, num_calls);
4530+
4531+
return make_mem(1);
4532+
}
4533+
4534+
void testCreateSubBuffer() {
4535+
#ifndef CL_HPP_ENABLE_EXCEPTIONS
4536+
cl_mem_flags flags = 0;
4537+
cl_buffer_create_type buffer_create_type = 0;
4538+
const void *buffer_create_info = nullptr;
4539+
cl_int *err = nullptr;
4540+
static cl::Buffer ret;
4541+
4542+
clCreateSubBuffer_StubWithCallback(clCreateSubBuffer_testCreateSubBuffer);
4543+
ret = bufferPool[0].createSubBuffer(flags, buffer_create_type,
4544+
buffer_create_info, err);
4545+
4546+
TEST_ASSERT_EQUAL_PTR(make_mem(1), ret());
4547+
ret() = nullptr;
4548+
#endif
4549+
}
4550+
#else
4551+
void testCreateSubBuffer() {}
4552+
#endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
45204553
} // extern "C"

0 commit comments

Comments
 (0)