-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_boolean.c
More file actions
34 lines (28 loc) · 773 Bytes
/
Copy pathtest_boolean.c
File metadata and controls
34 lines (28 loc) · 773 Bytes
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
#include "boolean.h"
#include "print.h" /* For DEBUG_INFO */
/* Simple test macro with debug info */
#define TEST(cond) \
do { \
if (!(cond)) { \
DEBUG_INFO("Boolean test failed: " #cond); \
passed = FALSE; \
} \
} while (0)
int main(void)
{
BOOL passed = TRUE;
/* --- AND logic --- */
TEST((TRUE && TRUE) == TRUE);
TEST((TRUE && FALSE) == FALSE);
TEST((FALSE && TRUE) == FALSE);
TEST((FALSE && FALSE) == FALSE);
/* --- OR logic --- */
TEST((TRUE || TRUE) == TRUE);
TEST((TRUE || FALSE) == TRUE);
TEST((FALSE || TRUE) == TRUE);
TEST((FALSE || FALSE) == FALSE);
/* --- NOT logic --- */
TEST((!TRUE) == FALSE);
TEST((!FALSE) == TRUE);
return passed ? 0 : 1;
}