MeshLib C++ Docs
Loading...
Searching...
No Matches
TestMacros.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <tgmath.h>
6
7#define TEST_ASSERT( ... ) \
8 if ( !( __VA_ARGS__ ) ) \
9 { \
10 fprintf( stderr, "%s:%d: check failed: %s\n", __func__, __LINE__, ( #__VA_ARGS__ ) ); \
11 abort(); \
12 }
13
14#define TEST_ASSERT_INT_EQUAL( val, exp ) \
15 if ( !( val == exp ) ) \
16 { \
17 fprintf( stderr, "%s:%d: check failed: expected %d, got %d\n", __func__, __LINE__, exp, val ); \
18 abort(); \
19 }
20
21#define TEST_ASSERT_FLOAT_EQUAL_APPROX( val, exp, eps ) \
22 if ( !( fabs( val - exp ) <= eps ) ) \
23 { \
24 fprintf( stderr, "%s:%d: check failed: expected %f (delta %f), got %f (delta %f)\n", __func__, __LINE__, exp, eps, val, fabs( val - exp ) ); \
25 abort(); \
26 }