MCPcopy Create free account
hub / github.com/BVLC/caffe / HasOneFailure

Function HasOneFailure

src/gtest/gtest-all.cpp:1908–1942  ·  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

1906// failure of the given type and that the failure message contains the
1907// given substring.
1908AssertionResult HasOneFailure(const char* /* results_expr */,
1909 const char* /* type_expr */,
1910 const char* /* substr_expr */,
1911 const TestPartResultArray& results,
1912 TestPartResult::Type type,
1913 const string& substr) {
1914 const String expected(type == TestPartResult::kFatalFailure ?
1915 "1 fatal failure" :
1916 "1 non-fatal failure");
1917 Message msg;
1918 if (results.size() != 1) {
1919 msg << "Expected: " << expected << "\n"
1920 << " Actual: " << results.size() << " failures";
1921 for (int i = 0; i < results.size(); i++) {
1922 msg << "\n" << results.GetTestPartResult(i);
1923 }
1924 return AssertionFailure() << msg;
1925 }
1926
1927 const TestPartResult& r = results.GetTestPartResult(0);
1928 if (r.type() != type) {
1929 return AssertionFailure() << "Expected: " << expected << "\n"
1930 << " Actual:\n"
1931 << r;
1932 }
1933
1934 if (strstr(r.message(), substr.c_str()) == NULL) {
1935 return AssertionFailure() << "Expected: " << expected << " containing \""
1936 << substr << "\"\n"
1937 << " Actual:\n"
1938 << r;
1939 }
1940
1941 return AssertionSuccess();
1942}
1943
1944// The constructor of SingleFailureChecker remembers where to look up
1945// test part results, what type of failure we expect, and what

Callers

nothing calls this directly

Calls 4

AssertionFailureFunction · 0.85
AssertionSuccessFunction · 0.85
sizeMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected