Skip to content

Commit 88fb721

Browse files
committed
2.0.2
Replaced printf_s() with printf() in sutest.c for compatibility on Linux. Replaced check for NDEBUG with a check for Windows, in which case DebugBreak() is called.
1 parent d6bdcaf commit 88fb721

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

test/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ LIB_DIRS :=
3232
LIBS :=
3333

3434
# defines...
35-
DEFINES := -DNDEBUG
35+
DEFINES :=
3636

3737
#============================================================================
3838
# Typically you should not need to change anything below this line

test/sutest.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @brief Simple Unit Testing ("SUTEST") framework
44
*/
55
/*****************************************************************************
6-
* Last updated on 2021-02-12
6+
* Last updated on 2022-06-08
77
*
88
* Q u a n t u m L e a P s
99
* ------------------------
@@ -37,12 +37,19 @@
3737
*/
3838
#include "sutest.h"
3939

40-
#include <stdio.h> /* for printf_s() */
40+
#include <stdio.h> /* for printf() */
4141
#include <stdlib.h> /* for exit() */
4242

43-
#ifndef NDEBUG
43+
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
44+
4445
#define WIN32_LEAN_AND_MEAN
4546
#include <windows.h> /* for DebugBreak() */
47+
#define DBG_BREAK() DebugBreak()
48+
49+
#else
50+
51+
#define DBG_BREAK() ((void)0)
52+
4653
#endif
4754

4855
/*..........................................................................*/
@@ -51,38 +58,35 @@ static int l_test_count;
5158
/*..........................................................................*/
5259
void TEST(char const *title) {
5360
if (l_test_count > 0) {
54-
printf_s(" PASSED\n");
61+
printf(" PASSED\n");
5562
}
56-
printf_s("test: \"%s\" ...", title);
63+
printf("test: \"%s\" ...", title);
5764
++l_test_count;
5865
}
5966

6067
/*..........................................................................*/
6168
void TEST_fail_(char const *cond, char const *file, int line) {
62-
printf_s(" FAILED in %s:%d\n"
69+
printf(" FAILED in %s:%d\n"
6370
"%s\n"
6471
"---------------------------------------------\n"
6572
"%d test(s)\n"
6673
"FAILED\n",
6774
file, line, cond, l_test_count);
6875

69-
#ifndef NDEBUG
70-
DebugBreak();
71-
#endif
72-
76+
DBG_BREAK();
7377
exit(l_test_count);
7478
}
7579

7680
/*..........................................................................*/
7781
int main(void) {
78-
printf_s("\n%s\n", "Simple Unit Internal Testing -- SUTEST");
82+
printf("\n%s\n", "Simple Unit Internal Testing -- SUTEST");
7983

8084
TEST_onRun();
8185

8286
if (l_test_count > 0) {
83-
printf_s("%s\n", " PASSED");
87+
printf("%s\n", " PASSED");
8488
}
85-
printf_s("---------------------------------------------\n"
89+
printf("---------------------------------------------\n"
8690
"%d test(s)\nOK\n", l_test_count);
8791

8892
return 0; /* success */

0 commit comments

Comments
 (0)