MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / FloatingPointLE

Function FloatingPointLE

rtpose_wrapper/src/gtest/gtest-all.cpp:2361–2392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2359// Helper template for implementing FloatLE() and DoubleLE().
2360template <typename RawType>
2361AssertionResult 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

Callers

nothing calls this directly

Calls 4

AssertionSuccessFunction · 0.85
AssertionFailureFunction · 0.85
StringStreamToStringFunction · 0.85
AlmostEqualsMethod · 0.80

Tested by

no test coverage detected