| 2359 | // Helper template for implementing FloatLE() and DoubleLE(). |
| 2360 | template <typename RawType> |
| 2361 | AssertionResult FloatingPointLE(const char* expr1, |
| 2362 | const char* expr2, |
| 2363 | RawType val1, |
| 2364 | RawType val2) { |
| 2365 | // Returns success if val1 is less than val2, |
| 2366 | if (val1 < val2) { |
| 2367 | return AssertionSuccess(); |
| 2368 | } |
| 2369 | |
| 2370 | // or if val1 is almost equal to val2. |
| 2371 | const FloatingPoint<RawType> lhs(val1), rhs(val2); |
| 2372 | if (lhs.AlmostEquals(rhs)) { |
| 2373 | return AssertionSuccess(); |
| 2374 | } |
| 2375 | |
| 2376 | // Note that the above two checks will both fail if either val1 or |
| 2377 | // val2 is NaN, as the IEEE floating-point standard requires that |
| 2378 | // any predicate involving a NaN must return false. |
| 2379 | |
| 2380 | ::std::stringstream val1_ss; |
| 2381 | val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) |
| 2382 | << val1; |
| 2383 | |
| 2384 | ::std::stringstream val2_ss; |
| 2385 | val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) |
| 2386 | << val2; |
| 2387 | |
| 2388 | return AssertionFailure() |
| 2389 | << "Expected: (" << expr1 << ") <= (" << expr2 << ")\n" |
| 2390 | << " Actual: " << StringStreamToString(&val1_ss) << " vs " |
| 2391 | << StringStreamToString(&val2_ss); |
| 2392 | } |
| 2393 | |
| 2394 | } // namespace internal |
| 2395 |
nothing calls this directly
no test coverage detected