aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2013-07-30 06:16:21 +0000
committerzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2013-07-30 06:16:21 +0000
commit5579c1a8b1591d4932495b8cb3cc61f3edca2555 (patch)
tree4d4fa50c41cecd0547b9b8b9fcdfe99275d95333 /include
parentfb25d5391143a0fd4cbce862f19472ddc2a1ecab (diff)
downloadgoogletest-5579c1a8b1591d4932495b8cb3cc61f3edca2555.tar.gz
googletest-5579c1a8b1591d4932495b8cb3cc61f3edca2555.tar.bz2
googletest-5579c1a8b1591d4932495b8cb3cc61f3edca2555.zip
Makes UnorderedElementsAre*() work with containers that don't have size() or empty().
Diffstat (limited to 'include')
-rw-r--r--include/gmock/gmock-matchers.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/include/gmock/gmock-matchers.h b/include/gmock/gmock-matchers.h
index 18ccdca3..0f52ee45 100644
--- a/include/gmock/gmock-matchers.h
+++ b/include/gmock/gmock-matchers.h
@@ -3095,8 +3095,13 @@ class UnorderedElementsAreMatcherImpl
virtual bool MatchAndExplain(Container container,
MatchResultListener* listener) const {
StlContainerReference stl_container = View::ConstReference(container);
- size_t actual_count = stl_container.size();
+ ::std::vector<string> element_printouts;
+ MatchMatrix matrix = AnalyzeElements(stl_container.begin(),
+ stl_container.end(),
+ &element_printouts,
+ listener);
+ const size_t actual_count = matrix.LhsSize();
if (actual_count == 0 && matchers_.empty()) {
return true;
}
@@ -3111,12 +3116,6 @@ class UnorderedElementsAreMatcherImpl
return false;
}
- ::std::vector<string> element_printouts;
- MatchMatrix matrix = AnalyzeElements(stl_container.begin(),
- stl_container.end(),
- &element_printouts,
- listener);
-
return VerifyAllElementsAndMatchersAreMatched(element_printouts,
matrix, listener) &&
FindPairing(matrix, listener);
@@ -3129,6 +3128,7 @@ class UnorderedElementsAreMatcherImpl
MatchMatrix AnalyzeElements(ElementIter elem_first, ElementIter elem_last,
::std::vector<string>* element_printouts,
MatchResultListener* listener) const {
+ element_printouts->clear();
::std::vector<char> did_match;
size_t num_elements = 0;
for (; elem_first != elem_last; ++num_elements, ++elem_first) {