Helper function for implementing ASSERT_NEAR.
| 2337 | |
| 2338 | // Helper function for implementing ASSERT_NEAR. |
| 2339 | AssertionResult DoubleNearPredFormat(const char* expr1, |
| 2340 | const char* expr2, |
| 2341 | const char* abs_error_expr, |
| 2342 | double val1, |
| 2343 | double val2, |
| 2344 | double abs_error) { |
| 2345 | const double diff = fabs(val1 - val2); |
| 2346 | if (diff <= abs_error) return AssertionSuccess(); |
| 2347 | |
| 2348 | // TODO(wan): do not print the value of an expression if it's |
| 2349 | // already a literal. |
| 2350 | return AssertionFailure() |
| 2351 | << "The difference between " << expr1 << " and " << expr2 |
| 2352 | << " is " << diff << ", which exceeds " << abs_error_expr << ", where\n" |
| 2353 | << expr1 << " evaluates to " << val1 << ",\n" |
| 2354 | << expr2 << " evaluates to " << val2 << ", and\n" |
| 2355 | << abs_error_expr << " evaluates to " << abs_error << "."; |
| 2356 | } |
| 2357 | |
| 2358 | |
| 2359 | // Helper template for implementing FloatLE() and DoubleLE(). |
nothing calls this directly
no test coverage detected