| 2854 | // Helper template for implementing FloatLE() and DoubleLE(). |
| 2855 | template <typename RawType> |
| 2856 | AssertionResult FloatingPointLE(const char* expr1, |
| 2857 | const char* expr2, |
| 2858 | RawType val1, |
| 2859 | RawType val2) { |
| 2860 | // Returns success if val1 is less than val2, |
| 2861 | if (val1 < val2) { |
| 2862 | return AssertionSuccess(); |
| 2863 | } |
| 2864 | |
| 2865 | // or if val1 is almost equal to val2. |
| 2866 | const FloatingPoint<RawType> lhs(val1), rhs(val2); |
| 2867 | if (lhs.AlmostEquals(rhs)) { |
| 2868 | return AssertionSuccess(); |
| 2869 | } |
| 2870 | |
| 2871 | // Note that the above two checks will both fail if either val1 or |
| 2872 | // val2 is NaN, as the IEEE floating-point standard requires that |
| 2873 | // any predicate involving a NaN must return false. |
| 2874 | |
| 2875 | ::std::stringstream val1_ss; |
| 2876 | val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) |
| 2877 | << val1; |
| 2878 | |
| 2879 | ::std::stringstream val2_ss; |
| 2880 | val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) |
| 2881 | << val2; |
| 2882 | |
| 2883 | return AssertionFailure() |
| 2884 | << "Expected: (" << expr1 << ") <= (" << expr2 << ")\n" |
| 2885 | << " Actual: " << StringStreamToString(&val1_ss) << " vs " |
| 2886 | << StringStreamToString(&val2_ss); |
| 2887 | } |
| 2888 | |
| 2889 | } // namespace internal |
| 2890 |
nothing calls this directly
no test coverage detected