| 1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | 
|---|
| 2 | // | 
|---|
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later | 
|---|
| 4 |  | 
|---|
| 5 | #ifndef QTCASSERT_H | 
|---|
| 6 | #define QTCASSERT_H | 
|---|
| 7 |  | 
|---|
| 8 | //namespace Utils { void writeAssertLocation(const char *msg){} } | 
|---|
| 9 |  | 
|---|
| 10 | #define QTC_ASSERT_STRINGIFY_HELPER(x) #x | 
|---|
| 11 | #define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(x) | 
|---|
| 12 | #define QTC_ASSERT_STRING(cond) /*::Utils::writeAssertLocation(\ | 
|---|
| 13 | "\"" cond"\" in file " __FILE__ ", line " QTC_ASSERT_STRINGIFY(__LINE__))*/ | 
|---|
| 14 |  | 
|---|
| 15 | // The 'do {...} while (0)' idiom is not used for the main block here to be | 
|---|
| 16 | // able to use 'break' and 'continue' as 'actions'. | 
|---|
| 17 |  | 
|---|
| 18 | #define QTC_ASSERT(cond, action) if (cond) {} else { QTC_ASSERT_STRING(#cond); action; } do {} while (0) | 
|---|
| 19 | #define QTC_CHECK(cond) if (cond) {} else { QTC_ASSERT_STRING(#cond); } do {} while (0) | 
|---|
| 20 | #define QTC_GUARD(cond) ((cond) ? true : (QTC_ASSERT_STRING(#cond), false)) | 
|---|
| 21 |  | 
|---|
| 22 | #endif // QTCASSERT_H | 
|---|
| 23 |  | 
|---|