libpulsar
A modular compiler for the pulsar programming language
Loading...
Searching...
No Matches
unit_testing.h
Go to the documentation of this file.
1
8#pragma once
9
10#include "def.h"
11
12void _PS_BEGIN_UNIT_TESTS(STR file);
13
19void PS_END_UNIT_TESTS(void);
20
21void _PS_UNIT_ASSERT(int result, STR expr, STR func, u64 line, STR msg, ...);
22
23void _PS_UNIT_SUPPRESS(STR msg, STR func, u64 line);
24
29void PS_UNIT_UNSUPPRESS(void);
30
34#define PS_BEGIN_UNIT_TESTS() _PS_BEGIN_UNIT_TESTS(__FILE__)
35
41#define PS_UNIT_ASSERT(result, ...) \
42 _PS_UNIT_ASSERT(result, #result, __func__, __LINE__, "" __VA_ARGS__)
43
51#define PS_UNIT_ASSERT_EQ(exp, act, fmt, msg, ...) \
52 do { \
53 auto_t exp_ = exp; \
54 auto_t act_ = act; \
55 _PS_UNIT_ASSERT(((exp_) == (act_)), #exp " == " #act, __func__, \
56 __LINE__, "Expected: " fmt "\n\tActual: " fmt "\n\t%s", exp_, \
57 act_, msg, ##__VA_ARGS__); \
58 } while (0)
59
66#define PS_UNIT_SUPPRESS(msg) _PS_UNIT_SUPPRESS(msg, __func__, __LINE__)
Base definitions.
#define STR
Definition def.h:40
#define u64
Definition def.h:48
void _PS_BEGIN_UNIT_TESTS(STR file)
void _PS_UNIT_ASSERT(int result, STR expr, STR func, u64 line, STR msg,...)
void PS_END_UNIT_TESTS(void)
End unit tests.
void _PS_UNIT_SUPPRESS(STR msg, STR func, u64 line)
void PS_UNIT_UNSUPPRESS(void)
Unsuppress unit test output.