| 1659 | // Helper template for implementing FloatLE() and DoubleLE(). |
| 1660 | template <typename RawType> |
| 1661 | AssertionResult FloatingPointLE(const char* expr1, const char* expr2, |
| 1662 | RawType val1, RawType val2) { |
| 1663 | // Returns success if val1 is less than val2, |
| 1664 | if (val1 < val2) { |
| 1665 | return AssertionSuccess(); |
| 1666 | } |
| 1667 | |
| 1668 | // or if val1 is almost equal to val2. |
| 1669 | const FloatingPoint<RawType> lhs(val1), rhs(val2); |
| 1670 | if (lhs.AlmostEquals(rhs)) { |
| 1671 | return AssertionSuccess(); |
| 1672 | } |
| 1673 | |
| 1674 | // Note that the above two checks will both fail if either val1 or |
| 1675 | // val2 is NaN, as the IEEE floating-point standard requires that |
| 1676 | // any predicate involving a NaN must return false. |
| 1677 | |
| 1678 | ::std::stringstream val1_ss; |
| 1679 | val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) |
| 1680 | << val1; |
| 1681 | |
| 1682 | ::std::stringstream val2_ss; |
| 1683 | val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) |
| 1684 | << val2; |
| 1685 | |
| 1686 | return AssertionFailure() |
| 1687 | << "Expected: (" << expr1 << ") <= (" << expr2 << ")\n" |
| 1688 | << " Actual: " << StringStreamToString(&val1_ss) << " vs " |
| 1689 | << StringStreamToString(&val2_ss); |
| 1690 | } |
| 1691 | |
| 1692 | } // namespace internal |
| 1693 |
nothing calls this directly
no test coverage detected