Skip to content

Commit 32dd10e

Browse files
test: enhance internal assertion utilities for parser tests
1 parent 44bb7b9 commit 32dd10e

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/__internal/__assert.hxx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <cstring>
77
#include <string>
88
#include <random>
9+
#include <format>
910

1011
using std::cerr;
1112
using std::cout;
@@ -46,6 +47,9 @@ using std::uniform_int_distribution;
4647
cerr << "File: " << __FILE__ << "\n"; \
4748
cerr << "Line: " << __LINE__ << "\n"; \
4849
abort(); \
50+
} else { \
51+
const auto fmt = std::format("[OK] [{}:{}]", BASE_NAME(__FILE__), __LINE__); \
52+
std::cout << fmt << std::format(" {} is {}\n", #condition, condition); \
4953
} \
5054
} while(0)
5155

@@ -108,4 +112,13 @@ string rand_source_digits(
108112
return results;
109113
}
110114

115+
#define TEST(func_name) void func_name() { \
116+
std::cout << std::format("[TEST] {}", #func_name) << "\n";
117+
118+
#define DONE }
119+
#define RUN(func) func();
120+
121+
#define TEST_MAIN int main() {
122+
#define END_MAIN return 0; }
123+
111124
#endif // __ASSERT_HXX

0 commit comments

Comments
 (0)