mirror of
https://github.com/darlinghq/ctest.git
synced 2024-12-04 02:21:10 +00:00
Added static to added local functions, and moved it to where it is used.
This commit is contained in:
parent
6f2f65adf1
commit
0700b738c2
18
ctest.h
18
ctest.h
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user