Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
testing::internal::ContainerEqMatcher< Container > Class Template Reference

#include <gmock-matchers.h>

Public Types

typedef internal::StlContainerView< Container > View
 
typedef View::type StlContainer
 
typedef View::const_reference StlContainerReference
 

Public Member Functions

 ContainerEqMatcher (const Container &expected)
 
void DescribeTo (::std::ostream *os) const
 
void DescribeNegationTo (::std::ostream *os) const
 
template<typename LhsContainer >
bool MatchAndExplain (const LhsContainer &lhs, MatchResultListener *listener) const
 

Detailed Description

template<typename Container>
class testing::internal::ContainerEqMatcher< Container >

Definition at line 2816 of file gmock-matchers.h.

Member Typedef Documentation

◆ StlContainer

template<typename Container >
View::type testing::internal::ContainerEqMatcher< Container >::StlContainer

Definition at line 2819 of file gmock-matchers.h.

◆ StlContainerReference

template<typename Container >
View::const_reference testing::internal::ContainerEqMatcher< Container >::StlContainerReference

Definition at line 2820 of file gmock-matchers.h.

◆ View

template<typename Container >
internal::StlContainerView<Container> testing::internal::ContainerEqMatcher< Container >::View

Definition at line 2818 of file gmock-matchers.h.

Constructor & Destructor Documentation

◆ ContainerEqMatcher()

template<typename Container >
testing::internal::ContainerEqMatcher< Container >::ContainerEqMatcher ( const Container & expected)
inlineexplicit

Definition at line 2824 of file gmock-matchers.h.

2825 : expected_(View::Copy(expected)) {
2826 // Makes sure the user doesn't instantiate this class template
2827 // with a const or reference type.
2828 (void)testing::StaticAssertTypeEq<Container,
2830 }
static type Copy(const RawContainer &container)
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T)
bool StaticAssertTypeEq()
Definition gtest.h:2238
Here is the call graph for this function:

Member Function Documentation

◆ DescribeNegationTo()

template<typename Container >
void testing::internal::ContainerEqMatcher< Container >::DescribeNegationTo ( ::std::ostream * os) const
inline

Definition at line 2836 of file gmock-matchers.h.

2836 {
2837 *os << "does not equal ";
2838 UniversalPrint(expected_, os);
2839 }
os_t os
void UniversalPrint(const T &value, ::std::ostream *os)
Here is the call graph for this function:

◆ DescribeTo()

template<typename Container >
void testing::internal::ContainerEqMatcher< Container >::DescribeTo ( ::std::ostream * os) const
inline

Definition at line 2832 of file gmock-matchers.h.

2832 {
2833 *os << "equals ";
2834 UniversalPrint(expected_, os);
2835 }
Here is the call graph for this function:

◆ MatchAndExplain()

template<typename Container >
template<typename LhsContainer >
bool testing::internal::ContainerEqMatcher< Container >::MatchAndExplain ( const LhsContainer & lhs,
MatchResultListener * listener ) const
inline

Definition at line 2842 of file gmock-matchers.h.

2843 {
2844 // GTEST_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug
2845 // that causes LhsContainer to be a const type sometimes.
2846 typedef internal::StlContainerView<GTEST_REMOVE_CONST_(LhsContainer)>
2847 LhsView;
2848 typedef typename LhsView::type LhsStlContainer;
2849 StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
2850 if (lhs_stl_container == expected_)
2851 return true;
2852
2853 ::std::ostream* const os = listener->stream();
2854 if (os != NULL) {
2855 // Something is different. Check for extra values first.
2856 bool printed_header = false;
2857 for (typename LhsStlContainer::const_iterator it =
2858 lhs_stl_container.begin();
2859 it != lhs_stl_container.end(); ++it) {
2860 if (internal::ArrayAwareFind(expected_.begin(), expected_.end(), *it) ==
2861 expected_.end()) {
2862 if (printed_header) {
2863 *os << ", ";
2864 } else {
2865 *os << "which has these unexpected elements: ";
2866 printed_header = true;
2867 }
2868 UniversalPrint(*it, os);
2869 }
2870 }
2871
2872 // Now check for missing values.
2873 bool printed_header2 = false;
2874 for (typename StlContainer::const_iterator it = expected_.begin();
2875 it != expected_.end(); ++it) {
2877 lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==
2878 lhs_stl_container.end()) {
2879 if (printed_header2) {
2880 *os << ", ";
2881 } else {
2882 *os << (printed_header ? ",\nand" : "which")
2883 << " doesn't have these expected elements: ";
2884 printed_header2 = true;
2885 }
2886 UniversalPrint(*it, os);
2887 }
2888 }
2889 }
2890
2891 return false;
2892 }
View::const_reference StlContainerReference
#define GTEST_REMOVE_CONST_(T)
Iter ArrayAwareFind(Iter begin, Iter end, const Element &elem)
Here is the call graph for this function:

The documentation for this class was generated from the following file: