MeshLib C++ Docs
Loading...
Searching...
No Matches
TestMacros.h File Reference
#include "TestFunctions.h"
#include <stdio.h>
#include <stdlib.h>
#include <tgmath.h>

Go to the source code of this file.

Macros

#define RUN_TEST(func)
 
#define TEST_ASSERT(...)
 
#define TEST_ASSERT_INT_EQUAL(val, exp)
 
#define TEST_ASSERT_FLOAT_EQUAL_APPROX(val, exp, eps)
 

Macro Definition Documentation

◆ RUN_TEST

#define RUN_TEST ( func)
Value:
printf( "%s ...\n", #func ); \
{ \
struct timespec ts1 = timespec_now(); \
func(); \
struct timespec ts2 = timespec_now(); \
struct timespec duration = timespec_get_duration( &ts1, &ts2 ); \
printf( "%s done (%.3f s)\n", #func, timespec_to_seconds( &duration ) ); \
}
double timespec_to_seconds(const struct timespec *ts)
struct timespec timespec_get_duration(const struct timespec *before, const struct timespec *after)
struct timespec timespec_now(void)

◆ TEST_ASSERT

#define TEST_ASSERT ( ...)
Value:
if ( !( __VA_ARGS__ ) ) \
{ \
fprintf( stderr, "%s:%d: check failed: %s\n", __func__, __LINE__, ( #__VA_ARGS__ ) ); \
abort(); \
}

◆ TEST_ASSERT_FLOAT_EQUAL_APPROX

#define TEST_ASSERT_FLOAT_EQUAL_APPROX ( val,
exp,
eps )
Value:
if ( !( fabs( val - exp ) <= eps ) ) \
{ \
fprintf( stderr, "%s:%d: check failed: expected %f (delta %f), got %f (delta %f)\n", __func__, __LINE__, exp, eps, val, fabs( val - exp ) ); \
abort(); \
}

◆ TEST_ASSERT_INT_EQUAL

#define TEST_ASSERT_INT_EQUAL ( val,
exp )
Value:
if ( !( val == exp ) ) \
{ \
fprintf( stderr, "%s:%d: check failed: expected %d, got %d\n", __func__, __LINE__, exp, val ); \
abort(); \
}