MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / EqFailure

Function EqFailure

test/common/gtest/gtest.cpp:2784–2815  ·  view source on GitHub ↗

Constructs and returns the message for an equality assertion (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure. The first four parameters are the expressions used in the assertion and their values, as strings. For example, for ASSERT_EQ(foo, bar) where foo is 5 and bar is 6, we have: expected_expression: "foo" actual_expression: "bar" expected_value: "5" actual_value: "6" The ignoring_

Source from the content-addressed store, hash-verified

2782// *_STRCASEEQ*. When it's true, the string " (ignoring case)" will
2783// be inserted into the message.
2784AssertionResult EqFailure(const char* expected_expression,
2785 const char* actual_expression,
2786 const std::string& expected_value,
2787 const std::string& actual_value,
2788 bool ignoring_case) {
2789 Message msg;
2790 msg << "Value of: " << actual_expression;
2791 if (actual_value != actual_expression) {
2792 msg << "\n Actual: " << actual_value;
2793 }
2794
2795 msg << "\nExpected: " << expected_expression;
2796 if (ignoring_case) {
2797 msg << " (ignoring case)";
2798 }
2799 if (expected_value != expected_expression) {
2800 msg << "\nWhich is: " << expected_value;
2801 }
2802
2803 if (!expected_value.empty() && !actual_value.empty()) {
2804 const std::vector<std::string> expected_lines =
2805 SplitEscapedString(expected_value);
2806 const std::vector<std::string> actual_lines =
2807 SplitEscapedString(actual_value);
2808 if (expected_lines.size() > 1 || actual_lines.size() > 1) {
2809 msg << "\nWith diff:\n"
2810 << edit_distance::CreateUnifiedDiff(expected_lines, actual_lines);
2811 }
2812 }
2813
2814 return AssertionFailure() << msg;
2815}
2816
2817// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
2818std::string GetBoolAssertionFailureMessage(

Callers 5

CmpHelperEQFunction · 0.85
gtest.cppFile · 0.85
CmpHelperSTREQFunction · 0.85
CmpHelperEQFailureFunction · 0.85
CmpHelperFloatingPointEQFunction · 0.85

Calls 5

SplitEscapedStringFunction · 0.85
CreateUnifiedDiffFunction · 0.85
AssertionFailureFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected