Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
FCTX Changes
++++++++++++

Whats new in FCTX 1.6.2
-----------------------

- ENH: fct_chk_eq_dbl and fct_chk_neq_dbl show more digits on failure.
- ENH: fct_chk_eqtol_dbl and fct_chk_neqtol_dbl permit using an
absolute tolerance different than DBL_EPILSON.

Whats new in FCTX 1.6.1
-----------------------

Expand Down
12 changes: 12 additions & 0 deletions doc/usr/source/api_fct.rst
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ These are used to verify that a condition is true. They are executed within
equality is done based on an absolute floating point difference less than
the *DBL_EPISLON* defined in the standard <float.h> file.

.. c:function:: fct_chk_eqtol_dbl(a, b, tol)

*New in FCTX 1.6.2*. Causes a test failure if *a* != *b*. Testing for
equality is done based on an absolute floating point difference less than
*tol*.

.. c:function:: fct_chk_eq_int(a, b)

*New in FCTX 1.1*. Causes a test failure if *a* != *b*. Testing for
Expand Down Expand Up @@ -416,6 +422,12 @@ These are used to verify that a condition is true. They are executed within
inequality is done based on an absolute floating point difference that is
NOT less than the *DBL_EPISLON* defined in the standard <float.h> file.

.. c:function:: fct_chk_neqtol_dbl(a, b, tol)

*New in FCTX 1.6.2*. Causes a test failure if *a* == *b*. Testing for
inequality is done based on an absolute floating point difference that is
NOT less than the *tol*.

.. c:function:: fct_chk_neq_int(a, b)

*New in FCTX 1.1*. Causes a test failure if *a* == *b*. Testing for
Expand Down
32 changes: 30 additions & 2 deletions include/fct.h
Original file line number Diff line number Diff line change
Expand Up @@ -3669,21 +3669,49 @@ with. If we fail a setup up, then we go directly to a teardown mode. */
#define fct_chk_eq_dbl(V1, V2) \
fct_xchk(\
((int)(fabs((V1)-(V2)) < DBL_EPSILON)),\
"chk_eq_dbl: %f != %f",\
"chk_eq_dbl: %.*g != %.*g",\
(DBL_DIG + 2),\
(V1),\
(DBL_DIG + 2),\
(V2)\
)


#define fct_chk_neq_dbl(V1, V2) \
fct_xchk(\
((int)(fabs((V1)-(V2)) >= DBL_EPSILON)),\
"chk_neq_dbl: %f == %f",\
"chk_neq_dbl: %.*g == %.*g",\
(DBL_DIG + 2),\
(V1),\
(DBL_DIG + 2),\
(V2)\
)


#define fct_chk_eqtol_dbl(V1, V2, TOL) \
fct_xchk(\
((int)(fabs((V1)-(V2)) < (TOL))),\
"chk_eq_dbl: %.*g != %.*g to tol %g",\
(DBL_DIG + 2),\
(V1),\
(DBL_DIG + 2),\
(V2),\
(TOL)\
)


#define fct_chk_neqtol_dbl(V1, V2, TOL) \
fct_xchk(\
((int)(fabs((V1)-(V2)) >= (TOL))),\
"chk_neq_dbl: %.*g == %.*g to tol %g",\
(DBL_DIG + 2),\
(V1),\
(DBL_DIG + 2),\
(V2),\
(TOL)\
)


#define fct_chk_eq_str(V1, V2) \
fct_xchk(fctstr_eq((V1), (V2)),\
"chk_eq_str: '%s' != '%s'",\
Expand Down
12 changes: 12 additions & 0 deletions tests/test_chk_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ FCT_BGN()
}
FCT_QTEST_END();

FCT_QTEST_BGN(chk_dbl_eqtol)
{
fct_chk_eqtol_dbl(6123.2313,6123.2313,DBL_EPSILON);
}
FCT_QTEST_END();

FCT_QTEST_BGN(chk_dbl_neqtol)
{
fct_chk_neqtol_dbl(1.11111, 1.1,DBL_EPSILON);
}
FCT_QTEST_END();

FCT_QTEST_BGN(chk_str_eq)
{
fct_chk_eq_str("a", "a");
Expand Down