| 1 | // |
| 2 | // SPDX-FileCopyrightText: Copyright 2025 Arm Limited and/or its affiliates <open-source-office@arm.com> |
| 3 | // |
| 4 | // SPDX-License-Identifier: Apache-2.0 |
| 5 | // |
| 6 | |
| 7 | #pragma once |
| 8 | |
| 9 | #include <stdexcept> |
| 10 | |
| 11 | #include "kai/kai_common.h" |
| 12 | |
| 13 | #if defined(KAI_ERROR_TRAP) |
| 14 | #define KAI_TEST_ERROR(msg) __builtin_trap() |
| 15 | #elif defined(__cpp_exceptions) |
| 16 | #define KAI_TEST_ERROR(msg) throw std::runtime_error(msg) |
| 17 | #else |
| 18 | #define KAI_TEST_ERROR(msg) KAI_ERROR(msg) |
| 19 | #endif // KAI_ERROR_TRAP |
| 20 | |
| 21 | #define KAI_TEST_ASSERT_MSG(cond, msg) \ |
| 22 | do { \ |
| 23 | if (!(cond)) { \ |
| 24 | KAI_TEST_ERROR(msg); \ |
| 25 | } \ |
| 26 | } while (false) |
| 27 | |
| 28 | #define KAI_TEST_ASSERT(cond) KAI_TEST_ASSERT_MSG(cond, "Assertion failed! " #cond) |