diff options
| author | Tyge Løvset <[email protected]> | 2022-08-19 09:28:48 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-08-19 09:28:48 +0200 |
| commit | 2876492564300f7d55ad1879a37c61f4c57bd122 (patch) | |
| tree | bcb37909563d646410f546d499eb3ebe49efe5f8 | |
| parent | bb85e62626580caa7e4e097b464f96fa78bb440e (diff) | |
| download | STC-modified-2876492564300f7d55ad1879a37c61f4c57bd122.tar.gz STC-modified-2876492564300f7d55ad1879a37c61f4c57bd122.zip | |
Minor update.
| -rw-r--r-- | include/stc/stctest.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/include/stc/stctest.h b/include/stc/stctest.h index 62504bef..0b5ae4e2 100644 --- a/include/stc/stctest.h +++ b/include/stc/stctest.h @@ -132,9 +132,9 @@ static int _stctest_strcmp(int res, const char* OP, ...) { const char* b = va_arg(ap, const char *);
va_end(ap);
int c = strcmp(a, b);
- if (OP[0] == '<') return OP[1] == '=' ? c <= 0 : c < 0;
- else if (OP[0] == '>') return OP[1] == '=' ? c >= 0 : c > 0;
- return (OP[0] == '!') ^ (c == 0);
+ if (OP[0] == '<') return OP[1] == '=' ? c <= 0 : c < 0;
+ if (OP[0] == '>') return OP[1] == '=' ? c >= 0 : c > 0;
+ return (OP[0] == '!') ^ (c == 0);
}
// Knuth:
@@ -152,10 +152,10 @@ static int _stctest_dblcmp(int res, const char* OP, ...) { double e = va_arg(ap, double);
double c = a - b;
va_end(ap);
- if (OP[0] == '<') return OP[1] == '=' ? c <= 0 : c < 0;
- else if (OP[0] == '>') return OP[1] == '=' ? c >= 0 : c > 0;
- return (OP[0] == '!') ^ (e == 0 ? approximately_equal(a, b, STCTEST_EPSILON)
- : (c < 0 ? -c : c) < e);
+ if (OP[0] == '<') return OP[1] == '=' ? c <= 0 : c < 0;
+ if (OP[0] == '>') return OP[1] == '=' ? c >= 0 : c > 0;
+ return (OP[0] == '!') ^ (e > 0 ? (c < 0 ? -c : c) < e
+ : approximately_equal(a, b, STCTEST_EPSILON));
}
static int _stctest_valcmp(int res, const char* OP, ...)
|
