Skip to content

Commit 48a5bb1

Browse files
Added test class to test DRef=nullptr case (#496)
1 parent 509a586 commit 48a5bb1

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

dpctl-capi/tests/test_sycl_device_manager.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct TestDPCTLGetDevices : public ::testing::TestWithParam<int>
9393
EXPECT_NO_FATAL_FAILURE(DV = DPCTLDeviceMgr_GetDevices(GetParam()));
9494
EXPECT_TRUE(DV != nullptr);
9595
EXPECT_NO_FATAL_FAILURE(nDevices = DPCTLDeviceVector_Size(DV));
96+
EXPECT_TRUE(nDevices == DPCTLDeviceMgr_GetNumDevices(GetParam()));
9697
}
9798

9899
void SetUp()
@@ -206,3 +207,26 @@ INSTANTIATE_TEST_SUITE_P(
206207
DPCTLSyclDeviceType::DPCTL_ACCELERATOR,
207208
DPCTLSyclDeviceType::DPCTL_GPU,
208209
DPCTLSyclDeviceType::DPCTL_CPU));
210+
211+
struct TestDPCTLDeviceMgrNullReference : public ::testing::Test
212+
{
213+
DPCTLSyclDeviceRef nullDRef = nullptr;
214+
};
215+
216+
TEST_F(TestDPCTLDeviceMgrNullReference, ChkPrintDeviceInfo)
217+
{
218+
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceMgr_PrintDeviceInfo(nullDRef));
219+
}
220+
221+
TEST_F(TestDPCTLDeviceMgrNullReference, ChkGetRelativeId)
222+
{
223+
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceMgr_GetRelativeId(nullDRef));
224+
}
225+
226+
TEST_F(TestDPCTLDeviceMgrNullReference, ChkGetPositionInDevices)
227+
{
228+
int mask = DPCTLSyclDeviceType::DPCTL_ALL |
229+
DPCTLSyclBackendType::DPCTL_ALL_BACKENDS;
230+
EXPECT_NO_FATAL_FAILURE(
231+
DPCTLDeviceMgr_GetPositionInDevices(nullDRef, mask));
232+
}

0 commit comments

Comments
 (0)