NeKernel dev
Loading...
Searching...
No Matches
TestCase.h
Go to the documentation of this file.
1/* ========================================
2
3 Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
4
5======================================== */
6
7#pragma once
8
10
15
16#define KT_RUN_TEST(OBJECT) \
17 { \
18 KTTestCase##OBJECT{}.Run(); \
19 }
20
21#define KT_MUST_PASS(MSG, LEFT_COND, RIGHT_COND) \
22 if (LEFT_COND != RIGHT_COND) { \
23 MUST_PASS(NO); \
24 }
25
26#define KT_DECL_TEST(NAME, FN) \
27 class KTTestCase##NAME final { \
28 public: \
29 KTTestCase##NAME() = default; \
30 ~KTTestCase##NAME() = default; \
31 LIBSYS_COPY_DELETE(KTTestCase##NAME); \
32 Void Run(); \
33 const Char* ToString(); \
34 }; \
35 inline Void KTTestCase##NAME::Run() { \
36 auto ret = FN() == YES; \
37 if (!ret) { \
38 PrintOut(nullptr, "[KERNEL-TEST] TEST FAILED!"); \
39 MUST_PASS(ret); \
40 } \
41 } \
42 inline const Char* KTTestCase##NAME::ToString() { \
43 return #FN; \
44 }
45
46KT_DECL_TEST(AlwaysBreak, []() -> bool {
47 KT_MUST_PASS("AlwaysBreak", YES, NO);
48 return NO;
49});
50
51KT_DECL_TEST(AlwaysPass, []() -> bool {
52 KT_MUST_PASS("AlwaysPass", YES, YES);
53 return YES;
54});
#define YES
#define NO
#define KT_DECL_TEST(NAME, FN)
Definition TestCase.h:26
#define KT_MUST_PASS(MSG, LEFT_COND, RIGHT_COND)
Definition TestCase.h:21