1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
// Copyright © Tavian Barnes <tavianator@tavianator.com>
// SPDX-License-Identifier: 0BSD
/**
* Unit tests.
*/
#ifndef BFS_TESTS_H
#define BFS_TESTS_H
#include "bfs.h"
#include "bfstd.h"
#include "diag.h"
/** Memory allocation tests. */
void check_alloc(void);
/** Standard library wrapper tests. */
void check_bfstd(void);
/** Bit manipulation tests. */
void check_bit(void);
/** I/O queue tests. */
void check_ioq(void);
/** Linked list tests. */
void check_list(void);
/** Signal hook tests. */
void check_sighook(void);
/** Trie tests. */
void check_trie(void);
/** Process spawning tests. */
void check_xspawn(void);
/** Time tests. */
void check_xtime(void);
/** Record a single check and return the result. */
bool bfs_check_impl(bool result);
/**
* Check a condition, logging a message on failure but continuing.
*/
#define bfs_check(cond, ...) \
bfs_check_impl((cond) || (bfs_check_(#cond, __VA_ARGS__), false))
#define bfs_check_(str, ...) \
BFS_VA_IF(__VA_ARGS__) \
(bfs_diag(__VA_ARGS__)) \
(bfs_diag("Check failed: `%s`", str))
/**
* Check a condition, logging the current error string on failure.
*/
#define bfs_echeck(cond, ...) \
bfs_check_impl((cond) || (bfs_echeck_(#cond, __VA_ARGS__), false))
#define bfs_echeck_(str, ...) \
BFS_VA_IF(__VA_ARGS__) \
(bfs_ediag(__VA_ARGS__)) \
(bfs_ediag("Check failed: `%s`", str))
#endif // BFS_TESTS_H
|