MCPcopy Create free account
hub / github.com/apache/singa / DoubleNearPredFormat

Function DoubleNearPredFormat

test/gtest/gtest-all.cc:2523–2540  ·  view source on GitHub ↗

Helper function for implementing ASSERT_NEAR.

Source from the content-addressed store, hash-verified

2521
2522// Helper function for implementing ASSERT_NEAR.
2523AssertionResult DoubleNearPredFormat(const char* expr1,
2524 const char* expr2,
2525 const char* abs_error_expr,
2526 double val1,
2527 double val2,
2528 double abs_error) {
2529 const double diff = fabs(val1 - val2);
2530 if (diff <= abs_error) return AssertionSuccess();
2531
2532 // TODO(wan): do not print the value of an expression if it's
2533 // already a literal.
2534 return AssertionFailure()
2535 << "The difference between " << expr1 << " and " << expr2
2536 << " is " << diff << ", which exceeds " << abs_error_expr << ", where\n"
2537 << expr1 << " evaluates to " << val1 << ",\n"
2538 << expr2 << " evaluates to " << val2 << ", and\n"
2539 << abs_error_expr << " evaluates to " << abs_error << ".";
2540}
2541
2542
2543// Helper template for implementing FloatLE() and DoubleLE().

Callers

nothing calls this directly

Calls 3

fabsFunction · 0.85
AssertionSuccessFunction · 0.85
AssertionFailureFunction · 0.85

Tested by

no test coverage detected