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

Function HasOneFailure

tests/gtest/gtest-all.cc:2139–2173  ·  view source on GitHub ↗

This predicate-formatter checks that 'results' contains a test part failure of the given type and that the failure message contains the given substring.

Source from the content-addressed store, hash-verified

2137// failure of the given type and that the failure message contains the
2138// given substring.
2139static AssertionResult HasOneFailure(const char* /* results_expr */,
2140 const char* /* type_expr */,
2141 const char* /* substr_expr */,
2142 const TestPartResultArray& results,
2143 TestPartResult::Type type,
2144 const std::string& substr) {
2145 const std::string expected(type == TestPartResult::kFatalFailure ?
2146 "1 fatal failure" :
2147 "1 non-fatal failure");
2148 Message msg;
2149 if (results.size() != 1) {
2150 msg << "Expected: " << expected << "\n"
2151 << " Actual: " << results.size() << " failures";
2152 for (int i = 0; i < results.size(); i++) {
2153 msg << "\n" << results.GetTestPartResult(i);
2154 }
2155 return AssertionFailure() << msg;
2156 }
2157
2158 const TestPartResult& r = results.GetTestPartResult(0);
2159 if (r.type() != type) {
2160 return AssertionFailure() << "Expected: " << expected << "\n"
2161 << " Actual:\n"
2162 << r;
2163 }
2164
2165 if (strstr(r.message(), substr.c_str()) == nullptr) {
2166 return AssertionFailure() << "Expected: " << expected << " containing \""
2167 << substr << "\"\n"
2168 << " Actual:\n"
2169 << r;
2170 }
2171
2172 return AssertionSuccess();
2173}
2174
2175// The constructor of SingleFailureChecker remembers where to look up
2176// test part results, what type of failure we expect, and what

Callers

nothing calls this directly

Calls 3

AssertionFailureFunction · 0.85
AssertionSuccessFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected