-
Notifications
You must be signed in to change notification settings - Fork 125
/
testfw.h
581 lines (490 loc) · 22.3 KB
/
testfw.h
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
/*
------------------------------------------------------------------------------
Licensing information can be found at the end of the file.
------------------------------------------------------------------------------
testfw.h - v1.1 - Basic test framework for C/C++.
Do this:
#define TESTFW_IMPLEMENTATION
before you include this file in *one* C/C++ file to create the implementation.
*/
#ifndef testfw_h
#define testfw_h
#define TESTFW_INIT() testfw_init()
#define TESTFW_SUMMARY() testfw_summary( __FILE__, __func__, __LINE__ )
#if defined( _WIN32 ) && !defined( TESTFW_NO_SEH ) && !defined( __TINYC__ )
#if defined __cplusplus
extern "C" unsigned long __cdecl _exception_code(void);
#else
unsigned long __cdecl _exception_code(void);
#endif
#define TESTFW_TEST_BEGIN( desc ) testfw_test_begin( desc, __FILE__, __func__, __LINE__ ); __try {
#define TESTFW_TEST_END() } __except( 1 /*EXCEPTION_EXECUTE_HANDLER*/ ) \
{ testfw_exception( _exception_code/*GetExceptionCode*/() ); } \
testfw_test_end( __FILE__, __func__, __LINE__ )
#else
#define TESTFW_TEST_BEGIN( desc ) testfw_test_begin( desc, __FILE__, __func__, __LINE__ ); {
#define TESTFW_TEST_END() testfw_test_end( __FILE__, __func__, __LINE__ ); }
#endif
#define TESTFW_EXPECTED( expression ) testfw_expected( (expression) ? 1 : 0, #expression, __FILE__, __func__, __LINE__ )
void testfw_init( void );
int testfw_summary( char const* filename, char const* funcname, int line );
void testfw_test_begin( char const* desc, char const* filename, char const* funcname, int line );
void testfw_test_end( char const* filename, char const* funcname, int line );
void testfw_expected( int expression, char const* expression_str, char const* filename, char const* funcname, int line );
void testfw_print_test_desc( void );
void testfw_print_failure( char const* filename, int line );
void testfw_assertion_count_inc( void );
void testfw_current_test_assertion_failed( void );
#if defined( _WIN32 ) && !defined( TESTFW_NO_SEH ) && !defined( __TINYC__ )
void testfw_exception( unsigned int exception_code );
#endif
#endif /* testfw_h */
#ifdef TESTFW_IMPLEMENTATION
#undef TESTFW_IMPLEMENTATION
#define _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#include <string.h>
#if defined( _WIN32 ) && !defined( __TINYC__ )
#pragma warning( push )
#pragma warning( disable: 4619 ) // pragma warning : there is no warning number 'number'
#pragma warning( disable: 4668 ) // 'symbol' is not defined as a preprocessor macro, replacing with '0'
#include <crtdbg.h>
#pragma warning( pop )
#endif /* _WIN32 */
#ifndef TESTFW_PRINTF
#define _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define TESTFW_PRINTF( format, ... ) printf( format, ##__VA_ARGS__ )
#endif
#ifdef TESTFW_NO_ANSI
#define TESTFW_ANSI_BLACK ""
#define TESTFW_ANSI_BLUE ""
#define TESTFW_ANSI_GREEN ""
#define TESTFW_ANSI_CYAN ""
#define TESTFW_ANSI_RED ""
#define TESTFW_ANSI_MAGENTA ""
#define TESTFW_ANSI_BROWN ""
#define TESTFW_ANSI_LIGHT_GREY ""
#define TESTFW_ANSI_GREY ""
#define TESTFW_ANSI_LIGHT_BLUE ""
#define TESTFW_ANSI_LIGHT_GREEN ""
#define TESTFW_ANSI_LIGHT_CYAN ""
#define TESTFW_ANSI_LIGHT_RED ""
#define TESTFW_ANSI_LIGHT_MAGENTA ""
#define TESTFW_ANSI_YELLOW ""
#define TESTFW_ANSI_WHITE ""
#define TESTFW_ANSI_RESET ""
#else
#ifndef TESTFW_ANSI_BLACK
#define TESTFW_ANSI_BLACK "\x1b[30m"
#endif
#ifndef TESTFW_ANSI_BLUE
#define TESTFW_ANSI_BLUE "\x1b[34m"
#endif
#ifndef TESTFW_ANSI_GREEN
#define TESTFW_ANSI_GREEN "\x1b[32m"
#endif
#ifndef TESTFW_ANSI_CYAN
#define TESTFW_ANSI_CYAN "\x1b[36m"
#endif
#ifndef TESTFW_ANSI_RED
#define TESTFW_ANSI_RED "\x1b[31m"
#endif
#ifndef TESTFW_ANSI_MAGENTA
#define TESTFW_ANSI_MAGENTA "\x1b[35m"
#endif
#ifndef TESTFW_ANSI_BROWN
#define TESTFW_ANSI_BROWN "\x1b[33m"
#endif
#ifndef TESTFW_ANSI_LIGHT_GREY
#define TESTFW_ANSI_LIGHT_GREY "\x1b[37m"
#endif
#ifndef TESTFW_ANSI_GREY
#define TESTFW_ANSI_GREY "\x1b[30;1m"
#endif
#ifndef TESTFW_ANSI_LIGHT_BLUE
#define TESTFW_ANSI_LIGHT_BLUE "\x1b[34;1m"
#endif
#ifndef TESTFW_ANSI_LIGHT_GREEN
#define TESTFW_ANSI_LIGHT_GREEN "\x1b[32;1m"
#endif
#ifndef TESTFW_ANSI_LIGHT_CYAN
#define TESTFW_ANSI_LIGHT_CYAN "\x1b[36;1m"
#endif
#ifndef TESTFW_ANSI_LIGHT_RED
#define TESTFW_ANSI_LIGHT_RED "\x1b[31;1m"
#endif
#ifndef TESTFW_ANSI_LIGHT_MAGENTA
#define TESTFW_ANSI_LIGHT_MAGENTA "\x1b[35;1m"
#endif
#ifndef TESTFW_ANSI_YELLOW
#define TESTFW_ANSI_YELLOW "\x1b[33;1m"
#endif
#ifndef TESTFW_ANSI_WHITE
#define TESTFW_ANSI_WHITE "\x1b[37;1m"
#endif
#ifndef TESTFW_ANSI_RESET
#define TESTFW_ANSI_RESET "\x1b[0m"
#endif
#endif
struct testfw_internal_current_test_state_t
{
int is_active;
char const* file;
char const* func;
int line;
char const* desc;
int desc_printed;
int counted_as_failed;
};
static struct
{
int tests_total;
int tests_failed;
int assertions_total;
int assertions_failed;
struct testfw_internal_current_test_state_t current_test;
#if defined( _WIN32 ) && defined( _DEBUG ) && !defined( __TINYC__ )
int total_leaks;
#endif
} testfw_internal_state;
static void testfw_internal_print_progress_divider( char ch, int fail, int total )
{
int width = 79;
int first = (int)( ( width * fail ) / ( total ? total : 1 ) );
int second = width - first;
if( fail > 0 && first == 0 )
{
++first;
--second;
}
TESTFW_PRINTF( "%s", TESTFW_ANSI_LIGHT_RED );
for( int i = 0; i < first; ++i ) TESTFW_PRINTF( "%c", ch );
TESTFW_PRINTF( "%s", TESTFW_ANSI_LIGHT_GREEN );
for( int i = 0; i < second; ++i ) TESTFW_PRINTF( "%c", ch );
TESTFW_PRINTF( "%s", TESTFW_ANSI_RESET );
TESTFW_PRINTF( "\n" );
}
#if defined( _WIN32 ) && defined( _DEBUG ) && !defined( __TINYC__ )
static int testfw_internal_debug_report_hook( int report_type, char* message, int* return_value )
{
_flushall();
(void) report_type;
*return_value = 0; // Don't break to debugger
if( stricmp( message, "Detected memory leaks!\n" ) == 0 )
{
TESTFW_PRINTF( "-------------------------------------------------------------------------------\n" );
TESTFW_PRINTF( "%sMEMORY CHECKS FAILED:%s Detected memory leaks\n", TESTFW_ANSI_LIGHT_RED,
TESTFW_ANSI_RESET );
return 1; // Tell CRT not to print the message
}
else if( stricmp( message, "Dumping objects ->\n" ) == 0 )
{
TESTFW_PRINTF( "-------------------------------------------------------------------------------\n" );
TESTFW_PRINTF( "\n" );
return 1; // Tell CRT not to print the message
}
else if( stricmp( message, "Object dump complete.\n" ) == 0 )
{
TESTFW_PRINTF( "\n" );
_CrtMemState state;
_CrtMemCheckpoint( &state );
static char const* const block_use_names[ 5 ] = { "Free", "Normal", "CRT", "Ignore", "Client", };
for( unsigned int i = 0; i < 5; ++i )
{
if( i != 2 && state.lCounts[ i ] )
TESTFW_PRINTF( "%lld bytes in %lld %hs Blocks.\n", (long long) state.lSizes[ i ],
(long long) state.lCounts[ i ], block_use_names[ i ] );
}
TESTFW_PRINTF( "\n" );
TESTFW_PRINTF( "High water mark: %lld bytes.\n", (long long)state.lHighWaterCount);
TESTFW_PRINTF( "All allocations: %lld bytes.\n", (long long)state.lTotalCount);
TESTFW_PRINTF( "\n" );
TESTFW_PRINTF( "===============================================================================\n" );
TESTFW_PRINTF( "%sMEMORY LEAKS: %d%s\n\n", TESTFW_ANSI_LIGHT_RED, testfw_internal_state.total_leaks, TESTFW_ANSI_RESET );
return 1; // Tell CRT not to print the message
}
else if( strnicmp( message, " Data: <", 8 ) == 0 )
{
++testfw_internal_state.total_leaks;
return 1; // Tell CRT not to print the message
}
return 0; // Tell CRT it can print the message, as we didn't handle it
}
#endif /* _WIN32 && _DEBUG */
#if defined( _WIN32 )
#include <windows.h>
#endif
void testfw_init( void )
{
memset( &testfw_internal_state, 0, sizeof( testfw_internal_state ) );
#if defined( _WIN32 )
#if !defined( __TINYC__ )
int flag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); // Get current flag
flag ^= _CRTDBG_LEAK_CHECK_DF; // Turn on leak-checking bit
_CrtSetDbgFlag( flag ); // Set flag to the new value
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );
_CrtSetReportHook2( _CRT_RPTHOOK_INSTALL, testfw_internal_debug_report_hook );
_CrtSetReportHook( testfw_internal_debug_report_hook );
#endif /* __TINYC__ */
HANDLE handle = GetStdHandle( STD_OUTPUT_HANDLE );
if( handle != INVALID_HANDLE_VALUE ) {
DWORD mode = 0;
GetConsoleMode( handle, &mode );
SetConsoleMode( handle, mode | 0x0004 /*ENABLE_VIRTUAL_TERMINAL_PROCESSING*/ );
}
#endif /* _WIN32 */
}
static int testfw_internal_must_be_in_test( void )
{
if( !testfw_internal_state.current_test.is_active )
TESTFW_PRINTF( "\n\n%sEXPECTED TO BE IN AN ACTIVE TEST, BUT NO TEST IS CURRENTLY ACTIVE.%s\n\n",
TESTFW_ANSI_LIGHT_RED, TESTFW_ANSI_RESET );
return !testfw_internal_state.current_test.is_active;
}
static int testfw_internal_can_not_be_in_test( void )
{
if( testfw_internal_state.current_test.is_active )
TESTFW_PRINTF( "\n\n%sEXPECTED TO NOT BE IN AN ACTIVE TEST, BUT A TEST IS CURRENTLY ACTIVE.%s\n\n",
TESTFW_ANSI_LIGHT_RED, TESTFW_ANSI_RESET );
return testfw_internal_state.current_test.is_active;
}
void testfw_print_test_desc( void )
{
if( testfw_internal_must_be_in_test() ) return;
if( !testfw_internal_state.current_test.desc_printed )
{
testfw_internal_state.current_test.desc_printed = 1;
TESTFW_PRINTF( "\n" );
TESTFW_PRINTF( "-------------------------------------------------------------------------------\n" );
TESTFW_PRINTF( "%s\n", testfw_internal_state.current_test.desc ? testfw_internal_state.current_test.desc :
"<NO DESCRIPTION>" );
TESTFW_PRINTF( "-------------------------------------------------------------------------------\n" );
TESTFW_PRINTF( "%s%s(%d): %s%s\n", TESTFW_ANSI_LIGHT_GREY, testfw_internal_state.current_test.file,
testfw_internal_state.current_test.line, TESTFW_ANSI_RESET, testfw_internal_state.current_test.func );
TESTFW_PRINTF( "%s", TESTFW_ANSI_LIGHT_GREY );
TESTFW_PRINTF( "...............................................................................\n" );
TESTFW_PRINTF( "%s", TESTFW_ANSI_RESET );
}
}
int testfw_summary( char const* filename, char const* funcname, int line )
{
(void) filename; (void) funcname; (void) line;
if( testfw_internal_can_not_be_in_test() ) return -1;
TESTFW_PRINTF( "\n" );
testfw_internal_print_progress_divider( '=', testfw_internal_state.tests_failed, testfw_internal_state.tests_total );
if( testfw_internal_state.tests_failed == 0 && testfw_internal_state.assertions_failed == 0 )
{
TESTFW_PRINTF( "%sAll tests passed%s (%d assertions in %d test cases)\n", TESTFW_ANSI_LIGHT_GREEN,
TESTFW_ANSI_RESET, testfw_internal_state.assertions_total, testfw_internal_state.tests_total );
}
else
{
TESTFW_PRINTF( "test cases: %4d |%s %4d passed %s|%s %4d failed%s\n", testfw_internal_state.tests_total,
TESTFW_ANSI_LIGHT_GREEN, testfw_internal_state.tests_total - testfw_internal_state.tests_failed,
TESTFW_ANSI_RESET, TESTFW_ANSI_LIGHT_RED, testfw_internal_state.tests_failed, TESTFW_ANSI_RESET );
TESTFW_PRINTF( "assertions: %4d |%s %4d passed %s|%s %4d failed%s\n", testfw_internal_state.assertions_total,
TESTFW_ANSI_LIGHT_GREEN, testfw_internal_state.assertions_total - testfw_internal_state.assertions_failed,
TESTFW_ANSI_RESET, TESTFW_ANSI_LIGHT_RED, testfw_internal_state.assertions_failed, TESTFW_ANSI_RESET );
}
TESTFW_PRINTF( "\n\n" );
#if defined( _WIN32 ) && defined( _DEBUG ) && !defined( __TINYC__ )
int result = _CrtDumpMemoryLeaks();
testfw_internal_state.tests_failed += result ? 1 : 0;
#endif
return testfw_internal_state.tests_failed;
}
void testfw_test_begin( char const* desc, char const* filename, char const* funcname, int line )
{
if( testfw_internal_can_not_be_in_test() ) return;
memset( &testfw_internal_state.current_test, 0, sizeof( testfw_internal_state.current_test ) );
testfw_internal_state.current_test.is_active = 1;
testfw_internal_state.current_test.file = filename;
testfw_internal_state.current_test.func = funcname;
testfw_internal_state.current_test.line = line;
testfw_internal_state.current_test.desc = desc;
testfw_internal_state.current_test.desc_printed = 0;
testfw_internal_state.current_test.counted_as_failed = 0;
++testfw_internal_state.tests_total;
}
void testfw_test_end( char const* filename, char const* funcname, int line )
{
(void) filename; (void) funcname; (void) line;
if( testfw_internal_must_be_in_test() ) return;
memset( &testfw_internal_state.current_test, 0, sizeof( testfw_internal_state.current_test ) );
}
#if defined( _WIN32 ) && !defined( TESTFW_NO_SEH ) && !defined( __TINYC__ )
#pragma warning( push )
#pragma warning( disable: 4668 )
#include <windows.h>
#pragma warning( pop )
void testfw_exception( unsigned int exception_code )
{
if( testfw_internal_must_be_in_test() ) return;
if( !testfw_internal_state.current_test.counted_as_failed )
{
testfw_internal_state.current_test.counted_as_failed = 1;
++testfw_internal_state.tests_failed;
}
char exception_str[ 64 ];
switch( exception_code )
{
case EXCEPTION_ACCESS_VIOLATION:
strcpy( exception_str, "EXCEPTION_ACCESS_VIOLATION" );
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
strcpy( exception_str, "EXCEPTION_DATATYPE_MISALIGNMENT" );
break;
case EXCEPTION_BREAKPOINT:
strcpy( exception_str, "EXCEPTION_BREAKPOINT" );
break;
case EXCEPTION_SINGLE_STEP:
strcpy( exception_str, "EXCEPTION_SINGLE_STEP" );
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
strcpy( exception_str, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED" );
break;
case EXCEPTION_FLT_DENORMAL_OPERAND:
strcpy( exception_str, "EXCEPTION_FLT_DENORMAL_OPERAND" );
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
strcpy( exception_str, "EXCEPTION_FLT_DIVIDE_BY_ZERO" );
break;
case EXCEPTION_FLT_INEXACT_RESULT:
strcpy( exception_str, "EXCEPTION_FLT_INEXACT_RESULT" );
break;
case EXCEPTION_FLT_INVALID_OPERATION:
strcpy( exception_str, "EXCEPTION_FLT_INVALID_OPERATION" );
break;
case EXCEPTION_FLT_OVERFLOW:
strcpy( exception_str, "EXCEPTION_FLT_OVERFLOW" );
break;
case EXCEPTION_FLT_STACK_CHECK:
strcpy( exception_str, "EXCEPTION_FLT_STACK_CHECK" );
break;
case EXCEPTION_FLT_UNDERFLOW:
strcpy( exception_str, "EXCEPTION_FLT_UNDERFLOW" );
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
strcpy( exception_str, "EXCEPTION_INT_DIVIDE_BY_ZERO" );
break;
case EXCEPTION_INT_OVERFLOW:
strcpy( exception_str, "EXCEPTION_INT_OVERFLOW" );
break;
case EXCEPTION_PRIV_INSTRUCTION:
strcpy( exception_str, "EXCEPTION_PRIV_INSTRUCTION" );
break;
case EXCEPTION_IN_PAGE_ERROR:
strcpy( exception_str, "EXCEPTION_IN_PAGE_ERROR" );
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
strcpy( exception_str, "EXCEPTION_ILLEGAL_INSTRUCTION" );
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
strcpy( exception_str, "EXCEPTION_NONCONTINUABLE_EXCEPTION" );
break;
case EXCEPTION_STACK_OVERFLOW:
strcpy( exception_str, "EXCEPTION_STACK_OVERFLOW" );
break;
case EXCEPTION_INVALID_DISPOSITION:
strcpy( exception_str, "EXCEPTION_INVALID_DISPOSITION" );
break;
case EXCEPTION_GUARD_PAGE:
strcpy( exception_str, "EXCEPTION_GUARD_PAGE" );
break;
case EXCEPTION_INVALID_HANDLE:
strcpy( exception_str, "EXCEPTION_INVALID_HANDLE" );
break;
default:
sprintf( exception_str, "%X", exception_code );
}
testfw_print_test_desc();
TESTFW_PRINTF( "\n%s%s(%d): %sFAILED:%s\n", TESTFW_ANSI_LIGHT_GREY, testfw_internal_state.current_test.file,
testfw_internal_state.current_test.line, TESTFW_ANSI_LIGHT_RED, TESTFW_ANSI_RESET );
TESTFW_PRINTF( "\n %sEXCEPTION( %s%s%s )%s\n", TESTFW_ANSI_CYAN, TESTFW_ANSI_WHITE, exception_str,
TESTFW_ANSI_LIGHT_GREY, TESTFW_ANSI_RESET );
}
#endif
void testfw_current_test_assertion_failed( void )
{
if( testfw_internal_must_be_in_test() ) return;
++testfw_internal_state.assertions_failed;
if( !testfw_internal_state.current_test.counted_as_failed )
{
testfw_internal_state.current_test.counted_as_failed = 1;
++testfw_internal_state.tests_failed;
}
}
void testfw_assertion_count_inc( void )
{
if( testfw_internal_must_be_in_test() ) return;
++testfw_internal_state.assertions_total;
}
void testfw_print_failure( char const* filename, int line )
{
TESTFW_PRINTF( "\n%s%s(%d): %sFAILED:%s\n", TESTFW_ANSI_LIGHT_GREY, filename, line, TESTFW_ANSI_LIGHT_RED,
TESTFW_ANSI_RESET );
}
void testfw_expected( int expression, char const* expression_str, char const* filename,
char const* funcname, int line )
{
(void) funcname;
if( testfw_internal_must_be_in_test() ) return;
testfw_assertion_count_inc();
if( !expression )
{
testfw_current_test_assertion_failed();
testfw_print_test_desc();
testfw_print_failure( filename, line );
TESTFW_PRINTF( "\n %sTESTFW_EXPECTED( %s%s%s )%s\n", TESTFW_ANSI_LIGHT_MAGENTA, TESTFW_ANSI_WHITE, expression_str,
TESTFW_ANSI_LIGHT_MAGENTA, TESTFW_ANSI_RESET );
}
}
#endif /* TESTFW_IMPLEMENTATION */
/*
------------------------------------------------------------------------------
This software is available under 2 licenses - you may choose the one you like.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2019 Mattias Gustavsson
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------------------
*/