diff options
author | Abseil Team <absl-team@google.com> | 2022-12-12 19:51:21 (GMT) |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-12-12 19:51:48 (GMT) |
commit | ad54e90f57199b91ac40e1344eb0c75e8670b21b (patch) | |
tree | 3530a6bb600a23932f91e3a98d96c14a541c6cf6 /googlemock | |
parent | b0846aaf37a271d56019b42121ebcea0ac42e8c1 (diff) | |
download | googletest-ad54e90f57199b91ac40e1344eb0c75e8670b21b.zip googletest-ad54e90f57199b91ac40e1344eb0c75e8670b21b.tar.gz googletest-ad54e90f57199b91ac40e1344eb0c75e8670b21b.tar.bz2 |
Refactor matrix verification into VerifyMatchMatrix.refs/pull/4082/head
PiperOrigin-RevId: 494786543
Change-Id: I7769558dd2ca046d8957bf352dc04cfb48ff7c3a
Diffstat (limited to 'googlemock')
-rw-r--r-- | googlemock/include/gmock/gmock-matchers.h | 17 | ||||
-rw-r--r-- | googlemock/src/gmock-matchers.cc | 17 |
2 files changed, 17 insertions, 17 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 901c109..26fe8d2 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -3644,23 +3644,6 @@ class UnorderedElementsAreMatcherImpl AnalyzeElements(stl_container.begin(), stl_container.end(), &element_printouts, listener); - 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; - } - } - return VerifyMatchMatrix(element_printouts, matrix, listener) && FindPairing(matrix, listener); } diff --git a/googlemock/src/gmock-matchers.cc b/googlemock/src/gmock-matchers.cc index a8d04a6..5810b6a 100644 --- a/googlemock/src/gmock-matchers.cc +++ b/googlemock/src/gmock-matchers.cc @@ -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); |