mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-07 12:42:54 +08:00
Use EXPECT_THROW instead of handmade try-catch in tests
Signed-off-by: Patryk Wrobel <patryk.wrobel@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
301be3c21b
commit
4395e0c3a1
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user