Refactor matrix verification into VerifyMatchMatrix.
PiperOrigin-RevId: 494786543 Change-Id: I7769558dd2ca046d8957bf352dc04cfb48ff7c3a
This commit is contained in:
parent
b0846aaf37
commit
ad54e90f57
@ -3644,23 +3644,6 @@ class UnorderedElementsAreMatcherImpl
|
|||||||
AnalyzeElements(stl_container.begin(), stl_container.end(),
|
AnalyzeElements(stl_container.begin(), stl_container.end(),
|
||||||
&element_printouts, listener);
|
&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) &&
|
return VerifyMatchMatrix(element_printouts, matrix, listener) &&
|
||||||
FindPairing(matrix, listener);
|
FindPairing(matrix, listener);
|
||||||
}
|
}
|
||||||
|
@ -370,6 +370,23 @@ void UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl(
|
|||||||
bool UnorderedElementsAreMatcherImplBase::VerifyMatchMatrix(
|
bool UnorderedElementsAreMatcherImplBase::VerifyMatchMatrix(
|
||||||
const ::std::vector<std::string>& element_printouts,
|
const ::std::vector<std::string>& element_printouts,
|
||||||
const MatchMatrix& matrix, MatchResultListener* listener) const {
|
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;
|
bool result = true;
|
||||||
::std::vector<char> element_matched(matrix.LhsSize(), 0);
|
::std::vector<char> element_matched(matrix.LhsSize(), 0);
|
||||||
::std::vector<char> matcher_matched(matrix.RhsSize(), 0);
|
::std::vector<char> matcher_matched(matrix.RhsSize(), 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user