Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Functions | Variables
test_math_float.cpp File Reference
#include <cassert>
#include <cinttypes>
#include <cstring>
#include <cmath>
#include <jau/test/catch2_ext.hpp>
#include <jau/float_math.hpp>
#include <jau/basic_types.hpp>
Include dependency graph for test_math_float.cpp:

Go to the source code of this file.

Functions

static void test05CompareWithEpsilon (int i, const float epsilon)
 
 TEST_CASE ("Float Compare Fixed Epsilon Test 20", "[math][datatype][float][epsilon]")
 
 TEST_CASE ("Float Compare Mac Epsilon Test 21", "[math][datatype][float][epsilon]")
 
 TEST_CASE ("Float Compare Zero Epsilon Test 10", "[math][datatype][float][epsilon]")
 
 TEST_CASE ("Float Epsilon Test 01", "[math][datatype][float][epsilon]")
 
 TEST_CASE ("Float Equals Fixed Epsilon Test 20", "[math][datatype][float][epsilon]")
 
 TEST_CASE ("Float Equals Mach Epsilon Test 21", "[math][datatype][float][epsilon]")
 
 TEST_CASE ("Float Equals No Epsilon Test 22", "[math][datatype][float][epsilon]")
 
 TEST_CASE ("Float IEEE 754 (IEC 559) Test 00", "[math][datatype][float][iec559]")
 
 TEST_CASE ("Float Zero Fixed Epsilon Test 10", "[math][datatype][float][epsilon]")
 
 TEST_CASE ("Float Zero Mach Epsilon Test 11", "[math][datatype][float][epsilon]")
 
 TEST_CASE ("Float Zero No Epsilon Test 12", "[math][datatype][float][epsilon]")
 
static void testCompareNoEpsilon (const int tstNum, const int exp, const float a, const float b)
 
static void testCompareWithEpsilon (const int tstNum, const int exp, const float a, const float b, const float epsilon)
 
static void testEqualsNoEpsilon (const int tstNum, const bool exp, const float a, const float b)
 
static void testEqualsWithEpsilon (const int tstNum, const bool exp, const float a, const float b, const float epsilon=std::numeric_limits< float >::epsilon())
 
static void testEqualsWithEpsilon (int i, const float epsilon=std::numeric_limits< float >::epsilon())
 
template<class T , std::enable_if_t<!std::numeric_limits< T >::is_integer, bool > = true>
void testFloatBits (const T a)
 
template<class T , std::enable_if_t<!std::numeric_limits< T >::is_integer, bool > = true>
void testFloatBits (const T a, const typename jau::uint_bytes< sizeof(T)>::type exp_a_bits)
 
void testIEC559DoubleType ()
 
void testIEC559FloatType ()
 
static void testZeroNoEpsilon (const int tstNum, const bool exp, const float a)
 
static void testZeroWithEpsilon1 (const int tstNum, const bool exp, const float a, const float epsilon=std::numeric_limits< float >::epsilon())
 
static void testZeroWithEpsilon1 (int i, const float epsilon=std::numeric_limits< float >::epsilon())
 

Variables

static const float MACH_EPSILON = jau::machineEpsilon<float>()
 
static const double MACH_EPSILON_DOUBLE = jau::machineEpsilon<double>()
 
static const float MAX_VALUE = std::numeric_limits<float>::max()
 
static const float MIN_VALUE = std::numeric_limits<float>::min()
 
static const float NaN = std::numeric_limits<float>::quiet_NaN()
 
static const double NaN_DBL = std::numeric_limits<double>::quiet_NaN()
 
static const float NEGATIVE_INFINITY = -std::numeric_limits<float>::infinity()
 
static const double NEGATIVE_INFINITY_DBL = -std::numeric_limits<double>::infinity()
 
static const float POSITIVE_INFINITY = std::numeric_limits<float>::infinity()
 
static const double POSITIVE_INFINITY_DBL = std::numeric_limits<double>::infinity()
 

Function Documentation

◆ testIEC559FloatType()

void testIEC559FloatType ( )

Definition at line 51 of file test_math_float.cpp.

Here is the caller graph for this function:

◆ testIEC559DoubleType()

void testIEC559DoubleType ( )

Definition at line 64 of file test_math_float.cpp.

Here is the caller graph for this function:

◆ testFloatBits() [1/2]

template<class T , std::enable_if_t<!std::numeric_limits< T >::is_integer, bool > = true>
void testFloatBits ( const T  a)

Definition at line 79 of file test_math_float.cpp.

Here is the caller graph for this function:

◆ testFloatBits() [2/2]

template<class T , std::enable_if_t<!std::numeric_limits< T >::is_integer, bool > = true>
void testFloatBits ( const T  a,
const typename jau::uint_bytes< sizeof(T)>::type  exp_a_bits 
)

Definition at line 86 of file test_math_float.cpp.

◆ TEST_CASE() [1/11]

TEST_CASE ( "Float IEEE 754 (IEC 559) Test 00"  ,
""  [math][datatype][float][iec559] 
)

Definition at line 93 of file test_math_float.cpp.

◆ TEST_CASE() [2/11]

TEST_CASE ( "Float Epsilon Test 01"  ,
""  [math][datatype][float][epsilon] 
)

Definition at line 126 of file test_math_float.cpp.

◆ testZeroWithEpsilon1() [1/2]

static void testZeroWithEpsilon1 ( const int  tstNum,
const bool  exp,
const float  a,
const float  epsilon = std::numeric_limits<float>::epsilon() 
)
static

Definition at line 152 of file test_math_float.cpp.

Here is the caller graph for this function:

◆ testZeroWithEpsilon1() [2/2]

static void testZeroWithEpsilon1 ( int  i,
const float  epsilon = std::numeric_limits<float>::epsilon() 
)
static

Definition at line 159 of file test_math_float.cpp.

◆ TEST_CASE() [3/11]

TEST_CASE ( "Float Zero Fixed Epsilon Test 10"  ,
""  [math][datatype][float][epsilon] 
)

Definition at line 171 of file test_math_float.cpp.

◆ TEST_CASE() [4/11]

TEST_CASE ( "Float Zero Mach Epsilon Test 11"  ,
""  [math][datatype][float][epsilon] 
)

Definition at line 174 of file test_math_float.cpp.

◆ testZeroNoEpsilon()

static void testZeroNoEpsilon ( const int  tstNum,
const bool  exp,
const float  a 
)
static

Definition at line 178 of file test_math_float.cpp.

Here is the caller graph for this function:

◆ TEST_CASE() [5/11]

TEST_CASE ( "Float Zero No Epsilon Test 12"  ,
""  [math][datatype][float][epsilon] 
)

Definition at line 185 of file test_math_float.cpp.

◆ testEqualsWithEpsilon() [1/2]

static void testEqualsWithEpsilon ( const int  tstNum,
const bool  exp,
const float  a,
const float  b,
const float  epsilon = std::numeric_limits<float>::epsilon() 
)
static

Definition at line 201 of file test_math_float.cpp.

Here is the caller graph for this function:

◆ testEqualsWithEpsilon() [2/2]

static void testEqualsWithEpsilon ( int  i,
const float  epsilon = std::numeric_limits<float>::epsilon() 
)
static

Definition at line 212 of file test_math_float.cpp.

◆ TEST_CASE() [6/11]

TEST_CASE ( "Float Equals Fixed Epsilon Test 20"  ,
""  [math][datatype][float][epsilon] 
)

Definition at line 230 of file test_math_float.cpp.

◆ TEST_CASE() [7/11]

TEST_CASE ( "Float Equals Mach Epsilon Test 21"  ,
""  [math][datatype][float][epsilon] 
)

Definition at line 234 of file test_math_float.cpp.

◆ testEqualsNoEpsilon()

static void testEqualsNoEpsilon ( const int  tstNum,
const bool  exp,
const float  a,
const float  b 
)
static

Definition at line 238 of file test_math_float.cpp.

Here is the caller graph for this function:

◆ TEST_CASE() [8/11]

TEST_CASE ( "Float Equals No Epsilon Test 22"  ,
""  [math][datatype][float][epsilon] 
)

Definition at line 249 of file test_math_float.cpp.

◆ testCompareNoEpsilon()

static void testCompareNoEpsilon ( const int  tstNum,
const int  exp,
const float  a,
const float  b 
)
static

Definition at line 267 of file test_math_float.cpp.

Here is the caller graph for this function:

◆ TEST_CASE() [9/11]

TEST_CASE ( "Float Compare Zero Epsilon Test 10"  ,
""  [math][datatype][float][epsilon] 
)

Definition at line 280 of file test_math_float.cpp.

◆ testCompareWithEpsilon()

static void testCompareWithEpsilon ( const int  tstNum,
const int  exp,
const float  a,
const float  b,
const float  epsilon 
)
static

Definition at line 311 of file test_math_float.cpp.

Here is the caller graph for this function:

◆ test05CompareWithEpsilon()

static void test05CompareWithEpsilon ( int  i,
const float  epsilon 
)
static

Definition at line 320 of file test_math_float.cpp.

Here is the caller graph for this function:

◆ TEST_CASE() [10/11]

TEST_CASE ( "Float Compare Fixed Epsilon Test 20"  ,
""  [math][datatype][float][epsilon] 
)

Definition at line 354 of file test_math_float.cpp.

◆ TEST_CASE() [11/11]

TEST_CASE ( "Float Compare Mac Epsilon Test 21"  ,
""  [math][datatype][float][epsilon] 
)

Definition at line 358 of file test_math_float.cpp.

Variable Documentation

◆ MACH_EPSILON

const float MACH_EPSILON = jau::machineEpsilon<float>()
static

Definition at line 36 of file test_math_float.cpp.

◆ MACH_EPSILON_DOUBLE

const double MACH_EPSILON_DOUBLE = jau::machineEpsilon<double>()
static

Definition at line 37 of file test_math_float.cpp.

◆ MIN_VALUE

const float MIN_VALUE = std::numeric_limits<float>::min()
static

Definition at line 39 of file test_math_float.cpp.

◆ MAX_VALUE

const float MAX_VALUE = std::numeric_limits<float>::max()
static

Definition at line 40 of file test_math_float.cpp.

◆ POSITIVE_INFINITY

const float POSITIVE_INFINITY = std::numeric_limits<float>::infinity()
static

Definition at line 41 of file test_math_float.cpp.

◆ NEGATIVE_INFINITY

const float NEGATIVE_INFINITY = -std::numeric_limits<float>::infinity()
static

Definition at line 42 of file test_math_float.cpp.

◆ NaN

const float NaN = std::numeric_limits<float>::quiet_NaN()
static

Definition at line 43 of file test_math_float.cpp.

◆ POSITIVE_INFINITY_DBL

const double POSITIVE_INFINITY_DBL = std::numeric_limits<double>::infinity()
static

Definition at line 47 of file test_math_float.cpp.

◆ NEGATIVE_INFINITY_DBL

const double NEGATIVE_INFINITY_DBL = -std::numeric_limits<double>::infinity()
static

Definition at line 48 of file test_math_float.cpp.

◆ NaN_DBL

const double NaN_DBL = std::numeric_limits<double>::quiet_NaN()
static

Definition at line 49 of file test_math_float.cpp.