@@ -45,12 +45,12 @@ constexpr size_t SIZE = 1024;
4545void common_test_body (size_t nbytes,
4646 const DPCTLSyclUSMRef Ptr,
4747 const DPCTLSyclQueueRef Q,
48- const char * expected)
48+ DPCTLSyclUSMType expected)
4949{
5050 auto Ctx = DPCTLQueue_GetContext (Q);
5151
5252 auto kind = DPCTLUSM_GetPointerType (Ptr, Ctx);
53- EXPECT_TRUE (0 == std::strncmp (kind, expected, 4 ) );
53+ EXPECT_TRUE (kind == expected);
5454
5555 auto Dev = DPCTLUSM_GetPointerDevice (Ptr, Ctx);
5656 auto QueueDev = DPCTLQueue_GetDevice (Q);
@@ -100,7 +100,7 @@ TEST_F(TestDPCTLSyclUSMInterface, MallocShared)
100100 const size_t nbytes = SIZE;
101101 auto Ptr = DPCTLmalloc_shared (nbytes, Q);
102102 EXPECT_TRUE (bool (Ptr));
103- common_test_body (nbytes, Ptr, Q, " shared " );
103+ common_test_body (nbytes, Ptr, Q, DPCTLSyclUSMType::DPCTL_USM_SHARED );
104104 DPCTLfree_with_queue (Ptr, Q);
105105 DPCTLQueue_Delete (Q);
106106}
@@ -112,7 +112,7 @@ TEST_F(TestDPCTLSyclUSMInterface, MallocDevice)
112112 const size_t nbytes = SIZE;
113113 auto Ptr = DPCTLmalloc_device (nbytes, Q);
114114 EXPECT_TRUE (bool (Ptr));
115- common_test_body (nbytes, Ptr, Q, " device " );
115+ common_test_body (nbytes, Ptr, Q, DPCTLSyclUSMType::DPCTL_USM_DEVICE );
116116 DPCTLfree_with_queue (Ptr, Q);
117117 DPCTLQueue_Delete (Q);
118118}
@@ -124,7 +124,7 @@ TEST_F(TestDPCTLSyclUSMInterface, MallocHost)
124124 const size_t nbytes = SIZE;
125125 auto Ptr = DPCTLmalloc_host (nbytes, Q);
126126 EXPECT_TRUE (bool (Ptr));
127- common_test_body (nbytes, Ptr, Q, " host " );
127+ common_test_body (nbytes, Ptr, Q, DPCTLSyclUSMType::DPCTL_USM_HOST );
128128 DPCTLfree_with_queue (Ptr, Q);
129129 DPCTLQueue_Delete (Q);
130130}
@@ -136,7 +136,7 @@ TEST_F(TestDPCTLSyclUSMInterface, AlignedAllocShared)
136136 const size_t nbytes = SIZE;
137137 auto Ptr = DPCTLaligned_alloc_shared (64 , nbytes, Q);
138138 EXPECT_TRUE (bool (Ptr));
139- common_test_body (nbytes, Ptr, Q, " shared " );
139+ common_test_body (nbytes, Ptr, Q, DPCTLSyclUSMType::DPCTL_USM_SHARED );
140140 DPCTLfree_with_queue (Ptr, Q);
141141 DPCTLQueue_Delete (Q);
142142}
@@ -148,7 +148,7 @@ TEST_F(TestDPCTLSyclUSMInterface, AlignedAllocDevice)
148148 const size_t nbytes = SIZE;
149149 auto Ptr = DPCTLaligned_alloc_device (64 , nbytes, Q);
150150 EXPECT_TRUE (bool (Ptr));
151- common_test_body (nbytes, Ptr, Q, " device " );
151+ common_test_body (nbytes, Ptr, Q, DPCTLSyclUSMType::DPCTL_USM_DEVICE );
152152 DPCTLfree_with_queue (Ptr, Q);
153153 DPCTLQueue_Delete (Q);
154154}
@@ -160,7 +160,7 @@ TEST_F(TestDPCTLSyclUSMInterface, AlignedAllocHost)
160160 const size_t nbytes = SIZE;
161161 auto Ptr = DPCTLaligned_alloc_host (64 , nbytes, Q);
162162 EXPECT_TRUE (bool (Ptr));
163- common_test_body (nbytes, Ptr, Q, " host " );
163+ common_test_body (nbytes, Ptr, Q, DPCTLSyclUSMType::DPCTL_USM_HOST );
164164 DPCTLfree_with_queue (Ptr, Q);
165165}
166166
@@ -234,13 +234,10 @@ TEST_F(TestDPCTLSyclUSMNullArgs, ChkPointerQueries)
234234{
235235 DPCTLSyclContextRef Null_CRef = nullptr ;
236236 DPCTLSyclUSMRef Null_MRef = nullptr ;
237- const char *t = nullptr ;
238- auto is_unknown = [=](const char *t) -> bool {
239- return strncmp (t, " unknown" , 7 ) == 0 ;
240- };
237+ DPCTLSyclUSMType t = DPCTLSyclUSMType::DPCTL_USM_UNKNOWN;
241238
242239 EXPECT_NO_FATAL_FAILURE (t = DPCTLUSM_GetPointerType (Null_MRef, Null_CRef));
243- ASSERT_TRUE (is_unknown (t) );
240+ ASSERT_TRUE (t == DPCTLSyclUSMType::DPCTL_USM_UNKNOWN );
244241
245242 DPCTLSyclDeviceSelectorRef DSRef = nullptr ;
246243 DPCTLSyclDeviceRef DRef = nullptr ;
@@ -253,9 +250,8 @@ TEST_F(TestDPCTLSyclUSMNullArgs, ChkPointerQueries)
253250 EXPECT_NO_FATAL_FAILURE (CRef = DPCTLContext_Create (DRef, nullptr , 0 ));
254251 EXPECT_NO_FATAL_FAILURE (DPCTLDevice_Delete (DRef));
255252
256- t = nullptr ;
257253 EXPECT_NO_FATAL_FAILURE (t = DPCTLUSM_GetPointerType (Null_MRef, CRef));
258- ASSERT_TRUE (is_unknown (t) );
254+ ASSERT_TRUE (t == DPCTLSyclUSMType::DPCTL_USM_UNKNOWN );
259255
260256 DPCTLSyclDeviceRef D2Ref = nullptr ;
261257 EXPECT_NO_FATAL_FAILURE (D2Ref = DPCTLUSM_GetPointerDevice (Null_MRef, CRef));
0 commit comments