Added static to added local functions, and moved it to where it is used.

This commit is contained in:
Tyge Løvset 2022-12-29 15:22:45 +01:00 committed by Bas van den Berg
parent 6f2f65adf1
commit 0700b738c2
2 changed files with 10 additions and 10 deletions

18
ctest.h
View File

@ -379,7 +379,7 @@ void assert_data(const unsigned char* exp, size_t expsize,
}
}
bool get_compare_result(const char* cmp, int c3, bool eq) {
static bool get_compare_result(const char* cmp, int c3, bool eq) {
if (cmp[0] == '<')
return c3 < 0 || ((cmp[1] == '=') & eq);
if (cmp[0] == '>')
@ -387,14 +387,6 @@ bool get_compare_result(const char* cmp, int c3, bool eq) {
return (cmp[0] == '=') == eq;
}
bool approximately_equal(double a, double b, double epsilon) {
double d = a - b;
if (d < 0) d = -d;
if (a < 0) a = -a;
if (b < 0) b = -b;
return d <= (a > b ? a : b)*epsilon; /* D.Knuth */
}
void assert_compare(const char* cmp, intmax_t exp, intmax_t real, const char* caller, int line) {
int c3 = (real < exp) - (exp < real);
@ -417,6 +409,14 @@ void assert_interval(intmax_t exp1, intmax_t exp2, intmax_t real, const char* ca
}
}
static bool approximately_equal(double a, double b, double epsilon) {
double d = a - b;
if (d < 0) d = -d;
if (a < 0) a = -a;
if (b < 0) b = -b;
return d <= (a > b ? a : b)*epsilon; /* D.Knuth */
}
/* tol < 0 means it is an epsilon, else absolute error */
void assert_dbl_compare(const char* cmp, double exp, double real, double tol, const char* caller, int line) {
double diff = exp - real;

2
main.c
View File

@ -18,7 +18,7 @@
#define CTEST_MAIN
// uncomment lines below to enable/disable features. See README.md for details
//#define CTEST_SEGFAULT
#define CTEST_SEGFAULT
//#define CTEST_NO_COLORS
//#define CTEST_COLOR_OK