initial commit
This commit is contained in:
parent
81af403965
commit
573e1a9fa3
220 changed files with 150440 additions and 0 deletions
66
test/test_macros.h
Normal file
66
test/test_macros.h
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
// SPDX-FileCopyrightText: 2024 Erin Catto
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define RUN_TEST( T ) \
|
||||
do \
|
||||
{ \
|
||||
int result = T(); \
|
||||
if ( result == 1 ) \
|
||||
{ \
|
||||
printf( "test failed: " #T "\n" ); \
|
||||
return 1; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
printf( "test passed: " #T "\n" ); \
|
||||
} \
|
||||
} \
|
||||
while ( false )
|
||||
|
||||
#define RUN_SUBTEST( T ) \
|
||||
do \
|
||||
{ \
|
||||
int result = T(); \
|
||||
if ( result == 1 ) \
|
||||
{ \
|
||||
printf( " subtest failed: " #T "\n" ); \
|
||||
return 1; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
printf( " subtest passed: " #T "\n" ); \
|
||||
} \
|
||||
} \
|
||||
while ( false )
|
||||
|
||||
#define ENSURE( C ) \
|
||||
do \
|
||||
{ \
|
||||
if ( ( C ) == false ) \
|
||||
{ \
|
||||
printf( "condition false: " #C "\n" ); \
|
||||
return 1; \
|
||||
} \
|
||||
} \
|
||||
while ( false )
|
||||
|
||||
#define ENSURE_SMALL( C, tol ) \
|
||||
do \
|
||||
{ \
|
||||
if ( ( C ) < -( tol ) || ( tol ) < ( C ) ) \
|
||||
{ \
|
||||
printf( "condition false: abs(" #C ") < %g\n", tol ); \
|
||||
return 1; \
|
||||
} \
|
||||
} \
|
||||
while ( false )
|
||||
|
||||
#define ARRAY_COUNT( A ) (int)( sizeof( A ) / sizeof( A[0] ) )
|
||||
|
||||
/// Used to prevent the compiler from warning about unused variables
|
||||
#define MAYBE_UNUSED( x ) ( (void)( x ) )
|
||||
Loading…
Reference in a new issue