| 2875 | // Helper template for implementing FloatLE() and DoubleLE(). |
| 2876 | template <typename RawType> |
| 2877 | AssertionResult FloatingPointLE(const char* expr1, |
| 2878 | const char* expr2, |
| 2879 | RawType val1, |
| 2880 | RawType val2) { |
| 2881 | // Returns success if val1 is less than val2, |
| 2882 | if (val1 < val2) { |
| 2883 | return AssertionSuccess(); |
| 2884 | } |
| 2885 | |
| 2886 | // or if val1 is almost equal to val2. |
| 2887 | const FloatingPoint<RawType> lhs(val1), rhs(val2); |
| 2888 | if (lhs.AlmostEquals(rhs)) { |
| 2889 | return AssertionSuccess(); |
| 2890 | } |
| 2891 | |
| 2892 | // Note that the above two checks will both fail if either val1 or |
| 2893 | // val2 is NaN, as the IEEE floating-point standard requires that |
| 2894 | // any predicate involving a NaN must return false. |
| 2895 | |
| 2896 | ::std::stringstream val1_ss; |
| 2897 | val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) |
| 2898 | << val1; |
| 2899 | |
| 2900 | ::std::stringstream val2_ss; |
| 2901 | val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) |
| 2902 | << val2; |
| 2903 | |
| 2904 | return AssertionFailure() |
| 2905 | << "Expected: (" << expr1 << ") <= (" << expr2 << ")\n" |
| 2906 | << " Actual: " << StringStreamToString(&val1_ss) << " vs " |
| 2907 | << StringStreamToString(&val2_ss); |
| 2908 | } |
| 2909 | |
| 2910 | } // namespace internal |
| 2911 |
nothing calls this directly
no test coverage detected