mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-10 23:20:58 +00:00
Remove abs calls and pick correct floating point epsilon values (fixes #641)
This commit is contained in:
parent
4ff837f099
commit
956a272d62
@ -98,6 +98,11 @@ CODING RULES
|
||||
* Avoid atoi. Use QUtil::string_to_int instead. It does
|
||||
overflow/underflow checking.
|
||||
|
||||
* Avoid certain functions that tend to be macros or create compilation
|
||||
errors on some platforms. Known cases: strcasecmp, abs. Avoid min
|
||||
and max. If needed, std::min and std::max are okay to use in C++
|
||||
code with <algorithm> included.
|
||||
|
||||
* Remember to avoid using `operator[]` with `std::string` or
|
||||
`std::vector`. Instead, use `at()`. See README-hardening.md for
|
||||
details.
|
||||
|
@ -714,7 +714,7 @@ static void test25(char const* infile,
|
||||
double d = 0.0;
|
||||
assert(qpdf_oh_get_value_as_number(qpdf, p_bool, &d) == QPDF_FALSE);
|
||||
assert((qpdf_oh_get_value_as_number(qpdf, p_int, &d) == QPDF_TRUE) &&
|
||||
(((d - 1.0) * (d - 1.0)) < 1e-100));
|
||||
((d - 1.0) < 1e-6) && ((d - 1.0) > -1e-6));
|
||||
assert(qpdf_oh_get_type_code(qpdf, p_int) == ot_integer);
|
||||
assert(strcmp(qpdf_oh_get_type_name(qpdf, p_int), "integer") == 0);
|
||||
assert(qpdf_oh_is_real(qpdf, p_real) &&
|
||||
|
@ -3293,11 +3293,11 @@ static void test_85(QPDF& pdf, char const* arg2)
|
||||
assert(s == "42.0");
|
||||
double num = 0.0;
|
||||
assert(oh_i.getValueAsNumber(num));
|
||||
assert(abs(num - 1.0) < 1e-100);
|
||||
assert(((num - 1.0) < 1e-6) && (num - 1.0 > -1e-6));
|
||||
assert(oh_r.getValueAsNumber(num));
|
||||
assert(abs(num - 42.0) < 1e-100);
|
||||
assert(((num - 42.0) < 1e-6) && (num - 42.0 > -1e-6));
|
||||
assert(! oh_b.getValueAsNumber(num));
|
||||
assert(abs(num - 42.0) < 1e-100);
|
||||
assert(((num - 42.0) < 1e-6) && (num - 42.0 > -1e-6));
|
||||
s = "";
|
||||
assert(oh_n.getValueAsName(s));
|
||||
assert(s == "/Test") ;
|
||||
|
Loading…
Reference in New Issue
Block a user