diff options
Diffstat (limited to 'third-party/unittest/googlemock/src/gmock-matchers.cc')
| -rw-r--r-- | third-party/unittest/googlemock/src/gmock-matchers.cc | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/third-party/unittest/googlemock/src/gmock-matchers.cc b/third-party/unittest/googlemock/src/gmock-matchers.cc index 4a3f7af2351d..07bba4f0103d 100644 --- a/third-party/unittest/googlemock/src/gmock-matchers.cc +++ b/third-party/unittest/googlemock/src/gmock-matchers.cc @@ -27,19 +27,19 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Google Mock - a framework for writing C++ mock classes. // // This file implements Matcher<const string&>, Matcher<string>, and // utilities for defining matchers. #include "gmock/gmock-matchers.h" -#include "gmock/gmock-generated-matchers.h" #include <string.h> + #include <iostream> #include <sstream> #include <string> +#include <vector> namespace testing { namespace internal { @@ -49,11 +49,13 @@ namespace internal { // 'negation' is false; otherwise returns the description of the // negation of the matcher. 'param_values' contains a list of strings // that are the print-out of the matcher's parameters. -GTEST_API_ std::string FormatMatcherDescription(bool negation, - const char* matcher_name, - const Strings& param_values) { +GTEST_API_ std::string FormatMatcherDescription( + bool negation, const char* matcher_name, + const std::vector<const char*>& param_names, const Strings& param_values) { std::string result = ConvertIdentifierNameToWords(matcher_name); - if (param_values.size() >= 1) result += " " + JoinAsTuple(param_values); + if (!param_values.empty()) { + result += " " + JoinAsKeyValueTuple(param_names, param_values); + } return negation ? "not (" + result + ")" : result; } @@ -219,8 +221,6 @@ class MaxBipartiteMatchState { // right_[left_[i]] = i. ::std::vector<size_t> left_; ::std::vector<size_t> right_; - - GTEST_DISALLOW_ASSIGN_(MaxBipartiteMatchState); }; const size_t MaxBipartiteMatchState::kUnused; @@ -370,6 +370,23 @@ void UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl( bool UnorderedElementsAreMatcherImplBase::VerifyMatchMatrix( const ::std::vector<std::string>& element_printouts, const MatchMatrix& matrix, MatchResultListener* listener) const { + if (matrix.LhsSize() == 0 && matrix.RhsSize() == 0) { + return true; + } + + if (match_flags() == UnorderedMatcherRequire::ExactMatch) { + if (matrix.LhsSize() != matrix.RhsSize()) { + // The element count doesn't match. If the container is empty, + // there's no need to explain anything as Google Mock already + // prints the empty container. Otherwise we just need to show + // how many elements there actually are. + if (matrix.LhsSize() != 0 && listener->IsInterested()) { + *listener << "which has " << Elements(matrix.LhsSize()); + } + return false; + } + } + bool result = true; ::std::vector<char> element_matched(matrix.LhsSize(), 0); ::std::vector<char> matcher_matched(matrix.RhsSize(), 0); |
