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

Function EqFailure

tests/gtest/gtest-all.cc:2806–2838  ·  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: lhs_expression: "foo" rhs_expression: "bar" lhs_value: "5" rhs_value: "6" The ignoring_case parameter is tr

Source from the content-addressed store, hash-verified

2804// *_STRCASEEQ*. When it's true, the string "Ignoring case" will
2805// be inserted into the message.
2806AssertionResult EqFailure(const char* lhs_expression,
2807 const char* rhs_expression,
2808 const std::string& lhs_value,
2809 const std::string& rhs_value,
2810 bool ignoring_case) {
2811 Message msg;
2812 msg << "Expected equality of these values:";
2813 msg << "\n " << lhs_expression;
2814 if (lhs_value != lhs_expression) {
2815 msg << "\n Which is: " << lhs_value;
2816 }
2817 msg << "\n " << rhs_expression;
2818 if (rhs_value != rhs_expression) {
2819 msg << "\n Which is: " << rhs_value;
2820 }
2821
2822 if (ignoring_case) {
2823 msg << "\nIgnoring case";
2824 }
2825
2826 if (!lhs_value.empty() && !rhs_value.empty()) {
2827 const std::vector<std::string> lhs_lines =
2828 SplitEscapedString(lhs_value);
2829 const std::vector<std::string> rhs_lines =
2830 SplitEscapedString(rhs_value);
2831 if (lhs_lines.size() > 1 || rhs_lines.size() > 1) {
2832 msg << "\nWith diff:\n"
2833 << edit_distance::CreateUnifiedDiff(lhs_lines, rhs_lines);
2834 }
2835 }
2836
2837 return AssertionFailure() << msg;
2838}
2839
2840// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
2841std::string GetBoolAssertionFailureMessage(

Callers 5

CmpHelperEQFailureFunction · 0.85
CmpHelperFloatingPointEQFunction · 0.85
CmpHelperEQFunction · 0.85
gtest-all.ccFile · 0.85
CmpHelperSTREQFunction · 0.85

Calls 4

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

Tested by

no test coverage detected