Helper function for implementing ASSERT_NEAR.
| 2855 | |
| 2856 | // Helper function for implementing ASSERT_NEAR. |
| 2857 | AssertionResult DoubleNearPredFormat(const char* expr1, |
| 2858 | const char* expr2, |
| 2859 | const char* abs_error_expr, |
| 2860 | double val1, |
| 2861 | double val2, |
| 2862 | double abs_error) { |
| 2863 | const double diff = fabs(val1 - val2); |
| 2864 | if (diff <= abs_error) return AssertionSuccess(); |
| 2865 | |
| 2866 | return AssertionFailure() |
| 2867 | << "The difference between " << expr1 << " and " << expr2 |
| 2868 | << " is " << diff << ", which exceeds " << abs_error_expr << ", where\n" |
| 2869 | << expr1 << " evaluates to " << val1 << ",\n" |
| 2870 | << expr2 << " evaluates to " << val2 << ", and\n" |
| 2871 | << abs_error_expr << " evaluates to " << abs_error << "."; |
| 2872 | } |
| 2873 | |
| 2874 | |
| 2875 | // Helper template for implementing FloatLE() and DoubleLE(). |
nothing calls this directly
no test coverage detected