MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / FloatingPointLE

Function FloatingPointLE

tests/gtest/gtest-all.cc:2877–2908  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2875// Helper template for implementing FloatLE() and DoubleLE().
2876template <typename RawType>
2877AssertionResult 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

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