diff options
Diffstat (limited to 'libmisc/tests/test.h')
-rw-r--r-- | libmisc/tests/test.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libmisc/tests/test.h b/libmisc/tests/test.h new file mode 100644 index 0000000..ea13d3c --- /dev/null +++ b/libmisc/tests/test.h @@ -0,0 +1,21 @@ +/* libmisc/tests/test.h - Common test utilities + * + * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +#ifndef _LIBMISC_TESTS_TEST_H_ +#define _LIBMISC_TESTS_TEST_H_ + +#include <stdio.h> +#include <stdlib.h> /* for exit() */ + +#define test_assert(expr) do { \ + if (!(expr)) { \ + printf("test failure: %s:%d:%s: %s\n", \ + __FILE__, __LINE__, __func__, #expr); \ + exit(1); \ + } \ + } while (0) + +#endif /* _LIBMISC_TESTS_TEST_H_ */ |