Skip to content

Commit a7d7769

Browse files
Replaced assert() with new macro TEST() in all tests, to check conditions also in Release configuration.
1 parent 4868c1f commit a7d7769

File tree

4 files changed

+227
-198
lines changed

4 files changed

+227
-198
lines changed

src/Common.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <utility>
1717
#include <chrono>
1818
#include <string>
19+
#include <exception>
1920

2021
#include <cassert>
2122
#include <cstdlib>
@@ -25,7 +26,21 @@
2526
typedef std::chrono::high_resolution_clock::time_point time_point;
2627
typedef std::chrono::high_resolution_clock::duration duration;
2728

28-
#define ERR_GUARD_VULKAN(Expr) do { VkResult res__ = (Expr); if (res__ < 0) assert(0); } while(0)
29+
#ifdef _DEBUG
30+
#define TEST(expr) do { \
31+
if(!(expr)) { \
32+
assert(0 && #expr); \
33+
} \
34+
} while(0)
35+
#else
36+
#define TEST(expr) do { \
37+
if(!(expr)) { \
38+
throw std::runtime_error("TEST FAILED: " #expr); \
39+
} \
40+
} while(0)
41+
#endif
42+
43+
#define ERR_GUARD_VULKAN(expr) TEST((expr) >= 0)
2944

3045
extern VkPhysicalDevice g_hPhysicalDevice;
3146
extern VkDevice g_hDevice;

src/SparseBindingTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void SparseBindingImage::Init(RandomNumberGenerator& rand)
128128
// But it doesn't help. Looks like a bug in Vulkan validation layers.
129129
uint32_t sparseMemReqCount = 0;
130130
vkGetImageSparseMemoryRequirements(g_hDevice, m_Image, &sparseMemReqCount, nullptr);
131-
assert(sparseMemReqCount <= 8);
131+
TEST(sparseMemReqCount <= 8);
132132
VkSparseImageMemoryRequirements sparseMemReq[8];
133133
vkGetImageSparseMemoryRequirements(g_hDevice, m_Image, &sparseMemReqCount, sparseMemReq);
134134

0 commit comments

Comments
 (0)