ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
Driver tets

Typedefs

typedef void(* rd_test_print_fp) (const char *const msg)
 function pointer to print test information More...
 

Functions

bool rd_expect_close (const float expect, const int8_t precision, const float check)
 Check if given value is "near enough" to what user expects. More...
 

Detailed Description

Functions to test drivers.

Typedef Documentation

◆ rd_test_print_fp

typedef void(* rd_test_print_fp) (const char *const msg)

function pointer to print test information

Definition at line 23 of file ruuvi_driver_test.h.

Function Documentation

◆ rd_expect_close()

bool rd_expect_close ( const float  expect,
const int8_t  precision,
const float  check 
)

Check if given value is "near enough" to what user expects.

Check if two floats are close to another, down to precision. Example

float expect = 0.12f;
float check = 0.127f;
int8_t precision = 2;
ruuvi_library_expect_close(expect, precision, check); // true
expect = 120f;
check = 127f;
precision = -1;
ruuvi_library_expect_close(expect, precision, check); // true
Parameters
[in]expectExpected value.
[in]precisionNumber of decimals which must match. Negative values are allowed.
[in]checkValue to check.