tts v2.3.0
The Tiny Test System
 
Loading...
Searching...
No Matches

◆ TTS_ULP_EQUAL

#define TTS_ULP_EQUAL (   L,
  R,
  N,
  ... 
)    TTS_PRECISION(L,R,N,"ULP" , ::tts::ulp_distance , 2, __VA_ARGS__ )

Checks if two values are within a given ULP distance.

This comparison is performed by using the proper tts::ulp_distance overload.

Parameters
L,RExpressions to compare.
NMaximum ULPs accepted between L and R.
...Optional tag. If equals to REQUIRED, this test will stop the program if it fails.

Example

#define TTS_MAIN
#include <tts/tts.hpp>
TTS_CASE( "ULP distance")
{
float a{1};
float eps = std::numeric_limits<float>::epsilon();
float qnan = std::numeric_limits<float>::quiet_NaN();
float inf = std::numeric_limits<float>::infinity();
float minf = -inf;
TTS_ULP_EQUAL(a , a , 0. );
TTS_ULP_EQUAL(a , qnan , inf );
TTS_ULP_EQUAL(qnan , qnan , 0. );
TTS_ULP_EQUAL(a , inf , inf );
TTS_ULP_EQUAL(inf , inf , inf );
TTS_ULP_EQUAL(a, a-eps , 1 );
TTS_ULP_EQUAL(a, a+eps , 0.5 );
TTS_ULP_EQUAL(a, a+3*eps , 1.5, REQUIRED );
};
#define TTS_CASE(ID)
Introduces a new test scenario and registers it into the current test driver.
Definition: case.hpp:147
#define TTS_ULP_EQUAL(L, R, N,...)
Checks if two values are within a given ULP distance.
Definition: precision.hpp:144