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* ------------------------
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/*..........................................................................*/
5259void 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/*..........................................................................*/
6168void 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/*..........................................................................*/
7781int 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