Helper function for implementing ASSERT_NEAR.
| 2521 | |
| 2522 | // Helper function for implementing ASSERT_NEAR. |
| 2523 | AssertionResult DoubleNearPredFormat(const char* expr1, |
| 2524 | const char* expr2, |
| 2525 | const char* abs_error_expr, |
| 2526 | double val1, |
| 2527 | double val2, |
| 2528 | double abs_error) { |
| 2529 | const double diff = fabs(val1 - val2); |
| 2530 | if (diff <= abs_error) return AssertionSuccess(); |
| 2531 | |
| 2532 | // TODO(wan): do not print the value of an expression if it's |
| 2533 | // already a literal. |
| 2534 | return AssertionFailure() |
| 2535 | << "The difference between " << expr1 << " and " << expr2 |
| 2536 | << " is " << diff << ", which exceeds " << abs_error_expr << ", where\n" |
| 2537 | << expr1 << " evaluates to " << val1 << ",\n" |
| 2538 | << expr2 << " evaluates to " << val2 << ", and\n" |
| 2539 | << abs_error_expr << " evaluates to " << abs_error << "."; |
| 2540 | } |
| 2541 | |
| 2542 | |
| 2543 | // Helper template for implementing FloatLE() and DoubleLE(). |
nothing calls this directly
no test coverage detected