diff --git a/opencl/test/unit_test/built_ins/built_in_tests.cpp b/opencl/test/unit_test/built_ins/built_in_tests.cpp index 45317aa293..10af6b447c 100644 --- a/opencl/test/unit_test/built_ins/built_in_tests.cpp +++ b/opencl/test/unit_test/built_ins/built_in_tests.cpp @@ -1262,13 +1262,9 @@ TEST_F(BuiltInTests, WhenGettingBuilderInfoTwiceThenPointerIsSame) { } TEST_F(BuiltInTests, GivenUnknownBuiltInOpWhenGettingBuilderInfoThenExceptionThrown) { - bool caughtException = false; - try { - BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::COUNT, *pClDevice); - } catch (const std::runtime_error &) { - caughtException = true; - } - EXPECT_TRUE(caughtException); + EXPECT_THROW( + BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::COUNT, *pClDevice), + std::runtime_error); } TEST_F(BuiltInTests, GivenUnsupportedBuildTypeWhenBuildingDispatchInfoThenFalseIsReturned) { diff --git a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp index ce3bd7d84f..0859dcf60f 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp +++ b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp @@ -1868,19 +1868,12 @@ TEST_F(MemoryManagerWithCsrTest, GivenAllocationsInHostPtrManagerWhenBiggerOverl GraphicsAllocation *graphicsAllocation3 = nullptr; - bool catchMe = false; - try { - graphicsAllocation3 = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), false, MemoryConstants::pageSize * 10}, cpuPtr3); - } catch (...) { - catchMe = true; - } + EXPECT_ANY_THROW(graphicsAllocation3 = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), false, MemoryConstants::pageSize * 10}, cpuPtr3)); EXPECT_NE(nullptr, graphicsAllocation1); EXPECT_NE(nullptr, graphicsAllocation2); EXPECT_EQ(nullptr, graphicsAllocation3); - EXPECT_TRUE(catchMe); - EXPECT_EQ((uintptr_t)cpuPtr1 & ~MemoryConstants::pageMask, (uintptr_t)graphicsAllocation1->fragmentsStorage.fragmentStorageData[0].cpuPtr); EXPECT_EQ((uintptr_t)cpuPtr2 & ~MemoryConstants::pageMask, (uintptr_t)graphicsAllocation2->fragmentsStorage.fragmentStorageData[0].cpuPtr); EXPECT_EQ(((uintptr_t)cpuPtr2 + MemoryConstants::pageSize) & ~MemoryConstants::pageMask, (uintptr_t)graphicsAllocation2->fragmentsStorage.fragmentStorageData[1].cpuPtr); diff --git a/shared/test/unit_test/memory_manager/host_ptr_manager_tests.cpp b/shared/test/unit_test/memory_manager/host_ptr_manager_tests.cpp index 4582d75418..a35044f201 100644 --- a/shared/test/unit_test/memory_manager/host_ptr_manager_tests.cpp +++ b/shared/test/unit_test/memory_manager/host_ptr_manager_tests.cpp @@ -574,14 +574,8 @@ TEST_F(HostPtrManagerTest, GivenFragmentSizeNonZeroWhenGettingFragmentThenCorrec auto ptr3 = (void *)0x040000; auto size3 = MemoryConstants::pageSize * 2; requiredAllocations = hostPtrManager.getAllocationRequirements(rootDeviceIndex, ptr3, size3); - auto catchme = false; - try { - OsHandleStorage st = hostPtrManager.populateAlreadyAllocatedFragments(requiredAllocations); - EXPECT_EQ(st.fragmentCount, 0u); - } catch (...) { - catchme = true; - } - EXPECT_TRUE(catchme); + + EXPECT_ANY_THROW(hostPtrManager.populateAlreadyAllocatedFragments(requiredAllocations)); } TEST_F(HostPtrManagerTest, WhenCheckingForOverlapsThenCorrectStatusIsReturned) { diff --git a/shared/test/unit_test/utilities/containers_tests.cpp b/shared/test/unit_test/utilities/containers_tests.cpp index 031a73936d..071c8eb91f 100644 --- a/shared/test/unit_test/utilities/containers_tests.cpp +++ b/shared/test/unit_test/utilities/containers_tests.cpp @@ -953,14 +953,8 @@ void testIDListUnlockOnException() { }; ListMock l; - bool caughtEx = false; - try { - l.throwExFromLock(); - } catch (const ExType &) { - caughtEx = true; - } + EXPECT_THROW(l.throwExFromLock(), ExType); - EXPECT_TRUE(caughtEx); EXPECT_FALSE(l.getLockedRef().test_and_set(std::memory_order_seq_cst)); }