proxygen
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
 
typedef internal::StlContainerView< Container > View
 
typedef View::type StlContainer
 
typedef View::const_reference StlContainerReference
 
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
 
 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
 
 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
 

Private Member Functions

 GTEST_DISALLOW_ASSIGN_ (ContainerEqMatcher)
 
 GTEST_DISALLOW_ASSIGN_ (ContainerEqMatcher)
 
 GTEST_DISALLOW_ASSIGN_ (ContainerEqMatcher)
 

Private Attributes

const StlContainer expected_
 

Detailed Description

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

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

Member Typedef Documentation

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Constructor & Destructor Documentation

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

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

References GTEST_REMOVE_REFERENCE_AND_CONST_, and testing::StaticAssertTypeEq().

2530  : expected_(View::Copy(expected)) {
2531  // Makes sure the user doesn't instantiate this class template
2532  // with a const or reference type.
2533  (void)testing::StaticAssertTypeEq<Container,
2534  GTEST_REMOVE_REFERENCE_AND_CONST_(Container)>();
2535  }
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T)
static type Copy(const RawContainer &container)
bool StaticAssertTypeEq()
Definition: gtest.h:2150
template<typename Container >
testing::internal::ContainerEqMatcher< Container >::ContainerEqMatcher ( const Container &  expected)
inlineexplicit

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

References GTEST_REMOVE_REFERENCE_AND_CONST_, and testing::StaticAssertTypeEq().

2530  : expected_(View::Copy(expected)) {
2531  // Makes sure the user doesn't instantiate this class template
2532  // with a const or reference type.
2533  (void)testing::StaticAssertTypeEq<Container,
2534  GTEST_REMOVE_REFERENCE_AND_CONST_(Container)>();
2535  }
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T)
static type Copy(const RawContainer &container)
bool StaticAssertTypeEq()
Definition: gtest.h:2150
template<typename Container >
testing::internal::ContainerEqMatcher< Container >::ContainerEqMatcher ( const Container &  expected)
inlineexplicit

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

References GTEST_REMOVE_REFERENCE_AND_CONST_, and testing::StaticAssertTypeEq().

2530  : expected_(View::Copy(expected)) {
2531  // Makes sure the user doesn't instantiate this class template
2532  // with a const or reference type.
2533  (void)testing::StaticAssertTypeEq<Container,
2534  GTEST_REMOVE_REFERENCE_AND_CONST_(Container)>();
2535  }
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T)
static type Copy(const RawContainer &container)
bool StaticAssertTypeEq()
Definition: gtest.h:2150

Member Function Documentation

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

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

References testing::internal::UniversalPrint().

2541  {
2542  *os << "does not equal ";
2544  }
void UniversalPrint(const T &value,::std::ostream *os)
template<typename Container >
void testing::internal::ContainerEqMatcher< Container >::DescribeNegationTo ( ::std::ostream *  os) const
inline

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

References testing::internal::UniversalPrint().

2541  {
2542  *os << "does not equal ";
2544  }
void UniversalPrint(const T &value,::std::ostream *os)
template<typename Container >
void testing::internal::ContainerEqMatcher< Container >::DescribeNegationTo ( ::std::ostream *  os) const
inline

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

References testing::internal::UniversalPrint().

2541  {
2542  *os << "does not equal ";
2544  }
void UniversalPrint(const T &value,::std::ostream *os)
template<typename Container >
void testing::internal::ContainerEqMatcher< Container >::DescribeTo ( ::std::ostream *  os) const
inline

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

References testing::internal::UniversalPrint().

2537  {
2538  *os << "equals ";
2540  }
void UniversalPrint(const T &value,::std::ostream *os)
template<typename Container >
void testing::internal::ContainerEqMatcher< Container >::DescribeTo ( ::std::ostream *  os) const
inline

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

References testing::internal::UniversalPrint().

2537  {
2538  *os << "equals ";
2540  }
void UniversalPrint(const T &value,::std::ostream *os)
template<typename Container >
void testing::internal::ContainerEqMatcher< Container >::DescribeTo ( ::std::ostream *  os) const
inline

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

References testing::internal::UniversalPrint().

2537  {
2538  *os << "equals ";
2540  }
void UniversalPrint(const T &value,::std::ostream *os)
template<typename Container >
testing::internal::ContainerEqMatcher< Container >::GTEST_DISALLOW_ASSIGN_ ( ContainerEqMatcher< Container >  )
private
template<typename Container >
testing::internal::ContainerEqMatcher< Container >::GTEST_DISALLOW_ASSIGN_ ( ContainerEqMatcher< Container >  )
private
template<typename Container >
testing::internal::ContainerEqMatcher< Container >::GTEST_DISALLOW_ASSIGN_ ( ContainerEqMatcher< Container >  )
private
template<typename Container >
template<typename LhsContainer >
bool testing::internal::ContainerEqMatcher< Container >::MatchAndExplain ( const LhsContainer &  lhs,
MatchResultListener listener 
) const
inline

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

References testing::internal::ArrayAwareFind(), testing::MatchResultListener::stream(), type, and testing::internal::UniversalPrint().

2548  {
2549  // GTEST_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug
2550  // that causes LhsContainer to be a const type sometimes.
2551  typedef internal::StlContainerView<GTEST_REMOVE_CONST_(LhsContainer)>
2552  LhsView;
2553  typedef typename LhsView::type LhsStlContainer;
2554  StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
2555  if (lhs_stl_container == expected_)
2556  return true;
2557 
2558  ::std::ostream* const os = listener->stream();
2559  if (os != NULL) {
2560  // Something is different. Check for extra values first.
2561  bool printed_header = false;
2562  for (typename LhsStlContainer::const_iterator it =
2563  lhs_stl_container.begin();
2564  it != lhs_stl_container.end(); ++it) {
2565  if (internal::ArrayAwareFind(expected_.begin(), expected_.end(), *it) ==
2566  expected_.end()) {
2567  if (printed_header) {
2568  *os << ", ";
2569  } else {
2570  *os << "which has these unexpected elements: ";
2571  printed_header = true;
2572  }
2573  UniversalPrint(*it, os);
2574  }
2575  }
2576 
2577  // Now check for missing values.
2578  bool printed_header2 = false;
2579  for (typename StlContainer::const_iterator it = expected_.begin();
2580  it != expected_.end(); ++it) {
2582  lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==
2583  lhs_stl_container.end()) {
2584  if (printed_header2) {
2585  *os << ", ";
2586  } else {
2587  *os << (printed_header ? ",\nand" : "which")
2588  << " doesn't have these expected elements: ";
2589  printed_header2 = true;
2590  }
2591  UniversalPrint(*it, os);
2592  }
2593  }
2594  }
2595 
2596  return false;
2597  }
PskType type
View::const_reference StlContainerReference
void UniversalPrint(const T &value,::std::ostream *os)
Iter ArrayAwareFind(Iter begin, Iter end, const Element &elem)
template<typename Container >
template<typename LhsContainer >
bool testing::internal::ContainerEqMatcher< Container >::MatchAndExplain ( const LhsContainer &  lhs,
MatchResultListener listener 
) const
inline

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

References testing::internal::ArrayAwareFind(), GTEST_DISALLOW_ASSIGN_, type, and testing::internal::UniversalPrint().

2548  {
2549  // GTEST_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug
2550  // that causes LhsContainer to be a const type sometimes.
2551  typedef internal::StlContainerView<GTEST_REMOVE_CONST_(LhsContainer)>
2552  LhsView;
2553  typedef typename LhsView::type LhsStlContainer;
2554  StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
2555  if (lhs_stl_container == expected_)
2556  return true;
2557 
2558  ::std::ostream* const os = listener->stream();
2559  if (os != NULL) {
2560  // Something is different. Check for extra values first.
2561  bool printed_header = false;
2562  for (typename LhsStlContainer::const_iterator it =
2563  lhs_stl_container.begin();
2564  it != lhs_stl_container.end(); ++it) {
2565  if (internal::ArrayAwareFind(expected_.begin(), expected_.end(), *it) ==
2566  expected_.end()) {
2567  if (printed_header) {
2568  *os << ", ";
2569  } else {
2570  *os << "which has these unexpected elements: ";
2571  printed_header = true;
2572  }
2573  UniversalPrint(*it, os);
2574  }
2575  }
2576 
2577  // Now check for missing values.
2578  bool printed_header2 = false;
2579  for (typename StlContainer::const_iterator it = expected_.begin();
2580  it != expected_.end(); ++it) {
2582  lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==
2583  lhs_stl_container.end()) {
2584  if (printed_header2) {
2585  *os << ", ";
2586  } else {
2587  *os << (printed_header ? ",\nand" : "which")
2588  << " doesn't have these expected elements: ";
2589  printed_header2 = true;
2590  }
2591  UniversalPrint(*it, os);
2592  }
2593  }
2594  }
2595 
2596  return false;
2597  }
PskType type
View::const_reference StlContainerReference
void UniversalPrint(const T &value,::std::ostream *os)
Iter ArrayAwareFind(Iter begin, Iter end, const Element &elem)
template<typename Container >
template<typename LhsContainer >
bool testing::internal::ContainerEqMatcher< Container >::MatchAndExplain ( const LhsContainer &  lhs,
MatchResultListener listener 
) const
inline

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

References testing::internal::ArrayAwareFind(), GTEST_DISALLOW_ASSIGN_, type, and testing::internal::UniversalPrint().

2548  {
2549  // GTEST_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug
2550  // that causes LhsContainer to be a const type sometimes.
2551  typedef internal::StlContainerView<GTEST_REMOVE_CONST_(LhsContainer)>
2552  LhsView;
2553  typedef typename LhsView::type LhsStlContainer;
2554  StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
2555  if (lhs_stl_container == expected_)
2556  return true;
2557 
2558  ::std::ostream* const os = listener->stream();
2559  if (os != NULL) {
2560  // Something is different. Check for extra values first.
2561  bool printed_header = false;
2562  for (typename LhsStlContainer::const_iterator it =
2563  lhs_stl_container.begin();
2564  it != lhs_stl_container.end(); ++it) {
2565  if (internal::ArrayAwareFind(expected_.begin(), expected_.end(), *it) ==
2566  expected_.end()) {
2567  if (printed_header) {
2568  *os << ", ";
2569  } else {
2570  *os << "which has these unexpected elements: ";
2571  printed_header = true;
2572  }
2573  UniversalPrint(*it, os);
2574  }
2575  }
2576 
2577  // Now check for missing values.
2578  bool printed_header2 = false;
2579  for (typename StlContainer::const_iterator it = expected_.begin();
2580  it != expected_.end(); ++it) {
2582  lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==
2583  lhs_stl_container.end()) {
2584  if (printed_header2) {
2585  *os << ", ";
2586  } else {
2587  *os << (printed_header ? ",\nand" : "which")
2588  << " doesn't have these expected elements: ";
2589  printed_header2 = true;
2590  }
2591  UniversalPrint(*it, os);
2592  }
2593  }
2594  }
2595 
2596  return false;
2597  }
PskType type
View::const_reference StlContainerReference
void UniversalPrint(const T &value,::std::ostream *os)
Iter ArrayAwareFind(Iter begin, Iter end, const Element &elem)

Member Data Documentation

template<typename Container >
const StlContainer testing::internal::ContainerEqMatcher< Container >::expected_
private

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


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