proxygen
testing::gmock_matchers_test Namespace Reference

Classes

class  AClass
 
class  AllArgsHelper
 
struct  AStruct
 
class  BacktrackingBPMTest
 
class  Base
 
class  BipartiteNonSquareTest
 
class  BipartiteRandomTest
 
class  BipartiteTest
 
class  ConstPropagatingPtr
 
struct  ConvertibleFromAny
 
class  ConvertibleToBool
 
class  Derived
 
class  DerivedClass
 
struct  DerivedStruct
 
class  DivisibleByImpl
 
class  EvenMatcherImpl
 
class  FloatingPointNearTest
 
class  FloatingPointTest
 
struct  Functor
 
class  GreaterThanMatcher
 
struct  IntReferenceWrapper
 
class  IntValue
 
class  IsGreaterThan
 
class  IsHalfOfMatcher
 
class  NewEvenMatcherImpl
 
class  NotCopyable
 
class  OtherDerived
 
struct  PolymorphicFunctor
 
class  PolymorphicIsEvenImpl
 
class  ReferencesBarOrIsZeroImpl
 
struct  ReferencingFunctor
 
class  Streamlike
 
struct  Type
 
class  Uncopyable
 
class  UnorderedElementsAreTest
 
class  Unprintable
 

Typedefs

typedef ::testing::tuple< long, int > Tuple2
 
typedef FloatingPointTest< float > FloatTest
 
typedef FloatingPointNearTest< float > FloatNearTest
 
typedef FloatingPointTest< double > DoubleTest
 
typedef FloatingPointNearTest< double > DoubleNearTest
 

Functions

Matcher< int > GreaterThan (int n)
 
string OfType (const string &type_name)
 
template<typename T >
string Describe (const Matcher< T > &m)
 
template<typename T >
string DescribeNegation (const Matcher< T > &m)
 
template<typename MatcherType , typename Value >
string Explain (const MatcherType &m, const Value &x)
 
 TEST (MatchResultListenerTest, StreamingWorks)
 
 TEST (MatchResultListenerTest, CanAccessUnderlyingStream)
 
 TEST (MatchResultListenerTest, IsInterestedWorks)
 
 TEST (MatcherInterfaceTest, CanBeImplementedUsingPublishedAPI)
 
 TEST (MatcherInterfaceTest, CanBeImplementedUsingNewAPI)
 
 TEST (MatcherTest, CanBeDefaultConstructed)
 
 TEST (MatcherTest, CanBeConstructedFromMatcherInterface)
 
 TEST (MatcherTest, CanBeImplicitlyConstructedFromValue)
 
 TEST (MatcherTest, CanBeImplicitlyConstructedFromNULL)
 
 TEST (MatcherTest, IsCopyable)
 
 TEST (MatcherTest, CanDescribeItself)
 
 TEST (MatcherTest, MatchAndExplain)
 
 TEST (StringMatcherTest, CanBeImplicitlyConstructedFromCStringLiteral)
 
 TEST (StringMatcherTest, CanBeImplicitlyConstructedFromString)
 
 TEST (MakeMatcherTest, ConstructsMatcherFromMatcherInterface)
 
PolymorphicMatcher< ReferencesBarOrIsZeroImplReferencesBarOrIsZero ()
 
 TEST (MakePolymorphicMatcherTest, ConstructsMatcherUsingOldAPI)
 
PolymorphicMatcher< PolymorphicIsEvenImplPolymorphicIsEven ()
 
 TEST (MakePolymorphicMatcherTest, ConstructsMatcherUsingNewAPI)
 
 TEST (MatcherCastTest, FromPolymorphicMatcher)
 
bool IsPositiveIntValue (const IntValue &foo)
 
 TEST (MatcherCastTest, FromCompatibleType)
 
 TEST (MatcherCastTest, FromConstReferenceToNonReference)
 
 TEST (MatcherCastTest, FromReferenceToNonReference)
 
 TEST (MatcherCastTest, FromNonReferenceToConstReference)
 
 TEST (MatcherCastTest, FromNonReferenceToReference)
 
 TEST (MatcherCastTest, FromSameType)
 
bool operator== (const ConvertibleFromAny &a, const ConvertibleFromAny &b)
 
ostream & operator<< (ostream &os, const ConvertibleFromAny &a)
 
 TEST (MatcherCastTest, ConversionConstructorIsUsed)
 
 TEST (MatcherCastTest, FromConvertibleFromAny)
 
bool operator== (const IntReferenceWrapper &a, const IntReferenceWrapper &b)
 
 TEST (MatcherCastTest, ValueIsNotCopied)
 
 TEST (SafeMatcherCastTest, FromPolymorphicMatcher)
 
 TEST (SafeMatcherCastTest, FromLosslesslyConvertibleArithmeticType)
 
 TEST (SafeMatcherCastTest, FromBaseClass)
 
 TEST (SafeMatcherCastTest, FromConstReferenceToReference)
 
 TEST (SafeMatcherCastTest, FromNonReferenceToConstReference)
 
 TEST (SafeMatcherCastTest, FromNonReferenceToReference)
 
 TEST (SafeMatcherCastTest, FromSameType)
 
 TEST (SafeMatcherCastTest, ConversionConstructorIsUsed)
 
 TEST (SafeMatcherCastTest, FromConvertibleFromAny)
 
 TEST (SafeMatcherCastTest, ValueIsNotCopied)
 
 TEST (ExpectThat, TakesLiterals)
 
 TEST (ExpectThat, TakesFunctions)
 
 TEST (ATest, MatchesAnyValue)
 
 TEST (ATest, WorksForDerivedClass)
 
 TEST (ATest, CanDescribeSelf)
 
 TEST (AnTest, MatchesAnyValue)
 
 TEST (AnTest, CanDescribeSelf)
 
 TEST (UnderscoreTest, MatchesAnyValue)
 
 TEST (UnderscoreTest, CanDescribeSelf)
 
 TEST (EqTest, MatchesEqualValue)
 
bool operator== (const Unprintable &, const Unprintable &)
 
 TEST (EqTest, CanDescribeSelf)
 
 TEST (EqTest, IsPolymorphic)
 
 TEST (TypedEqTest, ChecksEqualityForGivenType)
 
 TEST (TypedEqTest, CanDescribeSelf)
 
 TEST (TypedEqTest, HasSpecifiedType)
 
 TEST (GeTest, ImplementsGreaterThanOrEqual)
 
 TEST (GeTest, CanDescribeSelf)
 
 TEST (GtTest, ImplementsGreaterThan)
 
 TEST (GtTest, CanDescribeSelf)
 
 TEST (LeTest, ImplementsLessThanOrEqual)
 
 TEST (LeTest, CanDescribeSelf)
 
 TEST (LtTest, ImplementsLessThan)
 
 TEST (LtTest, CanDescribeSelf)
 
 TEST (NeTest, ImplementsNotEqual)
 
 TEST (NeTest, CanDescribeSelf)
 
 TEST (IsNullTest, MatchesNullPointer)
 
 TEST (IsNullTest, LinkedPtr)
 
 TEST (IsNullTest, ReferenceToConstLinkedPtr)
 
 TEST (IsNullTest, CanDescribeSelf)
 
 TEST (NotNullTest, MatchesNonNullPointer)
 
 TEST (NotNullTest, LinkedPtr)
 
 TEST (NotNullTest, ReferenceToConstLinkedPtr)
 
 TEST (NotNullTest, CanDescribeSelf)
 
 TEST (RefTest, MatchesSameVariable)
 
 TEST (RefTest, CanDescribeSelf)
 
 TEST (RefTest, CanBeUsedAsMatcherForConstReference)
 
 TEST (RefTest, IsCovariant)
 
 TEST (RefTest, ExplainsResult)
 
 TEST (StrEqTest, MatchesEqualString)
 
 TEST (StrEqTest, CanDescribeSelf)
 
 TEST (StrNeTest, MatchesUnequalString)
 
 TEST (StrNeTest, CanDescribeSelf)
 
 TEST (StrCaseEqTest, MatchesEqualStringIgnoringCase)
 
 TEST (StrCaseEqTest, MatchesEqualStringWith0IgnoringCase)
 
 TEST (StrCaseEqTest, CanDescribeSelf)
 
 TEST (StrCaseNeTest, MatchesUnequalStringIgnoringCase)
 
 TEST (StrCaseNeTest, CanDescribeSelf)
 
 TEST (HasSubstrTest, WorksForStringClasses)
 
 TEST (HasSubstrTest, WorksForCStrings)
 
 TEST (HasSubstrTest, CanDescribeSelf)
 
 TEST (KeyTest, CanDescribeSelf)
 
 TEST (KeyTest, ExplainsResult)
 
 TEST (KeyTest, MatchesCorrectly)
 
 TEST (KeyTest, SafelyCastsInnerMatcher)
 
 TEST (KeyTest, InsideContainsUsingMap)
 
 TEST (KeyTest, InsideContainsUsingMultimap)
 
 TEST (PairTest, Typing)
 
 TEST (PairTest, CanDescribeSelf)
 
 TEST (PairTest, CanExplainMatchResultTo)
 
 TEST (PairTest, MatchesCorrectly)
 
 TEST (PairTest, SafelyCastsInnerMatchers)
 
 TEST (PairTest, InsideContainsUsingMap)
 
 TEST (StartsWithTest, MatchesStringWithGivenPrefix)
 
 TEST (StartsWithTest, CanDescribeSelf)
 
 TEST (EndsWithTest, MatchesStringWithGivenSuffix)
 
 TEST (EndsWithTest, CanDescribeSelf)
 
 TEST (MatchesRegexTest, MatchesStringMatchingGivenRegex)
 
 TEST (MatchesRegexTest, CanDescribeSelf)
 
 TEST (ContainsRegexTest, MatchesStringContainingGivenRegex)
 
 TEST (ContainsRegexTest, CanDescribeSelf)
 
 TEST (Eq2Test, MatchesEqualArguments)
 
 TEST (Eq2Test, CanDescribeSelf)
 
 TEST (Ge2Test, MatchesGreaterThanOrEqualArguments)
 
 TEST (Ge2Test, CanDescribeSelf)
 
 TEST (Gt2Test, MatchesGreaterThanArguments)
 
 TEST (Gt2Test, CanDescribeSelf)
 
 TEST (Le2Test, MatchesLessThanOrEqualArguments)
 
 TEST (Le2Test, CanDescribeSelf)
 
 TEST (Lt2Test, MatchesLessThanArguments)
 
 TEST (Lt2Test, CanDescribeSelf)
 
 TEST (Ne2Test, MatchesUnequalArguments)
 
 TEST (Ne2Test, CanDescribeSelf)
 
 TEST (NotTest, NegatesMatcher)
 
 TEST (NotTest, CanDescribeSelf)
 
 TEST (NotTest, NotMatcherSafelyCastsMonomorphicMatchers)
 
void AllOfMatches (int num, const Matcher< int > &m)
 
 TEST (AllOfTest, MatchesWhenAllMatch)
 
 TEST (AllOfTest, CanDescribeSelf)
 
 TEST (AllOfTest, CanDescribeNegation)
 
 TEST (AllOfTest, AllOfMatcherSafelyCastsMonomorphicMatchers)
 
 TEST (AllOfTest, ExplainsResult)
 
void AnyOfMatches (int num, const Matcher< int > &m)
 
 TEST (AnyOfTest, MatchesWhenAnyMatches)
 
 TEST (AnyOfTest, CanDescribeSelf)
 
 TEST (AnyOfTest, CanDescribeNegation)
 
 TEST (AnyOfTest, AnyOfMatcherSafelyCastsMonomorphicMatchers)
 
 TEST (AnyOfTest, ExplainsResult)
 
int IsPositive (double x)
 
bool ReferencesFooAndIsZero (const int &n)
 
 TEST (TrulyTest, MatchesWhatSatisfiesThePredicate)
 
 TEST (TrulyTest, CanBeUsedWithFunctor)
 
ConvertibleToBool IsNotZero (int number)
 
 TEST (TrulyTest, PredicateCanReturnAClassConvertibleToBool)
 
 TEST (TrulyTest, CanDescribeSelf)
 
 TEST (TrulyTest, WorksForByRefArguments)
 
 TEST (MatchesTest, IsSatisfiedByWhatMatchesTheMatcher)
 
 TEST (MatchesTest, WorksOnByRefArguments)
 
 TEST (MatchesTest, WorksWithMatcherOnNonRefType)
 
 TEST (ValueTest, WorksWithPolymorphicMatcher)
 
 TEST (ValueTest, WorksWithMonomorphicMatcher)
 
 TEST (ExplainMatchResultTest, WorksWithPolymorphicMatcher)
 
 TEST (ExplainMatchResultTest, WorksWithMonomorphicMatcher)
 
 MATCHER_P (Really, inner_matcher,"")
 
 TEST (ExplainMatchResultTest, WorksInsideMATCHER)
 
 TEST (AllArgsTest, WorksForTuple)
 
 TEST (AllArgsTest, WorksForNonTuple)
 
 TEST (AllArgsTest, WorksInWithClause)
 
 TEST (MatcherAssertionTest, WorksWhenMatcherIsSatisfied)
 
 TEST (MatcherAssertionTest, WorksWhenMatcherIsNotSatisfied)
 
 TEST (MatcherAssertionTest, WorksForByRefArguments)
 
 TEST (MatcherAssertionTest, WorksForMonomorphicMatcher)
 
 TEST_F (FloatTest, FloatEqApproximatelyMatchesFloats)
 
 TEST_F (FloatTest, NanSensitiveFloatEqApproximatelyMatchesFloats)
 
 TEST_F (FloatTest, FloatEqCannotMatchNaN)
 
 TEST_F (FloatTest, NanSensitiveFloatEqCanMatchNaN)
 
 TEST_F (FloatTest, FloatEqCanDescribeSelf)
 
 TEST_F (FloatTest, NanSensitiveFloatEqCanDescribeSelf)
 
 TEST_F (FloatNearTest, FloatNearMatches)
 
 TEST_F (FloatNearTest, NanSensitiveFloatNearApproximatelyMatchesFloats)
 
 TEST_F (FloatNearTest, FloatNearCanDescribeSelf)
 
 TEST_F (FloatNearTest, NanSensitiveFloatNearCanDescribeSelf)
 
 TEST_F (FloatNearTest, FloatNearCannotMatchNaN)
 
 TEST_F (FloatNearTest, NanSensitiveFloatNearCanMatchNaN)
 
 TEST_F (DoubleTest, DoubleEqApproximatelyMatchesDoubles)
 
 TEST_F (DoubleTest, NanSensitiveDoubleEqApproximatelyMatchesDoubles)
 
 TEST_F (DoubleTest, DoubleEqCannotMatchNaN)
 
 TEST_F (DoubleTest, NanSensitiveDoubleEqCanMatchNaN)
 
 TEST_F (DoubleTest, DoubleEqCanDescribeSelf)
 
 TEST_F (DoubleTest, NanSensitiveDoubleEqCanDescribeSelf)
 
 TEST_F (DoubleNearTest, DoubleNearMatches)
 
 TEST_F (DoubleNearTest, NanSensitiveDoubleNearApproximatelyMatchesDoubles)
 
 TEST_F (DoubleNearTest, DoubleNearCanDescribeSelf)
 
 TEST_F (DoubleNearTest, ExplainsResultWhenMatchFails)
 
 TEST_F (DoubleNearTest, NanSensitiveDoubleNearCanDescribeSelf)
 
 TEST_F (DoubleNearTest, DoubleNearCannotMatchNaN)
 
 TEST_F (DoubleNearTest, NanSensitiveDoubleNearCanMatchNaN)
 
 TEST (PointeeTest, RawPointer)
 
 TEST (PointeeTest, RawPointerToConst)
 
 TEST (PointeeTest, ReferenceToConstRawPointer)
 
 TEST (PointeeTest, ReferenceToNonConstRawPointer)
 
 MATCHER_P (FieldIIs, inner_matcher,"")
 
 TEST (PointeeTest, WorksWithConstPropagatingPointers)
 
 TEST (PointeeTest, NeverMatchesNull)
 
 TEST (PointeeTest, MatchesAgainstAValue)
 
 TEST (PointeeTest, CanDescribeSelf)
 
 TEST (PointeeTest, CanExplainMatchResult)
 
 TEST (PointeeTest, AlwaysExplainsPointee)
 
bool ValueIsPositive (const Uncopyable &x)
 
 MATCHER_P (UncopyableIs, inner_matcher,"")
 
 TEST (FieldTest, WorksForNonConstField)
 
 TEST (FieldTest, WorksForConstField)
 
 TEST (FieldTest, WorksForUncopyableField)
 
 TEST (FieldTest, WorksForPointerField)
 
 TEST (FieldTest, WorksForByRefArgument)
 
 TEST (FieldTest, WorksForArgumentOfSubType)
 
 TEST (FieldTest, WorksForCompatibleMatcherType)
 
 TEST (FieldTest, CanDescribeSelf)
 
 TEST (FieldTest, CanExplainMatchResult)
 
 TEST (FieldForPointerTest, WorksForPointerToConst)
 
 TEST (FieldForPointerTest, WorksForPointerToNonConst)
 
 TEST (FieldForPointerTest, WorksForReferenceToConstPointer)
 
 TEST (FieldForPointerTest, DoesNotMatchNull)
 
 TEST (FieldForPointerTest, WorksForArgumentOfSubType)
 
 TEST (FieldForPointerTest, CanDescribeSelf)
 
 TEST (FieldForPointerTest, CanExplainMatchResult)
 
 TEST (PropertyTest, WorksForNonReferenceProperty)
 
 TEST (PropertyTest, WorksForReferenceToConstProperty)
 
 TEST (PropertyTest, WorksForReferenceToNonConstProperty)
 
 TEST (PropertyTest, WorksForByValueArgument)
 
 TEST (PropertyTest, WorksForArgumentOfSubType)
 
 TEST (PropertyTest, WorksForCompatibleMatcherType)
 
 TEST (PropertyTest, CanDescribeSelf)
 
 TEST (PropertyTest, CanExplainMatchResult)
 
 TEST (PropertyForPointerTest, WorksForPointerToConst)
 
 TEST (PropertyForPointerTest, WorksForPointerToNonConst)
 
 TEST (PropertyForPointerTest, WorksForReferenceToConstPointer)
 
 TEST (PropertyForPointerTest, WorksForReferenceToNonConstProperty)
 
 TEST (PropertyForPointerTest, WorksForArgumentOfSubType)
 
 TEST (PropertyForPointerTest, CanDescribeSelf)
 
 TEST (PropertyForPointerTest, CanExplainMatchResult)
 
string IntToStringFunction (int input)
 
 TEST (ResultOfTest, WorksForFunctionPointers)
 
 TEST (ResultOfTest, CanDescribeItself)
 
int IntFunction (int input)
 
 TEST (ResultOfTest, CanExplainMatchResult)
 
 TEST (ResultOfTest, WorksForNonReferenceResults)
 
double & DoubleFunction (double &input)
 
UncopyableRefUncopyableFunction (Uncopyable &obj)
 
 TEST (ResultOfTest, WorksForReferenceToNonConstResults)
 
const stringStringFunction (const string &input)
 
 TEST (ResultOfTest, WorksForReferenceToConstResults)
 
 TEST (ResultOfTest, WorksForCompatibleMatcherTypes)
 
 TEST (ResultOfDeathTest, DiesOnNullFunctionPointers)
 
 TEST (ResultOfTest, WorksForFunctionReferences)
 
 TEST (ResultOfTest, WorksForFunctors)
 
 TEST (ResultOfTest, WorksForPolymorphicFunctors)
 
const int * ReferencingFunction (const int &n)
 
 TEST (ResultOfTest, WorksForReferencingCallables)
 
PolymorphicMatcher< DivisibleByImplDivisibleBy (int n)
 
 TEST (ExplainMatchResultTest, AllOf_False_False)
 
 TEST (ExplainMatchResultTest, AllOf_False_True)
 
 TEST (ExplainMatchResultTest, AllOf_True_False)
 
 TEST (ExplainMatchResultTest, AllOf_True_True)
 
 TEST (ExplainMatchResultTest, AllOf_True_True_2)
 
 TEST (ExplainmatcherResultTest, MonomorphicMatcher)
 
 TEST (ByRefTest, AllowsNotCopyableConstValueInMatchers)
 
 TEST (ByRefTest, AllowsNotCopyableValueInMatchers)
 
 TEST (IsEmptyTest, ImplementsIsEmpty)
 
 TEST (IsEmptyTest, WorksWithString)
 
 TEST (IsEmptyTest, CanDescribeSelf)
 
 TEST (IsEmptyTest, ExplainsResult)
 
 TEST (SizeIsTest, ImplementsSizeIs)
 
 TEST (SizeIsTest, WorksWithMap)
 
 TEST (SizeIsTest, WorksWithReferences)
 
 TEST (SizeIsTest, CanDescribeSelf)
 
 TEST (SizeIsTest, ExplainsResult)
 
 TEST (ContainerEqExtraTest, MultipleValuesMissing)
 
 TEST (ContainerEqExtraTest, MultipleValuesAdded)
 
 TEST (ContainerEqExtraTest, MultipleValuesAddedAndRemoved)
 
 TEST (ContainerEqExtraTest, MultiSetOfIntDuplicateDifference)
 
 TEST (ContainerEqExtraTest, WorksForMaps)
 
 TEST (ContainerEqExtraTest, WorksForNativeArray)
 
 TEST (ContainerEqExtraTest, WorksForTwoDimensionalNativeArray)
 
 TEST (ContainerEqExtraTest, WorksForNativeArrayAsTuple)
 
 TEST (ContainerEqExtraTest, CopiesNativeArrayParameter)
 
 TEST (WhenSortedByTest, WorksForEmptyContainer)
 
 TEST (WhenSortedByTest, WorksForNonEmptyContainer)
 
 TEST (WhenSortedByTest, WorksForNonVectorContainer)
 
 TEST (WhenSortedByTest, WorksForNativeArray)
 
 TEST (WhenSortedByTest, CanDescribeSelf)
 
 TEST (WhenSortedByTest, ExplainsMatchResult)
 
 TEST (WhenSortedTest, WorksForEmptyContainer)
 
 TEST (WhenSortedTest, WorksForNonEmptyContainer)
 
 TEST (WhenSortedTest, WorksForMapTypes)
 
 TEST (WhenSortedTest, WorksForMultiMapTypes)
 
 TEST (WhenSortedTest, WorksForPolymorphicMatcher)
 
 TEST (WhenSortedTest, WorksForVectorConstRefMatcher)
 
 TEST (StreamlikeTest, Iteration)
 
 TEST (BeginEndDistanceIsTest, WorksWithNonStdList)
 
 TEST (BeginEndDistanceIsTest, CanDescribeSelf)
 
 TEST (BeginEndDistanceIsTest, ExplainsResult)
 
 TEST (WhenSortedTest, WorksForStreamlike)
 
 TEST (WhenSortedTest, WorksForVectorConstRefMatcherOnStreamlike)
 
 TEST (ElemensAreStreamTest, WorksForStreamlike)
 
 TEST (ElemensAreArrayStreamTest, WorksForStreamlike)
 
 TEST (ElementsAreTest, WorksWithUncopyable)
 
 TEST (ElementsAreTest, TakesStlContainer)
 
 TEST (UnorderedElementsAreArrayTest, SucceedsWhenExpected)
 
 TEST (UnorderedElementsAreArrayTest, VectorBool)
 
 TEST (UnorderedElementsAreArrayTest, WorksForStreamlike)
 
 TEST (UnorderedElementsAreArrayTest, TakesStlContainer)
 
 TEST_F (UnorderedElementsAreTest, WorksWithUncopyable)
 
 TEST_F (UnorderedElementsAreTest, SucceedsWhenExpected)
 
 TEST_F (UnorderedElementsAreTest, FailsWhenAnElementMatchesNoMatcher)
 
 TEST_F (UnorderedElementsAreTest, WorksForStreamlike)
 
 TEST_F (UnorderedElementsAreTest, Performance)
 
 TEST_F (UnorderedElementsAreTest, PerformanceHalfStrict)
 
 TEST_F (UnorderedElementsAreTest, FailMessageCountWrong)
 
 TEST_F (UnorderedElementsAreTest, FailMessageCountWrongZero)
 
 TEST_F (UnorderedElementsAreTest, FailMessageUnmatchedMatchers)
 
 TEST_F (UnorderedElementsAreTest, FailMessageUnmatchedElements)
 
 TEST_F (UnorderedElementsAreTest, FailMessageUnmatchedMatcherAndElement)
 
static string EMString (int element, int matcher)
 
 TEST_F (UnorderedElementsAreTest, FailMessageImperfectMatchOnly)
 
 TEST_F (UnorderedElementsAreTest, Describe)
 
 TEST_F (UnorderedElementsAreTest, DescribeNegation)
 
template<typename Graph >
ElementMatcherPairs FindBacktrackingMaxBPM (const Graph &g)
 
 TEST_P (BipartiteTest, Exhaustive)
 
 INSTANTIATE_TEST_CASE_P (AllGraphs, BipartiteTest,::testing::Range(0, 5))
 
 TEST_F (BipartiteNonSquareTest, SimpleBacktracking)
 
 TEST_P (BipartiteNonSquareTest, Exhaustive)
 
 INSTANTIATE_TEST_CASE_P (AllGraphs, BipartiteNonSquareTest, testing::Values(std::make_pair(1, 2), std::make_pair(2, 1), std::make_pair(3, 2), std::make_pair(2, 3), std::make_pair(4, 1), std::make_pair(1, 4), std::make_pair(4, 3), std::make_pair(3, 4)))
 
 TEST_P (BipartiteRandomTest, LargerNets)
 
 INSTANTIATE_TEST_CASE_P (Samples, BipartiteRandomTest, testing::Values(std::make_pair(5, 10000), std::make_pair(6, 5000), std::make_pair(7, 2000), std::make_pair(8, 500), std::make_pair(9, 100)))
 
 TEST (IsReadableTypeNameTest, ReturnsTrueForShortNames)
 
 TEST (IsReadableTypeNameTest, ReturnsTrueForLongNonTemplateNonFunctionNames)
 
 TEST (IsReadableTypeNameTest, ReturnsFalseForLongTemplateNames)
 
 TEST (IsReadableTypeNameTest, ReturnsFalseForLongFunctionTypeNames)
 
 TEST (JoinAsTupleTest, JoinsEmptyTuple)
 
 TEST (JoinAsTupleTest, JoinsOneTuple)
 
 TEST (JoinAsTupleTest, JoinsTwoTuple)
 
 TEST (JoinAsTupleTest, JoinsTenTuple)
 
 TEST (FormatMatcherDescriptionTest, WorksForEmptyDescription)
 
 TEST (PolymorphicMatcherTest, CanAccessMutableImpl)
 
 TEST (PolymorphicMatcherTest, CanAccessImpl)
 
 TEST (MatcherTupleTest, ExplainsMatchFailure)
 
 TEST (EachTest, ExplainsMatchResultCorrectly)
 
 TEST (EachTest, DescribesItselfCorrectly)
 
 TEST (EachTest, MatchesVectorWhenAllElementsMatch)
 
 TEST (EachTest, MatchesMapWhenAllElementsMatch)
 
 TEST (EachTest, AcceptsMatcher)
 
 TEST (EachTest, WorksForNativeArrayAsTuple)
 
PolymorphicMatcher< IsHalfOfMatcherIsHalfOf ()
 
 TEST (PointwiseTest, DescribesSelf)
 
 TEST (PointwiseTest, MakesCopyOfRhs)
 
 TEST (PointwiseTest, WorksForLhsNativeArray)
 
 TEST (PointwiseTest, WorksForRhsNativeArray)
 
 TEST (PointwiseTest, RejectsWrongSize)
 
 TEST (PointwiseTest, RejectsWrongContent)
 
 TEST (PointwiseTest, AcceptsCorrectContent)
 
 TEST (PointwiseTest, AllowsMonomorphicInnerMatcher)
 
 TEST (UnorderedPointwiseTest, DescribesSelf)
 
 TEST (UnorderedPointwiseTest, MakesCopyOfRhs)
 
 TEST (UnorderedPointwiseTest, WorksForLhsNativeArray)
 
 TEST (UnorderedPointwiseTest, WorksForRhsNativeArray)
 
 TEST (UnorderedPointwiseTest, RejectsWrongSize)
 
 TEST (UnorderedPointwiseTest, RejectsWrongContent)
 
 TEST (UnorderedPointwiseTest, AcceptsCorrectContentInSameOrder)
 
 TEST (UnorderedPointwiseTest, AcceptsCorrectContentInDifferentOrder)
 
 TEST (UnorderedPointwiseTest, AllowsMonomorphicInnerMatcher)
 
static string EMString (int element, int matcher)
 
static string EMString (int element, int matcher)
 

Variables

const int g_bar = 1
 
const int foo = 0
 

Typedef Documentation

typedef::testing::tuple< long, int > testing::gmock_matchers_test::Tuple2

Definition at line 1930 of file gmock-matchers_test.cc.

Function Documentation

void testing::gmock_matchers_test::AllOfMatches ( int  num,
const Matcher< int > &  m 
)

Definition at line 2046 of file gmock-matchers_test.cc.

References Describe(), EXPECT_FALSE, EXPECT_TRUE, i, testing::internal::MatcherBase< T >::Matches(), and SCOPED_TRACE.

Referenced by testing::gmock_matchers_test::Type< T >::IsTypeOf(), and TEST().

2046  {
2048  EXPECT_TRUE(m.Matches(0));
2049  for (int i = 1; i <= num; ++i) {
2050  EXPECT_FALSE(m.Matches(i));
2051  }
2052  EXPECT_TRUE(m.Matches(num + 1));
2053 }
string Describe(const Matcher< T > &m)
#define SCOPED_TRACE(message)
Definition: gtest.h:2115
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
void testing::gmock_matchers_test::AnyOfMatches ( int  num,
const Matcher< int > &  m 
)

Definition at line 2244 of file gmock-matchers_test.cc.

References Describe(), EXPECT_FALSE, EXPECT_TRUE, i, testing::internal::MatcherBase< T >::Matches(), and SCOPED_TRACE.

Referenced by testing::gmock_matchers_test::Type< T >::IsTypeOf(), and TEST().

2244  {
2246  EXPECT_FALSE(m.Matches(0));
2247  for (int i = 1; i <= num; ++i) {
2248  EXPECT_TRUE(m.Matches(i));
2249  }
2250  EXPECT_FALSE(m.Matches(num + 1));
2251 }
string Describe(const Matcher< T > &m)
#define SCOPED_TRACE(message)
Definition: gtest.h:2115
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
PolymorphicMatcher< DivisibleByImpl > testing::gmock_matchers_test::DivisibleBy ( int  n)

Definition at line 3990 of file gmock-matchers_test.cc.

References testing::MakePolymorphicMatcher().

Referenced by testing::gmock_matchers_test::DivisibleByImpl::divider(), and TEST().

3990  {
3991  return MakePolymorphicMatcher(DivisibleByImpl(n));
3992 }
PolymorphicMatcher< Impl > MakePolymorphicMatcher(const Impl &impl)
double & testing::gmock_matchers_test::DoubleFunction ( double &  input)

Definition at line 3845 of file gmock-matchers_test.cc.

Referenced by testing::gmock_matchers_test::DerivedClass::k(), and TEST().

3845 { return input; } // NOLINT
static string testing::gmock_matchers_test::EMString ( int  element,
int  matcher 
)
static

Definition at line 4940 of file gmock-matchers_test.cc.

4940  {
4941  stringstream ss;
4942  ss << "(element #" << element << ", matcher #" << matcher << ")";
4943  return ss.str();
4944 }
static string testing::gmock_matchers_test::EMString ( int  element,
int  matcher 
)
static

Definition at line 4940 of file gmock-matchers_test.cc.

References testing::AnyOf(), best_so_far_, Describe(), DescribeNegation(), EMString(), testing::Eq(), EXPECT_FALSE, EXPECT_THAT, testing::ExplainMatchResult(), g(), graph_, kUnused, lhs_used_, matches_, prefix(), rhs_used_, testing::StringMatchResultListener::str(), testing::internal::TEST_F(), testing::UnorderedElementsAre(), and v.

4940  {
4941  stringstream ss;
4942  ss << "(element #" << element << ", matcher #" << matcher << ")";
4943  return ss.str();
4944 }
static string testing::gmock_matchers_test::EMString ( int  element,
int  matcher 
)
static

Definition at line 4940 of file gmock-matchers_test.cc.

References testing::AnyOf(), best_so_far_, Describe(), DescribeNegation(), testing::Eq(), EXPECT_FALSE, EXPECT_THAT, testing::ExplainMatchResult(), g(), graph_, kUnused, lhs_used_, matches_, prefix(), rhs_used_, testing::StringMatchResultListener::str(), testing::internal::TEST_F(), testing::UnorderedElementsAre(), and v.

Referenced by EMString(), and TEST_F().

4940  {
4941  stringstream ss;
4942  ss << "(element #" << element << ", matcher #" << matcher << ")";
4943  return ss.str();
4944 }
template<typename Graph >
ElementMatcherPairs testing::gmock_matchers_test::FindBacktrackingMaxBPM ( const Graph &  g)

Definition at line 5091 of file gmock-matchers_test.cc.

References g().

Referenced by TEST_F(), and TEST_P().

5091  {
5092  return BacktrackingMaxBPMState<Graph>(&g).Compute();
5093 }
g_t g(f_t)
testing::gmock_matchers_test::INSTANTIATE_TEST_CASE_P ( AllGraphs  ,
BipartiteTest  ,
::testing::Range(0, 5)   
)
testing::gmock_matchers_test::INSTANTIATE_TEST_CASE_P ( AllGraphs  ,
BipartiteNonSquareTest  ,
testing::Values(std::make_pair(1, 2), std::make_pair(2, 1), std::make_pair(3, 2), std::make_pair(2, 3), std::make_pair(4, 1), std::make_pair(1, 4), std::make_pair(4, 3), std::make_pair(3, 4))   
)
testing::gmock_matchers_test::INSTANTIATE_TEST_CASE_P ( Samples  ,
BipartiteRandomTest  ,
testing::Values(std::make_pair(5, 10000), std::make_pair(6, 5000), std::make_pair(7, 2000), std::make_pair(8, 500), std::make_pair(9, 100))   
)
int testing::gmock_matchers_test::IntFunction ( int  input)

Definition at line 3822 of file gmock-matchers_test.cc.

Referenced by testing::gmock_matchers_test::DerivedClass::k(), and TEST().

3822 { return input == 42 ? 80 : 90; }
string testing::gmock_matchers_test::IntToStringFunction ( int  input)

Definition at line 3802 of file gmock-matchers_test.cc.

Referenced by testing::gmock_matchers_test::DerivedClass::k(), testing::gmock_matchers_test::Functor::operator()(), and TEST().

3802 { return input == 1 ? "foo" : "bar"; }
PolymorphicMatcher< IsHalfOfMatcher > testing::gmock_matchers_test::IsHalfOf ( )

Definition at line 5433 of file gmock-matchers_test.cc.

References testing::MakePolymorphicMatcher().

Referenced by testing::gmock_matchers_test::IsHalfOfMatcher::DescribeNegationTo(), and TEST().

5433  {
5434  return MakePolymorphicMatcher(IsHalfOfMatcher());
5435 }
PolymorphicMatcher< Impl > MakePolymorphicMatcher(const Impl &impl)
ConvertibleToBool testing::gmock_matchers_test::IsNotZero ( int  number)

Definition at line 2485 of file gmock-matchers_test.cc.

Referenced by testing::gmock_matchers_test::ConvertibleToBool::operator bool(), and TEST().

2485  {
2486  return ConvertibleToBool(number);
2487 }
int number
int testing::gmock_matchers_test::IsPositive ( double  x)
bool testing::gmock_matchers_test::IsPositiveIntValue ( const IntValue foo)

Definition at line 549 of file gmock-matchers_test.cc.

References testing::gmock_matchers_test::IntValue::value().

Referenced by TEST(), and testing::gmock_matchers_test::IntValue::value().

549  {
550  return foo.value() > 0;
551 }
testing::gmock_matchers_test::MATCHER_P ( Really  ,
inner_matcher  ,
""   
)

Definition at line 2578 of file gmock-matchers_test.cc.

References testing::ExplainMatchResult().

2578  {
2579  return ExplainMatchResult(inner_matcher, arg, result_listener);
2580 }
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
testing::gmock_matchers_test::MATCHER_P ( FieldIIs  ,
inner_matcher  ,
""   
)
testing::gmock_matchers_test::MATCHER_P ( UncopyableIs  ,
inner_matcher  ,
""   
)

Definition at line 3373 of file gmock-matchers_test.cc.

References testing::ExplainMatchResult().

Referenced by testing::gmock_matchers_test::ConvertibleToBool::operator bool(), testing::gmock_matchers_test::Uncopyable::set_value(), and testing::gmock_matchers_test::FloatingPointNearTest< RawType >::TestNearMatches().

3373  {
3374  return ExplainMatchResult(inner_matcher, arg.value(), result_listener);
3375 }
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
string testing::gmock_matchers_test::OfType ( const string type_name)
ostream & testing::gmock_matchers_test::operator<< ( ostream &  os,
const ConvertibleFromAny a 
)

Definition at line 626 of file gmock-matchers_test.cc.

References testing::gmock_matchers_test::ConvertibleFromAny::value.

626  {
627  return os << a.value;
628 }
char a
bool testing::gmock_matchers_test::operator== ( const ConvertibleFromAny a,
const ConvertibleFromAny b 
)

Definition at line 622 of file gmock-matchers_test.cc.

References testing::gmock_matchers_test::ConvertibleFromAny::value.

622  {
623  return a.value == b.value;
624 }
char b
char a
bool testing::gmock_matchers_test::operator== ( const IntReferenceWrapper a,
const IntReferenceWrapper b 
)

Definition at line 648 of file gmock-matchers_test.cc.

References testing::gmock_matchers_test::IntReferenceWrapper::value.

648  {
649  return a.value == b.value;
650 }
char b
char a
bool testing::gmock_matchers_test::operator== ( const Unprintable ,
const Unprintable  
)
inline

Definition at line 874 of file gmock-matchers_test.cc.

875  {
876  return true;
877 }
PolymorphicMatcher< PolymorphicIsEvenImpl > testing::gmock_matchers_test::PolymorphicIsEven ( )

Definition at line 501 of file gmock-matchers_test.cc.

References testing::MakePolymorphicMatcher().

Referenced by testing::gmock_matchers_test::PolymorphicIsEvenImpl::MatchAndExplain(), testing::gmock_matchers_test::ConvertibleToBool::operator bool(), and TEST().

501  {
502  return MakePolymorphicMatcher(PolymorphicIsEvenImpl());
503 }
PolymorphicMatcher< Impl > MakePolymorphicMatcher(const Impl &impl)
PolymorphicMatcher< ReferencesBarOrIsZeroImpl > testing::gmock_matchers_test::ReferencesBarOrIsZero ( )

Definition at line 458 of file gmock-matchers_test.cc.

References testing::MakePolymorphicMatcher().

Referenced by testing::gmock_matchers_test::ReferencesBarOrIsZeroImpl::DescribeNegationTo(), and TEST().

458  {
459  return MakePolymorphicMatcher(ReferencesBarOrIsZeroImpl());
460 }
PolymorphicMatcher< Impl > MakePolymorphicMatcher(const Impl &impl)
bool testing::gmock_matchers_test::ReferencesFooAndIsZero ( const int &  n)
const int * testing::gmock_matchers_test::ReferencingFunction ( const int &  n)
Uncopyable & testing::gmock_matchers_test::RefUncopyableFunction ( Uncopyable obj)

Definition at line 3847 of file gmock-matchers_test.cc.

Referenced by testing::gmock_matchers_test::DerivedClass::k(), and TEST().

3847  { // NOLINT
3848  return obj;
3849 }
const string & testing::gmock_matchers_test::StringFunction ( const string input)

Definition at line 3871 of file gmock-matchers_test.cc.

Referenced by testing::gmock_matchers_test::DerivedClass::k(), and TEST().

3871 { return input; }
testing::gmock_matchers_test::TEST ( MatchResultListenerTest  ,
StreamingWorks   
)

Definition at line 224 of file gmock-matchers_test.cc.

References testing::StringMatchResultListener::Clear(), dummy(), EXPECT_EQ, and testing::StringMatchResultListener::str().

224  {
225  StringMatchResultListener listener;
226  listener << "hi" << 5;
227  EXPECT_EQ("hi5", listener.str());
228 
229  listener.Clear();
230  EXPECT_EQ("", listener.str());
231 
232  listener << 42;
233  EXPECT_EQ("42", listener.str());
234 
235  // Streaming shouldn't crash when the underlying ostream is NULL.
236  DummyMatchResultListener dummy;
237  dummy << "hi" << 5;
238 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void dummy()
testing::gmock_matchers_test::TEST ( MatchResultListenerTest  ,
CanAccessUnderlyingStream   
)

Definition at line 240 of file gmock-matchers_test.cc.

References EXPECT_EQ, EXPECT_TRUE, and stream.

240  {
241  EXPECT_TRUE(DummyMatchResultListener().stream() == NULL);
242  EXPECT_TRUE(StreamMatchResultListener(NULL).stream() == NULL);
243 
244  EXPECT_EQ(&std::cout, StreamMatchResultListener(&std::cout).stream());
245 }
StreamCodecFactory stream
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
testing::gmock_matchers_test::TEST ( MatchResultListenerTest  ,
IsInterestedWorks   
)

Definition at line 247 of file gmock-matchers_test.cc.

References EXPECT_FALSE, and EXPECT_TRUE.

247  {
248  EXPECT_TRUE(StringMatchResultListener().IsInterested());
249  EXPECT_TRUE(StreamMatchResultListener(&std::cout).IsInterested());
250 
251  EXPECT_FALSE(DummyMatchResultListener().IsInterested());
252  EXPECT_FALSE(StreamMatchResultListener(NULL).IsInterested());
253 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherInterfaceTest  ,
CanBeImplementedUsingPublishedAPI   
)

Definition at line 274 of file gmock-matchers_test.cc.

References m.

274  {
275  EvenMatcherImpl m;
276 }
static map< string, int > m
testing::gmock_matchers_test::TEST ( MatcherInterfaceTest  ,
CanBeImplementedUsingNewAPI   
)

Definition at line 299 of file gmock-matchers_test.cc.

References EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, Explain(), m, testing::MakeMatcher(), and testing::internal::MatcherBase< T >::Matches().

299  {
300  Matcher<int> m = MakeMatcher(new NewEvenMatcherImpl);
301  EXPECT_TRUE(m.Matches(2));
302  EXPECT_FALSE(m.Matches(3));
303  EXPECT_EQ("value % 2 == 0", Explain(m, 2));
304  EXPECT_EQ("value % 2 == 1", Explain(m, 3));
305 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
Matcher< T > MakeMatcher(const MatcherInterface< T > *impl)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherTest  ,
CanBeDefaultConstructed   
)

Definition at line 308 of file gmock-matchers_test.cc.

References m.

308  {
309  Matcher<double> m;
310 }
static map< string, int > m
testing::gmock_matchers_test::TEST ( MatcherTest  ,
CanBeConstructedFromMatcherInterface   
)

Definition at line 313 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, and testing::internal::MatcherBase< T >::Matches().

313  {
314  const MatcherInterface<int>* impl = new EvenMatcherImpl;
315  Matcher<int> m(impl);
316  EXPECT_TRUE(m.Matches(4));
317  EXPECT_FALSE(m.Matches(5));
318 }
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherTest  ,
CanBeImplicitlyConstructedFromValue   
)

Definition at line 321 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

321  {
322  Matcher<int> m1 = 5;
323  EXPECT_TRUE(m1.Matches(5));
324  EXPECT_FALSE(m1.Matches(6));
325 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherTest  ,
CanBeImplicitlyConstructedFromNULL   
)

Definition at line 328 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

328  {
329  Matcher<int*> m1 = NULL;
330  EXPECT_TRUE(m1.Matches(NULL));
331  int n = 0;
332  EXPECT_FALSE(m1.Matches(&n));
333 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherTest  ,
IsCopyable   
)

Definition at line 336 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

336  {
337  // Tests the copy constructor.
338  Matcher<bool> m1 = Eq(false);
339  EXPECT_TRUE(m1.Matches(false));
340  EXPECT_FALSE(m1.Matches(true));
341 
342  // Tests the assignment operator.
343  m1 = Eq(true);
344  EXPECT_TRUE(m1.Matches(true));
345  EXPECT_FALSE(m1.Matches(false));
346 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherTest  ,
CanDescribeItself   
)

Definition at line 350 of file gmock-matchers_test.cc.

References Describe(), and EXPECT_EQ.

350  {
351  EXPECT_EQ("is an even number",
352  Describe(Matcher<int>(new EvenMatcherImpl)));
353 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
testing::gmock_matchers_test::TEST ( MatcherTest  ,
MatchAndExplain   
)

Definition at line 356 of file gmock-matchers_test.cc.

References EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, GreaterThan(), m, testing::internal::MatcherBase< T >::MatchAndExplain(), and testing::StringMatchResultListener::str().

356  {
357  Matcher<int> m = GreaterThan(0);
358  StringMatchResultListener listener1;
359  EXPECT_TRUE(m.MatchAndExplain(42, &listener1));
360  EXPECT_EQ("which is 42 more than 0", listener1.str());
361 
362  StringMatchResultListener listener2;
363  EXPECT_FALSE(m.MatchAndExplain(-9, &listener2));
364  EXPECT_EQ("which is 9 less than 0", listener2.str());
365 }
Matcher< int > GreaterThan(int n)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( StringMatcherTest  ,
CanBeImplicitlyConstructedFromCStringLiteral   
)

Definition at line 369 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

369  {
370  Matcher<string> m1 = "hi";
371  EXPECT_TRUE(m1.Matches("hi"));
372  EXPECT_FALSE(m1.Matches("hello"));
373 
374  Matcher<const string&> m2 = "hi";
375  EXPECT_TRUE(m2.Matches("hi"));
376  EXPECT_FALSE(m2.Matches("hello"));
377 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( StringMatcherTest  ,
CanBeImplicitlyConstructedFromString   
)

Definition at line 381 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), and testing::internal::TEST().

381  {
382  Matcher<string> m1 = string("hi");
383  EXPECT_TRUE(m1.Matches("hi"));
384  EXPECT_FALSE(m1.Matches("hello"));
385 
386  Matcher<const string&> m2 = string("hi");
387  EXPECT_TRUE(m2.Matches("hi"));
388  EXPECT_FALSE(m2.Matches("hello"));
389 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
const char * string
Definition: Conv.cpp:212
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MakeMatcherTest  ,
ConstructsMatcherFromMatcherInterface   
)

Definition at line 432 of file gmock-matchers_test.cc.

References m, and testing::MakeMatcher().

432  {
433  const MatcherInterface<int>* dummy_impl = NULL;
434  Matcher<int> m = MakeMatcher(dummy_impl);
435 }
Matcher< T > MakeMatcher(const MatcherInterface< T > *impl)
static map< string, int > m
testing::gmock_matchers_test::TEST ( MakePolymorphicMatcherTest  ,
ConstructsMatcherUsingOldAPI   
)

Definition at line 462 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), and ReferencesBarOrIsZero().

462  {
463  // Using a polymorphic matcher to match a reference type.
464  Matcher<const int&> m1 = ReferencesBarOrIsZero();
465  EXPECT_TRUE(m1.Matches(0));
466  // Verifies that the identity of a by-reference argument is preserved.
467  EXPECT_TRUE(m1.Matches(g_bar));
468  EXPECT_FALSE(m1.Matches(1));
469  EXPECT_EQ("g_bar or zero", Describe(m1));
470 
471  // Using a polymorphic matcher to match a value type.
472  Matcher<double> m2 = ReferencesBarOrIsZero();
473  EXPECT_TRUE(m2.Matches(0.0));
474  EXPECT_FALSE(m2.Matches(0.1));
475  EXPECT_EQ("g_bar or zero", Describe(m2));
476 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicMatcher< ReferencesBarOrIsZeroImpl > ReferencesBarOrIsZero()
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MakePolymorphicMatcherTest  ,
ConstructsMatcherUsingNewAPI   
)

Definition at line 505 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, Explain(), testing::internal::MatcherBase< T >::Matches(), testing::Not(), and PolymorphicIsEven().

505  {
506  // Using PolymorphicIsEven() as a Matcher<int>.
507  const Matcher<int> m1 = PolymorphicIsEven();
508  EXPECT_TRUE(m1.Matches(42));
509  EXPECT_FALSE(m1.Matches(43));
510  EXPECT_EQ("is even", Describe(m1));
511 
512  const Matcher<int> not_m1 = Not(m1);
513  EXPECT_EQ("is odd", Describe(not_m1));
514 
515  EXPECT_EQ("% 2 == 0", Explain(m1, 42));
516 
517  // Using PolymorphicIsEven() as a Matcher<char>.
518  const Matcher<char> m2 = PolymorphicIsEven();
519  EXPECT_TRUE(m2.Matches('\x42'));
520  EXPECT_FALSE(m2.Matches('\x43'));
521  EXPECT_EQ("is even", Describe(m2));
522 
523  const Matcher<char> not_m2 = Not(m2);
524  EXPECT_EQ("is odd", Describe(not_m2));
525 
526  EXPECT_EQ("% 2 == 0", Explain(m2, '\x42'));
527 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
PolymorphicMatcher< PolymorphicIsEvenImpl > PolymorphicIsEven()
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherCastTest  ,
FromPolymorphicMatcher   
)

Definition at line 530 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, m, and testing::internal::MatcherBase< T >::Matches().

530  {
531  Matcher<int> m = MatcherCast<int>(Eq(5));
532  EXPECT_TRUE(m.Matches(5));
533  EXPECT_FALSE(m.Matches(6));
534 }
internal::EqMatcher< T > Eq(T x)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherCastTest  ,
FromCompatibleType   
)

Definition at line 555 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, IsPositiveIntValue(), testing::internal::MatcherBase< T >::Matches(), and testing::Truly().

555  {
556  Matcher<double> m1 = Eq(2.0);
557  Matcher<int> m2 = MatcherCast<int>(m1);
558  EXPECT_TRUE(m2.Matches(2));
559  EXPECT_FALSE(m2.Matches(3));
560 
561  Matcher<IntValue> m3 = Truly(IsPositiveIntValue);
562  Matcher<int> m4 = MatcherCast<int>(m3);
563  // In the following, the arguments 1 and 0 are statically converted
564  // to IntValue objects, and then tested by the IsPositiveIntValue()
565  // predicate.
566  EXPECT_TRUE(m4.Matches(1));
567  EXPECT_FALSE(m4.Matches(0));
568 }
internal::EqMatcher< T > Eq(T x)
bool IsPositiveIntValue(const IntValue &foo)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
PolymorphicMatcher< internal::TrulyMatcher< Predicate > > Truly(Predicate pred)
testing::gmock_matchers_test::TEST ( MatcherCastTest  ,
FromConstReferenceToNonReference   
)

Definition at line 571 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

571  {
572  Matcher<const int&> m1 = Eq(0);
573  Matcher<int> m2 = MatcherCast<int>(m1);
574  EXPECT_TRUE(m2.Matches(0));
575  EXPECT_FALSE(m2.Matches(1));
576 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherCastTest  ,
FromReferenceToNonReference   
)

Definition at line 579 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

579  {
580  Matcher<int&> m1 = Eq(0);
581  Matcher<int> m2 = MatcherCast<int>(m1);
582  EXPECT_TRUE(m2.Matches(0));
583  EXPECT_FALSE(m2.Matches(1));
584 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherCastTest  ,
FromNonReferenceToConstReference   
)

Definition at line 587 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

587  {
588  Matcher<int> m1 = Eq(0);
589  Matcher<const int&> m2 = MatcherCast<const int&>(m1);
590  EXPECT_TRUE(m2.Matches(0));
591  EXPECT_FALSE(m2.Matches(1));
592 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherCastTest  ,
FromNonReferenceToReference   
)

Definition at line 595 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

595  {
596  Matcher<int> m1 = Eq(0);
597  Matcher<int&> m2 = MatcherCast<int&>(m1);
598  int n = 0;
599  EXPECT_TRUE(m2.Matches(n));
600  n = 1;
601  EXPECT_FALSE(m2.Matches(n));
602 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherCastTest  ,
FromSameType   
)

Definition at line 605 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

605  {
606  Matcher<int> m1 = Eq(0);
607  Matcher<int> m2 = MatcherCast<int>(m1);
608  EXPECT_TRUE(m2.Matches(0));
609  EXPECT_FALSE(m2.Matches(1));
610 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherCastTest  ,
ConversionConstructorIsUsed   
)

Definition at line 630 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, and testing::internal::MatcherBase< T >::Matches().

630  {
631  Matcher<ConvertibleFromAny> m = MatcherCast<ConvertibleFromAny>(1);
632  EXPECT_TRUE(m.Matches(ConvertibleFromAny(1)));
633  EXPECT_FALSE(m.Matches(ConvertibleFromAny(2)));
634 }
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherCastTest  ,
FromConvertibleFromAny   
)

Definition at line 636 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, m, and testing::internal::MatcherBase< T >::Matches().

636  {
637  Matcher<ConvertibleFromAny> m =
638  MatcherCast<ConvertibleFromAny>(Eq(ConvertibleFromAny(1)));
639  EXPECT_TRUE(m.Matches(ConvertibleFromAny(1)));
640  EXPECT_FALSE(m.Matches(ConvertibleFromAny(2)));
641 }
internal::EqMatcher< T > Eq(T x)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatcherCastTest  ,
ValueIsNotCopied   
)

Definition at line 652 of file gmock-matchers_test.cc.

References EXPECT_TRUE, m, and testing::internal::MatcherBase< T >::Matches().

652  {
653  int n = 42;
654  Matcher<IntReferenceWrapper> m = MatcherCast<IntReferenceWrapper>(n);
655  // Verify that the matcher holds a reference to n, not to its temporary copy.
656  EXPECT_TRUE(m.Matches(n));
657 }
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
testing::gmock_matchers_test::TEST ( SafeMatcherCastTest  ,
FromPolymorphicMatcher   
)

Definition at line 676 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

676  {
677  Matcher<char> m2 = SafeMatcherCast<char>(Eq(32));
678  EXPECT_TRUE(m2.Matches(' '));
679  EXPECT_FALSE(m2.Matches('\n'));
680 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( SafeMatcherCastTest  ,
FromLosslesslyConvertibleArithmeticType   
)

Definition at line 685 of file gmock-matchers_test.cc.

References testing::DoubleEq(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

685  {
686  Matcher<double> m1 = DoubleEq(1.0);
687  Matcher<float> m2 = SafeMatcherCast<float>(m1);
688  EXPECT_TRUE(m2.Matches(1.0f));
689  EXPECT_FALSE(m2.Matches(2.0f));
690 
691  Matcher<char> m3 = SafeMatcherCast<char>(TypedEq<int>('a'));
692  EXPECT_TRUE(m3.Matches('a'));
693  EXPECT_FALSE(m3.Matches('b'));
694 }
internal::FloatingEqMatcher< double > DoubleEq(double rhs)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( SafeMatcherCastTest  ,
FromBaseClass   
)

Definition at line 698 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), and testing::Ref().

698  {
699  Derived d, d2;
700  Matcher<Base*> m1 = Eq(&d);
701  Matcher<Derived*> m2 = SafeMatcherCast<Derived*>(m1);
702  EXPECT_TRUE(m2.Matches(&d));
703  EXPECT_FALSE(m2.Matches(&d2));
704 
705  Matcher<Base&> m3 = Ref(d);
706  Matcher<Derived&> m4 = SafeMatcherCast<Derived&>(m3);
707  EXPECT_TRUE(m4.Matches(d));
708  EXPECT_FALSE(m4.Matches(d2));
709 }
internal::EqMatcher< T > Eq(T x)
internal::RefMatcher< T & > Ref(T &x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( SafeMatcherCastTest  ,
FromConstReferenceToReference   
)

Definition at line 712 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), and testing::Ref().

712  {
713  int n = 0;
714  Matcher<const int&> m1 = Ref(n);
715  Matcher<int&> m2 = SafeMatcherCast<int&>(m1);
716  int n1 = 0;
717  EXPECT_TRUE(m2.Matches(n));
718  EXPECT_FALSE(m2.Matches(n1));
719 }
internal::RefMatcher< T & > Ref(T &x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( SafeMatcherCastTest  ,
FromNonReferenceToConstReference   
)

Definition at line 722 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

722  {
723  Matcher<int> m1 = Eq(0);
724  Matcher<const int&> m2 = SafeMatcherCast<const int&>(m1);
725  EXPECT_TRUE(m2.Matches(0));
726  EXPECT_FALSE(m2.Matches(1));
727 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( SafeMatcherCastTest  ,
FromNonReferenceToReference   
)

Definition at line 730 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

730  {
731  Matcher<int> m1 = Eq(0);
732  Matcher<int&> m2 = SafeMatcherCast<int&>(m1);
733  int n = 0;
734  EXPECT_TRUE(m2.Matches(n));
735  n = 1;
736  EXPECT_FALSE(m2.Matches(n));
737 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( SafeMatcherCastTest  ,
FromSameType   
)

Definition at line 740 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

740  {
741  Matcher<int> m1 = Eq(0);
742  Matcher<int> m2 = SafeMatcherCast<int>(m1);
743  EXPECT_TRUE(m2.Matches(0));
744  EXPECT_FALSE(m2.Matches(1));
745 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( SafeMatcherCastTest  ,
ConversionConstructorIsUsed   
)

Definition at line 747 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, and testing::internal::MatcherBase< T >::Matches().

747  {
748  Matcher<ConvertibleFromAny> m = SafeMatcherCast<ConvertibleFromAny>(1);
749  EXPECT_TRUE(m.Matches(ConvertibleFromAny(1)));
750  EXPECT_FALSE(m.Matches(ConvertibleFromAny(2)));
751 }
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( SafeMatcherCastTest  ,
FromConvertibleFromAny   
)

Definition at line 753 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, m, and testing::internal::MatcherBase< T >::Matches().

753  {
754  Matcher<ConvertibleFromAny> m =
755  SafeMatcherCast<ConvertibleFromAny>(Eq(ConvertibleFromAny(1)));
756  EXPECT_TRUE(m.Matches(ConvertibleFromAny(1)));
757  EXPECT_FALSE(m.Matches(ConvertibleFromAny(2)));
758 }
internal::EqMatcher< T > Eq(T x)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( SafeMatcherCastTest  ,
ValueIsNotCopied   
)

Definition at line 760 of file gmock-matchers_test.cc.

References EXPECT_TRUE, m, and testing::internal::MatcherBase< T >::Matches().

760  {
761  int n = 42;
762  Matcher<IntReferenceWrapper> m = SafeMatcherCast<IntReferenceWrapper>(n);
763  // Verify that the matcher holds a reference to n, not to its temporary copy.
764  EXPECT_TRUE(m.Matches(n));
765 }
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
testing::gmock_matchers_test::TEST ( ExpectThat  ,
TakesLiterals   
)

Definition at line 767 of file gmock-matchers_test.cc.

References EXPECT_THAT.

767  {
768  EXPECT_THAT(1, 1);
769  EXPECT_THAT(1.0, 1.0);
770  EXPECT_THAT(string(), "");
771 }
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( ExpectThat  ,
TakesFunctions   
)

Definition at line 773 of file gmock-matchers_test.cc.

References EXPECT_THAT.

773  {
774  struct Helper {
775  static void Func() {}
776  };
777  void (*func)() = Helper::Func;
778  EXPECT_THAT(func, Helper::Func);
779  EXPECT_THAT(func, &Helper::Func);
780 }
Function< void()> Func
Definition: Executor.h:27
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( ATest  ,
MatchesAnyValue   
)

Definition at line 783 of file gmock-matchers_test.cc.

References a, b, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

783  {
784  // Tests a matcher for a value type.
785  Matcher<double> m1 = A<double>();
786  EXPECT_TRUE(m1.Matches(91.43));
787  EXPECT_TRUE(m1.Matches(-15.32));
788 
789  // Tests a matcher for a reference type.
790  int a = 2;
791  int b = -6;
792  Matcher<int&> m2 = A<int&>();
793  EXPECT_TRUE(m2.Matches(a));
794  EXPECT_TRUE(m2.Matches(b));
795 }
char b
char a
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
testing::gmock_matchers_test::TEST ( ATest  ,
WorksForDerivedClass   
)

Definition at line 797 of file gmock-matchers_test.cc.

References EXPECT_THAT.

797  {
798  Base base;
799  Derived derived;
800  EXPECT_THAT(&base, A<Base*>());
801  // This shouldn't compile: EXPECT_THAT(&base, A<Derived*>());
802  EXPECT_THAT(&derived, A<Base*>());
803  EXPECT_THAT(&derived, A<Derived*>());
804 }
AtomicCounter< T, DeterministicAtomic > Base
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( ATest  ,
CanDescribeSelf   
)

Definition at line 807 of file gmock-matchers_test.cc.

References Describe(), and EXPECT_EQ.

807  {
808  EXPECT_EQ("is anything", Describe(A<bool>()));
809 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
testing::gmock_matchers_test::TEST ( AnTest  ,
MatchesAnyValue   
)

Definition at line 812 of file gmock-matchers_test.cc.

References a, b, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

812  {
813  // Tests a matcher for a value type.
814  Matcher<int> m1 = An<int>();
815  EXPECT_TRUE(m1.Matches(9143));
816  EXPECT_TRUE(m1.Matches(-1532));
817 
818  // Tests a matcher for a reference type.
819  int a = 2;
820  int b = -6;
821  Matcher<int&> m2 = An<int&>();
822  EXPECT_TRUE(m2.Matches(a));
823  EXPECT_TRUE(m2.Matches(b));
824 }
char b
char a
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
testing::gmock_matchers_test::TEST ( AnTest  ,
CanDescribeSelf   
)

Definition at line 827 of file gmock-matchers_test.cc.

References Describe(), and EXPECT_EQ.

827  {
828  EXPECT_EQ("is anything", Describe(An<int>()));
829 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
testing::gmock_matchers_test::TEST ( UnderscoreTest  ,
MatchesAnyValue   
)

Definition at line 833 of file gmock-matchers_test.cc.

References testing::_, a, b, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

833  {
834  // Uses _ as a matcher for a value type.
835  Matcher<int> m1 = _;
836  EXPECT_TRUE(m1.Matches(123));
837  EXPECT_TRUE(m1.Matches(-242));
838 
839  // Uses _ as a matcher for a reference type.
840  bool a = false;
841  const bool b = true;
842  Matcher<const bool&> m2 = _;
843  EXPECT_TRUE(m2.Matches(a));
844  EXPECT_TRUE(m2.Matches(b));
845 }
char b
char a
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
const internal::AnythingMatcher _
testing::gmock_matchers_test::TEST ( UnderscoreTest  ,
CanDescribeSelf   
)

Definition at line 848 of file gmock-matchers_test.cc.

References testing::_, Describe(), EXPECT_EQ, and m.

848  {
849  Matcher<int> m = _;
850  EXPECT_EQ("is anything", Describe(m));
851 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
const internal::AnythingMatcher _
testing::gmock_matchers_test::TEST ( EqTest  ,
MatchesEqualValue   
)

Definition at line 854 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

854  {
855  // 2 C-strings with same content but different addresses.
856  const char a1[] = "hi";
857  const char a2[] = "hi";
858 
859  Matcher<const char*> m1 = Eq(a1);
860  EXPECT_TRUE(m1.Matches(a1));
861  EXPECT_FALSE(m1.Matches(a2));
862 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( EqTest  ,
CanDescribeSelf   
)

Definition at line 879 of file gmock-matchers_test.cc.

References Describe(), testing::Eq(), EXPECT_EQ, and m.

879  {
880  Matcher<Unprintable> m = Eq(Unprintable());
881  EXPECT_EQ("is equal to 1-byte object <61>", Describe(m));
882 }
string Describe(const Matcher< T > &m)
internal::EqMatcher< T > Eq(T x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
testing::gmock_matchers_test::TEST ( EqTest  ,
IsPolymorphic   
)

Definition at line 886 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

886  {
887  Matcher<int> m1 = Eq(1);
888  EXPECT_TRUE(m1.Matches(1));
889  EXPECT_FALSE(m1.Matches(2));
890 
891  Matcher<char> m2 = Eq(1);
892  EXPECT_TRUE(m2.Matches('\1'));
893  EXPECT_FALSE(m2.Matches('a'));
894 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( TypedEqTest  ,
ChecksEqualityForGivenType   
)

Definition at line 897 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

897  {
898  Matcher<char> m1 = TypedEq<char>('a');
899  EXPECT_TRUE(m1.Matches('a'));
900  EXPECT_FALSE(m1.Matches('b'));
901 
902  Matcher<int> m2 = TypedEq<int>(6);
903  EXPECT_TRUE(m2.Matches(6));
904  EXPECT_FALSE(m2.Matches(7));
905 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( TypedEqTest  ,
CanDescribeSelf   
)

Definition at line 908 of file gmock-matchers_test.cc.

References Describe(), and EXPECT_EQ.

908  {
909  EXPECT_EQ("is equal to 2", Describe(TypedEq<int>(2)));
910 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
testing::gmock_matchers_test::TEST ( TypedEqTest  ,
HasSpecifiedType   
)

Definition at line 926 of file gmock-matchers_test.cc.

926  {
927  // Verfies that the type of TypedEq<T>(v) is Matcher<T>.
928  Type<Matcher<int> >::IsTypeOf(TypedEq<int>(5));
929  Type<Matcher<double> >::IsTypeOf(TypedEq<double>(5));
930 }
testing::gmock_matchers_test::TEST ( GeTest  ,
ImplementsGreaterThanOrEqual   
)

Definition at line 933 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), and testing::internal::MatcherBase< T >::Matches().

933  {
934  Matcher<int> m1 = Ge(0);
935  EXPECT_TRUE(m1.Matches(1));
936  EXPECT_TRUE(m1.Matches(0));
937  EXPECT_FALSE(m1.Matches(-1));
938 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( GeTest  ,
CanDescribeSelf   
)

Definition at line 941 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, testing::Ge(), and m.

941  {
942  Matcher<int> m = Ge(5);
943  EXPECT_EQ("is >= 5", Describe(m));
944 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( GtTest  ,
ImplementsGreaterThan   
)

Definition at line 947 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Gt(), and testing::internal::MatcherBase< T >::Matches().

947  {
948  Matcher<double> m1 = Gt(0);
949  EXPECT_TRUE(m1.Matches(1.0));
950  EXPECT_FALSE(m1.Matches(0.0));
951  EXPECT_FALSE(m1.Matches(-1.0));
952 }
internal::GtMatcher< Rhs > Gt(Rhs x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( GtTest  ,
CanDescribeSelf   
)

Definition at line 955 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, testing::Gt(), and m.

955  {
956  Matcher<int> m = Gt(5);
957  EXPECT_EQ("is > 5", Describe(m));
958 }
string Describe(const Matcher< T > &m)
internal::GtMatcher< Rhs > Gt(Rhs x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
testing::gmock_matchers_test::TEST ( LeTest  ,
ImplementsLessThanOrEqual   
)

Definition at line 961 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Le(), and testing::internal::MatcherBase< T >::Matches().

961  {
962  Matcher<char> m1 = Le('b');
963  EXPECT_TRUE(m1.Matches('a'));
964  EXPECT_TRUE(m1.Matches('b'));
965  EXPECT_FALSE(m1.Matches('c'));
966 }
internal::LeMatcher< Rhs > Le(Rhs x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( LeTest  ,
CanDescribeSelf   
)

Definition at line 969 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, testing::Le(), and m.

969  {
970  Matcher<int> m = Le(5);
971  EXPECT_EQ("is <= 5", Describe(m));
972 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::LeMatcher< Rhs > Le(Rhs x)
static map< string, int > m
testing::gmock_matchers_test::TEST ( LtTest  ,
ImplementsLessThan   
)

Definition at line 975 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Lt(), and testing::internal::MatcherBase< T >::Matches().

975  {
976  Matcher<const string&> m1 = Lt("Hello");
977  EXPECT_TRUE(m1.Matches("Abc"));
978  EXPECT_FALSE(m1.Matches("Hello"));
979  EXPECT_FALSE(m1.Matches("Hello, world!"));
980 }
internal::LtMatcher< Rhs > Lt(Rhs x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( LtTest  ,
CanDescribeSelf   
)

Definition at line 983 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, testing::Lt(), and m.

983  {
984  Matcher<int> m = Lt(5);
985  EXPECT_EQ("is < 5", Describe(m));
986 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::LtMatcher< Rhs > Lt(Rhs x)
static map< string, int > m
testing::gmock_matchers_test::TEST ( NeTest  ,
ImplementsNotEqual   
)

Definition at line 989 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), and testing::Ne().

989  {
990  Matcher<int> m1 = Ne(0);
991  EXPECT_TRUE(m1.Matches(1));
992  EXPECT_TRUE(m1.Matches(-1));
993  EXPECT_FALSE(m1.Matches(0));
994 }
internal::NeMatcher< Rhs > Ne(Rhs x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( NeTest  ,
CanDescribeSelf   
)

Definition at line 997 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, m, and testing::Ne().

997  {
998  Matcher<int> m = Ne(5);
999  EXPECT_EQ("isn't equal to 5", Describe(m));
1000 }
string Describe(const Matcher< T > &m)
internal::NeMatcher< Rhs > Ne(Rhs x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
testing::gmock_matchers_test::TEST ( IsNullTest  ,
MatchesNullPointer   
)

Definition at line 1003 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::internal::IsNull(), and testing::internal::MatcherBase< T >::Matches().

1003  {
1004  Matcher<int*> m1 = IsNull();
1005  int* p1 = NULL;
1006  int n = 0;
1007  EXPECT_TRUE(m1.Matches(p1));
1008  EXPECT_FALSE(m1.Matches(&n));
1009 
1010  Matcher<const char*> m2 = IsNull();
1011  const char* p2 = NULL;
1012  EXPECT_TRUE(m2.Matches(p2));
1013  EXPECT_FALSE(m2.Matches("hi"));
1014 
1015 #if !GTEST_OS_SYMBIAN
1016  // Nokia's Symbian compiler generates:
1017  // gmock-matchers.h: ambiguous access to overloaded function
1018  // gmock-matchers.h: 'testing::Matcher<void *>::Matcher(void *)'
1019  // gmock-matchers.h: 'testing::Matcher<void *>::Matcher(const testing::
1020  // MatcherInterface<void *> *)'
1021  // gmock-matchers.h: (point of instantiation: 'testing::
1022  // gmock_matchers_test::IsNullTest_MatchesNullPointer_Test::TestBody()')
1023  // gmock-matchers.h: (instantiating: 'testing::PolymorphicMatc
1024  Matcher<void*> m3 = IsNull();
1025  void* p3 = NULL;
1026  EXPECT_TRUE(m3.Matches(p3));
1027  EXPECT_FALSE(m3.Matches(reinterpret_cast<void*>(0xbeef)));
1028 #endif
1029 }
PolymorphicMatcher< internal::IsNullMatcher > IsNull()
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( IsNullTest  ,
LinkedPtr   
)

Definition at line 1031 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::internal::IsNull(), m, and testing::internal::MatcherBase< T >::Matches().

1031  {
1032  const Matcher<linked_ptr<int> > m = IsNull();
1033  const linked_ptr<int> null_p;
1034  const linked_ptr<int> non_null_p(new int);
1035 
1036  EXPECT_TRUE(m.Matches(null_p));
1037  EXPECT_FALSE(m.Matches(non_null_p));
1038 }
PolymorphicMatcher< internal::IsNullMatcher > IsNull()
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( IsNullTest  ,
ReferenceToConstLinkedPtr   
)

Definition at line 1040 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::internal::IsNull(), m, testing::internal::MatcherBase< T >::Matches(), and testing::internal::TEST().

1040  {
1041  const Matcher<const linked_ptr<double>&> m = IsNull();
1042  const linked_ptr<double> null_p;
1043  const linked_ptr<double> non_null_p(new double);
1044 
1045  EXPECT_TRUE(m.Matches(null_p));
1046  EXPECT_FALSE(m.Matches(non_null_p));
1047 }
PolymorphicMatcher< internal::IsNullMatcher > IsNull()
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( IsNullTest  ,
CanDescribeSelf   
)

Definition at line 1059 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, testing::internal::IsNull(), and m.

1059  {
1060  Matcher<int*> m = IsNull();
1061  EXPECT_EQ("is NULL", Describe(m));
1062  EXPECT_EQ("isn't NULL", DescribeNegation(m));
1063 }
PolymorphicMatcher< internal::IsNullMatcher > IsNull()
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
static map< string, int > m
testing::gmock_matchers_test::TEST ( NotNullTest  ,
MatchesNonNullPointer   
)

Definition at line 1066 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), and testing::NotNull().

1066  {
1067  Matcher<int*> m1 = NotNull();
1068  int* p1 = NULL;
1069  int n = 0;
1070  EXPECT_FALSE(m1.Matches(p1));
1071  EXPECT_TRUE(m1.Matches(&n));
1072 
1073  Matcher<const char*> m2 = NotNull();
1074  const char* p2 = NULL;
1075  EXPECT_FALSE(m2.Matches(p2));
1076  EXPECT_TRUE(m2.Matches("hi"));
1077 }
PolymorphicMatcher< internal::NotNullMatcher > NotNull()
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( NotNullTest  ,
LinkedPtr   
)

Definition at line 1079 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::NotNull().

1079  {
1080  const Matcher<linked_ptr<int> > m = NotNull();
1081  const linked_ptr<int> null_p;
1082  const linked_ptr<int> non_null_p(new int);
1083 
1084  EXPECT_FALSE(m.Matches(null_p));
1085  EXPECT_TRUE(m.Matches(non_null_p));
1086 }
PolymorphicMatcher< internal::NotNullMatcher > NotNull()
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( NotNullTest  ,
ReferenceToConstLinkedPtr   
)

Definition at line 1088 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), testing::NotNull(), and testing::internal::TEST().

1088  {
1089  const Matcher<const linked_ptr<double>&> m = NotNull();
1090  const linked_ptr<double> null_p;
1091  const linked_ptr<double> non_null_p(new double);
1092 
1093  EXPECT_FALSE(m.Matches(null_p));
1094  EXPECT_TRUE(m.Matches(non_null_p));
1095 }
PolymorphicMatcher< internal::NotNullMatcher > NotNull()
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( NotNullTest  ,
CanDescribeSelf   
)

Definition at line 1107 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, m, and testing::NotNull().

1107  {
1108  Matcher<int*> m = NotNull();
1109  EXPECT_EQ("isn't NULL", Describe(m));
1110 }
string Describe(const Matcher< T > &m)
PolymorphicMatcher< internal::NotNullMatcher > NotNull()
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
testing::gmock_matchers_test::TEST ( RefTest  ,
MatchesSameVariable   
)

Definition at line 1114 of file gmock-matchers_test.cc.

References a, b, EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::Ref().

1114  {
1115  int a = 0;
1116  int b = 0;
1117  Matcher<int&> m = Ref(a);
1118  EXPECT_TRUE(m.Matches(a));
1119  EXPECT_FALSE(m.Matches(b));
1120 }
char b
internal::RefMatcher< T & > Ref(T &x)
static map< string, int > m
char a
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( RefTest  ,
CanDescribeSelf   
)

Definition at line 1123 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, m, and testing::Ref().

1123  {
1124  int n = 5;
1125  Matcher<int&> m = Ref(n);
1126  stringstream ss;
1127  ss << "references the variable @" << &n << " 5";
1128  EXPECT_EQ(string(ss.str()), Describe(m));
1129 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::RefMatcher< T & > Ref(T &x)
static map< string, int > m
testing::gmock_matchers_test::TEST ( RefTest  ,
CanBeUsedAsMatcherForConstReference   
)

Definition at line 1133 of file gmock-matchers_test.cc.

References a, b, EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::Ref().

1133  {
1134  int a = 0;
1135  int b = 0;
1136  Matcher<const int&> m = Ref(a);
1137  EXPECT_TRUE(m.Matches(a));
1138  EXPECT_FALSE(m.Matches(b));
1139 }
char b
internal::RefMatcher< T & > Ref(T &x)
static map< string, int > m
char a
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( RefTest  ,
IsCovariant   
)

Definition at line 1145 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), and testing::Ref().

1145  {
1146  Base base, base2;
1147  Derived derived;
1148  Matcher<const Base&> m1 = Ref(base);
1149  EXPECT_TRUE(m1.Matches(base));
1150  EXPECT_FALSE(m1.Matches(base2));
1151  EXPECT_FALSE(m1.Matches(derived));
1152 
1153  m1 = Ref(derived);
1154  EXPECT_TRUE(m1.Matches(derived));
1155  EXPECT_FALSE(m1.Matches(base));
1156  EXPECT_FALSE(m1.Matches(base2));
1157 }
internal::RefMatcher< T & > Ref(T &x)
AtomicCounter< T, DeterministicAtomic > Base
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( RefTest  ,
ExplainsResult   
)

Definition at line 1159 of file gmock-matchers_test.cc.

References EXPECT_THAT, Explain(), m, testing::Ref(), and testing::StartsWith().

1159  {
1160  int n = 0;
1161  EXPECT_THAT(Explain(Matcher<const int&>(Ref(n)), n),
1162  StartsWith("which is located @"));
1163 
1164  int m = 0;
1165  EXPECT_THAT(Explain(Matcher<const int&>(Ref(n)), m),
1166  StartsWith("which is located @"));
1167 }
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
string Explain(const MatcherType &m, const Value &x)
internal::RefMatcher< T & > Ref(T &x)
static map< string, int > m
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( StrEqTest  ,
MatchesEqualString   
)

Definition at line 1171 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::StrEq().

1171  {
1172  Matcher<const char*> m = StrEq(string("Hello"));
1173  EXPECT_TRUE(m.Matches("Hello"));
1174  EXPECT_FALSE(m.Matches("hello"));
1175  EXPECT_FALSE(m.Matches(NULL));
1176 
1177  Matcher<const string&> m2 = StrEq("Hello");
1178  EXPECT_TRUE(m2.Matches("Hello"));
1179  EXPECT_FALSE(m2.Matches("Hi"));
1180 }
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrEq(const internal::string &str)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( StrEqTest  ,
CanDescribeSelf   
)

Definition at line 1182 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, m, and testing::StrEq().

1182  {
1183  Matcher<string> m = StrEq("Hi-\'\"?\\\a\b\f\n\r\t\v\xD3");
1184  EXPECT_EQ("is equal to \"Hi-\'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\\xD3\"",
1185  Describe(m));
1186 
1187  string str("01204500800");
1188  str[3] = '\0';
1189  Matcher<string> m2 = StrEq(str);
1190  EXPECT_EQ("is equal to \"012\\04500800\"", Describe(m2));
1191  str[0] = str[6] = str[7] = str[9] = str[10] = '\0';
1192  Matcher<string> m3 = StrEq(str);
1193  EXPECT_EQ("is equal to \"\\012\\045\\0\\08\\0\\0\"", Describe(m3));
1194 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrEq(const internal::string &str)
static map< string, int > m
testing::gmock_matchers_test::TEST ( StrNeTest  ,
MatchesUnequalString   
)

Definition at line 1196 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::StrNe().

1196  {
1197  Matcher<const char*> m = StrNe("Hello");
1198  EXPECT_TRUE(m.Matches(""));
1199  EXPECT_TRUE(m.Matches(NULL));
1200  EXPECT_FALSE(m.Matches("Hello"));
1201 
1202  Matcher<string> m2 = StrNe(string("Hello"));
1203  EXPECT_TRUE(m2.Matches("hello"));
1204  EXPECT_FALSE(m2.Matches("Hello"));
1205 }
static map< string, int > m
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrNe(const internal::string &str)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( StrNeTest  ,
CanDescribeSelf   
)

Definition at line 1207 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, m, and testing::StrNe().

1207  {
1208  Matcher<const char*> m = StrNe("Hi");
1209  EXPECT_EQ("isn't equal to \"Hi\"", Describe(m));
1210 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrNe(const internal::string &str)
testing::gmock_matchers_test::TEST ( StrCaseEqTest  ,
MatchesEqualStringIgnoringCase   
)

Definition at line 1212 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::StrCaseEq().

1212  {
1213  Matcher<const char*> m = StrCaseEq(string("Hello"));
1214  EXPECT_TRUE(m.Matches("Hello"));
1215  EXPECT_TRUE(m.Matches("hello"));
1216  EXPECT_FALSE(m.Matches("Hi"));
1217  EXPECT_FALSE(m.Matches(NULL));
1218 
1219  Matcher<const string&> m2 = StrCaseEq("Hello");
1220  EXPECT_TRUE(m2.Matches("hello"));
1221  EXPECT_FALSE(m2.Matches("Hi"));
1222 }
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrCaseEq(const internal::string &str)
testing::gmock_matchers_test::TEST ( StrCaseEqTest  ,
MatchesEqualStringWith0IgnoringCase   
)

Definition at line 1224 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), and testing::StrCaseEq().

1224  {
1225  string str1("oabocdooeoo");
1226  string str2("OABOCDOOEOO");
1227  Matcher<const string&> m0 = StrCaseEq(str1);
1228  EXPECT_FALSE(m0.Matches(str2 + string(1, '\0')));
1229 
1230  str1[3] = str2[3] = '\0';
1231  Matcher<const string&> m1 = StrCaseEq(str1);
1232  EXPECT_TRUE(m1.Matches(str2));
1233 
1234  str1[0] = str1[6] = str1[7] = str1[10] = '\0';
1235  str2[0] = str2[6] = str2[7] = str2[10] = '\0';
1236  Matcher<const string&> m2 = StrCaseEq(str1);
1237  str1[9] = str2[9] = '\0';
1238  EXPECT_FALSE(m2.Matches(str2));
1239 
1240  Matcher<const string&> m3 = StrCaseEq(str1);
1241  EXPECT_TRUE(m3.Matches(str2));
1242 
1243  EXPECT_FALSE(m3.Matches(str2 + "x"));
1244  str2.append(1, '\0');
1245  EXPECT_FALSE(m3.Matches(str2));
1246  EXPECT_FALSE(m3.Matches(string(str2, 0, 9)));
1247 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrCaseEq(const internal::string &str)
testing::gmock_matchers_test::TEST ( StrCaseEqTest  ,
CanDescribeSelf   
)

Definition at line 1249 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, m, and testing::StrCaseEq().

1249  {
1250  Matcher<string> m = StrCaseEq("Hi");
1251  EXPECT_EQ("is equal to (ignoring case) \"Hi\"", Describe(m));
1252 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrCaseEq(const internal::string &str)
testing::gmock_matchers_test::TEST ( StrCaseNeTest  ,
MatchesUnequalStringIgnoringCase   
)

Definition at line 1254 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::StrCaseNe().

1254  {
1255  Matcher<const char*> m = StrCaseNe("Hello");
1256  EXPECT_TRUE(m.Matches("Hi"));
1257  EXPECT_TRUE(m.Matches(NULL));
1258  EXPECT_FALSE(m.Matches("Hello"));
1259  EXPECT_FALSE(m.Matches("hello"));
1260 
1261  Matcher<string> m2 = StrCaseNe(string("Hello"));
1262  EXPECT_TRUE(m2.Matches(""));
1263  EXPECT_FALSE(m2.Matches("Hello"));
1264 }
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrCaseNe(const internal::string &str)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( StrCaseNeTest  ,
CanDescribeSelf   
)

Definition at line 1266 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, m, and testing::StrCaseNe().

1266  {
1267  Matcher<const char*> m = StrCaseNe("Hi");
1268  EXPECT_EQ("isn't equal to (ignoring case) \"Hi\"", Describe(m));
1269 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrCaseNe(const internal::string &str)
static map< string, int > m
testing::gmock_matchers_test::TEST ( HasSubstrTest  ,
WorksForStringClasses   
)

Definition at line 1272 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::HasSubstr(), testing::internal::MatcherBase< T >::Matches(), and string.

1272  {
1273  const Matcher<string> m1 = HasSubstr("foo");
1274  EXPECT_TRUE(m1.Matches(string("I love food.")));
1275  EXPECT_FALSE(m1.Matches(string("tofo")));
1276 
1277  const Matcher<const std::string&> m2 = HasSubstr("foo");
1278  EXPECT_TRUE(m2.Matches(std::string("I love food.")));
1279  EXPECT_FALSE(m2.Matches(std::string("tofo")));
1280 }
PolymorphicMatcher< internal::HasSubstrMatcher< internal::string > > HasSubstr(const internal::string &substring)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
const char * string
Definition: Conv.cpp:212
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( HasSubstrTest  ,
WorksForCStrings   
)

Definition at line 1283 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::HasSubstr(), and testing::internal::MatcherBase< T >::Matches().

1283  {
1284  const Matcher<char*> m1 = HasSubstr("foo");
1285  EXPECT_TRUE(m1.Matches(const_cast<char*>("I love food.")));
1286  EXPECT_FALSE(m1.Matches(const_cast<char*>("tofo")));
1287  EXPECT_FALSE(m1.Matches(NULL));
1288 
1289  const Matcher<const char*> m2 = HasSubstr("foo");
1290  EXPECT_TRUE(m2.Matches("I love food."));
1291  EXPECT_FALSE(m2.Matches("tofo"));
1292  EXPECT_FALSE(m2.Matches(NULL));
1293 }
PolymorphicMatcher< internal::HasSubstrMatcher< internal::string > > HasSubstr(const internal::string &substring)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( HasSubstrTest  ,
CanDescribeSelf   
)

Definition at line 1296 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, testing::HasSubstr(), and m.

1296  {
1297  Matcher<string> m = HasSubstr("foo\n\"");
1298  EXPECT_EQ("has substring \"foo\\n\\\"\"", Describe(m));
1299 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicMatcher< internal::HasSubstrMatcher< internal::string > > HasSubstr(const internal::string &substring)
static map< string, int > m
testing::gmock_matchers_test::TEST ( KeyTest  ,
CanDescribeSelf   
)

Definition at line 1301 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, testing::Key(), and m.

1301  {
1302  Matcher<const pair<std::string, int>&> m = Key("foo");
1303  EXPECT_EQ("has a key that is equal to \"foo\"", Describe(m));
1304  EXPECT_EQ("doesn't have a key that is equal to \"foo\"", DescribeNegation(m));
1305 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::KeyMatcher< M > Key(M inner_matcher)
string DescribeNegation(const Matcher< T > &m)
static map< string, int > m
testing::gmock_matchers_test::TEST ( KeyTest  ,
ExplainsResult   
)

Definition at line 1307 of file gmock-matchers_test.cc.

References EXPECT_EQ, Explain(), GreaterThan(), testing::Key(), and m.

1307  {
1308  Matcher<pair<int, bool> > m = Key(GreaterThan(10));
1309  EXPECT_EQ("whose first field is a value which is 5 less than 10",
1310  Explain(m, make_pair(5, true)));
1311  EXPECT_EQ("whose first field is a value which is 5 more than 10",
1312  Explain(m, make_pair(15, true)));
1313 }
Matcher< int > GreaterThan(int n)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::KeyMatcher< M > Key(M inner_matcher)
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
testing::gmock_matchers_test::TEST ( KeyTest  ,
MatchesCorrectly   
)

Definition at line 1315 of file gmock-matchers_test.cc.

References EXPECT_THAT, testing::Ge(), testing::Key(), testing::Lt(), and testing::Not().

1315  {
1316  pair<int, std::string> p(25, "foo");
1317  EXPECT_THAT(p, Key(25));
1318  EXPECT_THAT(p, Not(Key(42)));
1319  EXPECT_THAT(p, Key(Ge(20)));
1320  EXPECT_THAT(p, Not(Key(Lt(25))));
1321 }
internal::KeyMatcher< M > Key(M inner_matcher)
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
Definition: Traits.h:577
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( KeyTest  ,
SafelyCastsInnerMatcher   
)

Definition at line 1323 of file gmock-matchers_test.cc.

References EXPECT_THAT, testing::Gt(), folly::is_negative(), folly::is_positive(), testing::Key(), testing::Lt(), and testing::Not().

1323  {
1324  Matcher<int> is_positive = Gt(0);
1325  Matcher<int> is_negative = Lt(0);
1326  pair<char, bool> p('a', true);
1327  EXPECT_THAT(p, Key(is_positive));
1328  EXPECT_THAT(p, Not(Key(is_negative)));
1329 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::KeyMatcher< M > Key(M inner_matcher)
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
constexpr bool is_positive(T x)
Definition: Traits.h:687
#define EXPECT_THAT(value, matcher)
constexpr bool is_negative(T x)
Definition: Traits.h:675
Definition: Traits.h:577
testing::gmock_matchers_test::TEST ( KeyTest  ,
InsideContainsUsingMap   
)

Definition at line 1331 of file gmock-matchers_test.cc.

References testing::Contains(), EXPECT_THAT, testing::Key(), and testing::Not().

1331  {
1332  map<int, char> container;
1333  container.insert(make_pair(1, 'a'));
1334  container.insert(make_pair(2, 'b'));
1335  container.insert(make_pair(4, 'c'));
1336  EXPECT_THAT(container, Contains(Key(1)));
1337  EXPECT_THAT(container, Not(Contains(Key(3))));
1338 }
internal::KeyMatcher< M > Key(M inner_matcher)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
Definition: Traits.h:594
#define EXPECT_THAT(value, matcher)
internal::ContainsMatcher< M > Contains(M matcher)
testing::gmock_matchers_test::TEST ( KeyTest  ,
InsideContainsUsingMultimap   
)

Definition at line 1340 of file gmock-matchers_test.cc.

References testing::Contains(), EXPECT_THAT, testing::Key(), and testing::Not().

1340  {
1341  multimap<int, char> container;
1342  container.insert(make_pair(1, 'a'));
1343  container.insert(make_pair(2, 'b'));
1344  container.insert(make_pair(4, 'c'));
1345 
1346  EXPECT_THAT(container, Not(Contains(Key(25))));
1347  container.insert(make_pair(25, 'd'));
1348  EXPECT_THAT(container, Contains(Key(25)));
1349  container.insert(make_pair(25, 'e'));
1350  EXPECT_THAT(container, Contains(Key(25)));
1351 
1352  EXPECT_THAT(container, Contains(Key(1)));
1353  EXPECT_THAT(container, Not(Contains(Key(3))));
1354 }
internal::KeyMatcher< M > Key(M inner_matcher)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
internal::ContainsMatcher< M > Contains(M matcher)
testing::gmock_matchers_test::TEST ( PairTest  ,
Typing   
)

Definition at line 1356 of file gmock-matchers_test.cc.

References testing::Pair().

1356  {
1357  // Test verifies the following type conversions can be compiled.
1358  Matcher<const pair<const char*, int>&> m1 = Pair("foo", 42);
1359  Matcher<const pair<const char*, int> > m2 = Pair("foo", 42);
1360  Matcher<pair<const char*, int> > m3 = Pair("foo", 42);
1361 
1362  Matcher<pair<int, const std::string> > m4 = Pair(25, "42");
1363  Matcher<pair<const std::string, int> > m5 = Pair("25", 42);
1364 }
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
testing::gmock_matchers_test::TEST ( PairTest  ,
CanDescribeSelf   
)

Definition at line 1366 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, testing::Not(), and testing::Pair().

1366  {
1367  Matcher<const pair<std::string, int>&> m1 = Pair("foo", 42);
1368  EXPECT_EQ("has a first field that is equal to \"foo\""
1369  ", and has a second field that is equal to 42",
1370  Describe(m1));
1371  EXPECT_EQ("has a first field that isn't equal to \"foo\""
1372  ", or has a second field that isn't equal to 42",
1373  DescribeNegation(m1));
1374  // Double and triple negation (1 or 2 times not and description of negation).
1375  Matcher<const pair<int, int>&> m2 = Not(Pair(Not(13), 42));
1376  EXPECT_EQ("has a first field that isn't equal to 13"
1377  ", and has a second field that is equal to 42",
1378  DescribeNegation(m2));
1379 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
testing::gmock_matchers_test::TEST ( PairTest  ,
CanExplainMatchResultTo   
)

Definition at line 1381 of file gmock-matchers_test.cc.

References EXPECT_EQ, Explain(), GreaterThan(), m, and testing::Pair().

1381  {
1382  // If neither field matches, Pair() should explain about the first
1383  // field.
1384  const Matcher<pair<int, int> > m = Pair(GreaterThan(0), GreaterThan(0));
1385  EXPECT_EQ("whose first field does not match, which is 1 less than 0",
1386  Explain(m, make_pair(-1, -2)));
1387 
1388  // If the first field matches but the second doesn't, Pair() should
1389  // explain about the second field.
1390  EXPECT_EQ("whose second field does not match, which is 2 less than 0",
1391  Explain(m, make_pair(1, -2)));
1392 
1393  // If the first field doesn't match but the second does, Pair()
1394  // should explain about the first field.
1395  EXPECT_EQ("whose first field does not match, which is 1 less than 0",
1396  Explain(m, make_pair(-1, 2)));
1397 
1398  // If both fields match, Pair() should explain about them both.
1399  EXPECT_EQ("whose both fields match, where the first field is a value "
1400  "which is 1 more than 0, and the second field is a value "
1401  "which is 2 more than 0",
1402  Explain(m, make_pair(1, 2)));
1403 
1404  // If only the first match has an explanation, only this explanation should
1405  // be printed.
1406  const Matcher<pair<int, int> > explain_first = Pair(GreaterThan(0), 0);
1407  EXPECT_EQ("whose both fields match, where the first field is a value "
1408  "which is 1 more than 0",
1409  Explain(explain_first, make_pair(1, 0)));
1410 
1411  // If only the second match has an explanation, only this explanation should
1412  // be printed.
1413  const Matcher<pair<int, int> > explain_second = Pair(0, GreaterThan(0));
1414  EXPECT_EQ("whose both fields match, where the second field is a value "
1415  "which is 1 more than 0",
1416  Explain(explain_second, make_pair(0, 1)));
1417 }
Matcher< int > GreaterThan(int n)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
static map< string, int > m
testing::gmock_matchers_test::TEST ( PairTest  ,
MatchesCorrectly   
)

Definition at line 1419 of file gmock-matchers_test.cc.

References EXPECT_THAT, testing::Ge(), testing::HasSubstr(), testing::Lt(), testing::Not(), and testing::Pair().

1419  {
1420  pair<int, std::string> p(25, "foo");
1421 
1422  // Both fields match.
1423  EXPECT_THAT(p, Pair(25, "foo"));
1424  EXPECT_THAT(p, Pair(Ge(20), HasSubstr("o")));
1425 
1426  // 'first' doesnt' match, but 'second' matches.
1427  EXPECT_THAT(p, Not(Pair(42, "foo")));
1428  EXPECT_THAT(p, Not(Pair(Lt(25), "foo")));
1429 
1430  // 'first' matches, but 'second' doesn't match.
1431  EXPECT_THAT(p, Not(Pair(25, "bar")));
1432  EXPECT_THAT(p, Not(Pair(25, Not("foo"))));
1433 
1434  // Neither field matches.
1435  EXPECT_THAT(p, Not(Pair(13, "bar")));
1436  EXPECT_THAT(p, Not(Pair(Lt(13), HasSubstr("a"))));
1437 }
internal::LtMatcher< Rhs > Lt(Rhs x)
PolymorphicMatcher< internal::HasSubstrMatcher< internal::string > > HasSubstr(const internal::string &substring)
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
Definition: Traits.h:577
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PairTest  ,
SafelyCastsInnerMatchers   
)

Definition at line 1439 of file gmock-matchers_test.cc.

References testing::_, EXPECT_THAT, testing::Gt(), folly::is_negative(), folly::is_positive(), testing::Lt(), testing::Not(), and testing::Pair().

1439  {
1440  Matcher<int> is_positive = Gt(0);
1441  Matcher<int> is_negative = Lt(0);
1442  pair<char, bool> p('a', true);
1443  EXPECT_THAT(p, Pair(is_positive, _));
1444  EXPECT_THAT(p, Not(Pair(is_negative, _)));
1445  EXPECT_THAT(p, Pair(_, is_positive));
1446  EXPECT_THAT(p, Not(Pair(_, is_negative)));
1447 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
constexpr bool is_positive(T x)
Definition: Traits.h:687
#define EXPECT_THAT(value, matcher)
constexpr bool is_negative(T x)
Definition: Traits.h:675
Definition: Traits.h:577
const internal::AnythingMatcher _
testing::gmock_matchers_test::TEST ( PairTest  ,
InsideContainsUsingMap   
)

Definition at line 1449 of file gmock-matchers_test.cc.

References testing::_, testing::Contains(), EXPECT_THAT, testing::Not(), and testing::Pair().

1449  {
1450  map<int, char> container;
1451  container.insert(make_pair(1, 'a'));
1452  container.insert(make_pair(2, 'b'));
1453  container.insert(make_pair(4, 'c'));
1454  EXPECT_THAT(container, Contains(Pair(1, 'a')));
1455  EXPECT_THAT(container, Contains(Pair(1, _)));
1456  EXPECT_THAT(container, Contains(Pair(_, 'a')));
1457  EXPECT_THAT(container, Not(Contains(Pair(3, _))));
1458 }
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
Definition: Traits.h:594
#define EXPECT_THAT(value, matcher)
const internal::AnythingMatcher _
internal::ContainsMatcher< M > Contains(M matcher)
testing::gmock_matchers_test::TEST ( StartsWithTest  ,
MatchesStringWithGivenPrefix   
)

Definition at line 1462 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), and testing::StartsWith().

1462  {
1463  const Matcher<const char*> m1 = StartsWith(string(""));
1464  EXPECT_TRUE(m1.Matches("Hi"));
1465  EXPECT_TRUE(m1.Matches(""));
1466  EXPECT_FALSE(m1.Matches(NULL));
1467 
1468  const Matcher<const string&> m2 = StartsWith("Hi");
1469  EXPECT_TRUE(m2.Matches("Hi"));
1470  EXPECT_TRUE(m2.Matches("Hi Hi!"));
1471  EXPECT_TRUE(m2.Matches("High"));
1472  EXPECT_FALSE(m2.Matches("H"));
1473  EXPECT_FALSE(m2.Matches(" Hi"));
1474 }
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( StartsWithTest  ,
CanDescribeSelf   
)

Definition at line 1476 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, m, and testing::StartsWith().

1476  {
1477  Matcher<const std::string> m = StartsWith("Hi");
1478  EXPECT_EQ("starts with \"Hi\"", Describe(m));
1479 }
string Describe(const Matcher< T > &m)
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
testing::gmock_matchers_test::TEST ( EndsWithTest  ,
MatchesStringWithGivenSuffix   
)

Definition at line 1483 of file gmock-matchers_test.cc.

References testing::EndsWith(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

1483  {
1484  const Matcher<const char*> m1 = EndsWith("");
1485  EXPECT_TRUE(m1.Matches("Hi"));
1486  EXPECT_TRUE(m1.Matches(""));
1487  EXPECT_FALSE(m1.Matches(NULL));
1488 
1489  const Matcher<const string&> m2 = EndsWith(string("Hi"));
1490  EXPECT_TRUE(m2.Matches("Hi"));
1491  EXPECT_TRUE(m2.Matches("Wow Hi Hi"));
1492  EXPECT_TRUE(m2.Matches("Super Hi"));
1493  EXPECT_FALSE(m2.Matches("i"));
1494  EXPECT_FALSE(m2.Matches("Hi "));
1495 }
PolymorphicMatcher< internal::EndsWithMatcher< internal::string > > EndsWith(const internal::string &suffix)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( EndsWithTest  ,
CanDescribeSelf   
)

Definition at line 1497 of file gmock-matchers_test.cc.

References Describe(), testing::EndsWith(), EXPECT_EQ, and m.

1497  {
1498  Matcher<const std::string> m = EndsWith("Hi");
1499  EXPECT_EQ("ends with \"Hi\"", Describe(m));
1500 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicMatcher< internal::EndsWithMatcher< internal::string > > EndsWith(const internal::string &suffix)
static map< string, int > m
testing::gmock_matchers_test::TEST ( MatchesRegexTest  ,
MatchesStringMatchingGivenRegex   
)

Definition at line 1504 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), and testing::MatchesRegex().

1504  {
1505  const Matcher<const char*> m1 = MatchesRegex("a.*z");
1506  EXPECT_TRUE(m1.Matches("az"));
1507  EXPECT_TRUE(m1.Matches("abcz"));
1508  EXPECT_FALSE(m1.Matches(NULL));
1509 
1510  const Matcher<const string&> m2 = MatchesRegex(new RE("a.*z"));
1511  EXPECT_TRUE(m2.Matches("azbz"));
1512  EXPECT_FALSE(m2.Matches("az1"));
1513  EXPECT_FALSE(m2.Matches("1az"));
1514 }
PolymorphicMatcher< internal::MatchesRegexMatcher > MatchesRegex(const internal::RE *regex)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatchesRegexTest  ,
CanDescribeSelf   
)

Definition at line 1516 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, and testing::MatchesRegex().

1516  {
1517  Matcher<const std::string> m1 = MatchesRegex(string("Hi.*"));
1518  EXPECT_EQ("matches regular expression \"Hi.*\"", Describe(m1));
1519 
1520  Matcher<const char*> m2 = MatchesRegex(new RE("a.*"));
1521  EXPECT_EQ("matches regular expression \"a.*\"", Describe(m2));
1522 }
string Describe(const Matcher< T > &m)
PolymorphicMatcher< internal::MatchesRegexMatcher > MatchesRegex(const internal::RE *regex)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
testing::gmock_matchers_test::TEST ( ContainsRegexTest  ,
MatchesStringContainingGivenRegex   
)

Definition at line 1526 of file gmock-matchers_test.cc.

References testing::ContainsRegex(), EXPECT_FALSE, EXPECT_TRUE, and testing::internal::MatcherBase< T >::Matches().

1526  {
1527  const Matcher<const char*> m1 = ContainsRegex(string("a.*z"));
1528  EXPECT_TRUE(m1.Matches("az"));
1529  EXPECT_TRUE(m1.Matches("0abcz1"));
1530  EXPECT_FALSE(m1.Matches(NULL));
1531 
1532  const Matcher<const string&> m2 = ContainsRegex(new RE("a.*z"));
1533  EXPECT_TRUE(m2.Matches("azbz"));
1534  EXPECT_TRUE(m2.Matches("az1"));
1535  EXPECT_FALSE(m2.Matches("1a"));
1536 }
PolymorphicMatcher< internal::MatchesRegexMatcher > ContainsRegex(const internal::RE *regex)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ContainsRegexTest  ,
CanDescribeSelf   
)

Definition at line 1538 of file gmock-matchers_test.cc.

References testing::ContainsRegex(), Describe(), testing::EndsWith(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, testing::HasSubstr(), m, testing::internal::MatcherBase< T >::Matches(), testing::StartsWith(), testing::StrCaseEq(), testing::StrCaseNe(), testing::StrEq(), testing::StrNe(), and testing::internal::TEST().

1538  {
1539  Matcher<const std::string> m1 = ContainsRegex("Hi.*");
1540  EXPECT_EQ("contains regular expression \"Hi.*\"", Describe(m1));
1541 
1542  Matcher<const char*> m2 = ContainsRegex(new RE("a.*"));
1543  EXPECT_EQ("contains regular expression \"a.*\"", Describe(m2));
1544 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicMatcher< internal::MatchesRegexMatcher > ContainsRegex(const internal::RE *regex)
testing::gmock_matchers_test::TEST ( Eq2Test  ,
MatchesEqualArguments   
)

Definition at line 1934 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, m, and testing::internal::MatcherBase< T >::Matches().

1934  {
1935  Matcher<const Tuple2&> m = Eq();
1936  EXPECT_TRUE(m.Matches(Tuple2(5L, 5)));
1937  EXPECT_FALSE(m.Matches(Tuple2(5L, 6)));
1938 }
internal::EqMatcher< T > Eq(T x)
::testing::tuple< long, int > Tuple2
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( Eq2Test  ,
CanDescribeSelf   
)

Definition at line 1941 of file gmock-matchers_test.cc.

References Describe(), testing::Eq(), EXPECT_EQ, and m.

1941  {
1942  Matcher<const Tuple2&> m = Eq();
1943  EXPECT_EQ("are an equal pair", Describe(m));
1944 }
string Describe(const Matcher< T > &m)
internal::EqMatcher< T > Eq(T x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
testing::gmock_matchers_test::TEST ( Ge2Test  ,
MatchesGreaterThanOrEqualArguments   
)

Definition at line 1948 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), m, and testing::internal::MatcherBase< T >::Matches().

1948  {
1949  Matcher<const Tuple2&> m = Ge();
1950  EXPECT_TRUE(m.Matches(Tuple2(5L, 4)));
1951  EXPECT_TRUE(m.Matches(Tuple2(5L, 5)));
1952  EXPECT_FALSE(m.Matches(Tuple2(5L, 6)));
1953 }
::testing::tuple< long, int > Tuple2
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( Ge2Test  ,
CanDescribeSelf   
)

Definition at line 1956 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, testing::Ge(), and m.

1956  {
1957  Matcher<const Tuple2&> m = Ge();
1958  EXPECT_EQ("are a pair where the first >= the second", Describe(m));
1959 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( Gt2Test  ,
MatchesGreaterThanArguments   
)

Definition at line 1963 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Gt(), m, and testing::internal::MatcherBase< T >::Matches().

1963  {
1964  Matcher<const Tuple2&> m = Gt();
1965  EXPECT_TRUE(m.Matches(Tuple2(5L, 4)));
1966  EXPECT_FALSE(m.Matches(Tuple2(5L, 5)));
1967  EXPECT_FALSE(m.Matches(Tuple2(5L, 6)));
1968 }
internal::GtMatcher< Rhs > Gt(Rhs x)
::testing::tuple< long, int > Tuple2
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( Gt2Test  ,
CanDescribeSelf   
)

Definition at line 1971 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, testing::Gt(), and m.

1971  {
1972  Matcher<const Tuple2&> m = Gt();
1973  EXPECT_EQ("are a pair where the first > the second", Describe(m));
1974 }
string Describe(const Matcher< T > &m)
internal::GtMatcher< Rhs > Gt(Rhs x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
testing::gmock_matchers_test::TEST ( Le2Test  ,
MatchesLessThanOrEqualArguments   
)

Definition at line 1978 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Le(), m, and testing::internal::MatcherBase< T >::Matches().

1978  {
1979  Matcher<const Tuple2&> m = Le();
1980  EXPECT_TRUE(m.Matches(Tuple2(5L, 6)));
1981  EXPECT_TRUE(m.Matches(Tuple2(5L, 5)));
1982  EXPECT_FALSE(m.Matches(Tuple2(5L, 4)));
1983 }
::testing::tuple< long, int > Tuple2
internal::LeMatcher< Rhs > Le(Rhs x)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( Le2Test  ,
CanDescribeSelf   
)

Definition at line 1986 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, testing::Le(), and m.

1986  {
1987  Matcher<const Tuple2&> m = Le();
1988  EXPECT_EQ("are a pair where the first <= the second", Describe(m));
1989 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::LeMatcher< Rhs > Le(Rhs x)
static map< string, int > m
testing::gmock_matchers_test::TEST ( Lt2Test  ,
MatchesLessThanArguments   
)

Definition at line 1993 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Lt(), m, and testing::internal::MatcherBase< T >::Matches().

1993  {
1994  Matcher<const Tuple2&> m = Lt();
1995  EXPECT_TRUE(m.Matches(Tuple2(5L, 6)));
1996  EXPECT_FALSE(m.Matches(Tuple2(5L, 5)));
1997  EXPECT_FALSE(m.Matches(Tuple2(5L, 4)));
1998 }
::testing::tuple< long, int > Tuple2
internal::LtMatcher< Rhs > Lt(Rhs x)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( Lt2Test  ,
CanDescribeSelf   
)

Definition at line 2001 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, testing::Lt(), and m.

2001  {
2002  Matcher<const Tuple2&> m = Lt();
2003  EXPECT_EQ("are a pair where the first < the second", Describe(m));
2004 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::LtMatcher< Rhs > Lt(Rhs x)
static map< string, int > m
testing::gmock_matchers_test::TEST ( Ne2Test  ,
MatchesUnequalArguments   
)

Definition at line 2008 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::Ne().

2008  {
2009  Matcher<const Tuple2&> m = Ne();
2010  EXPECT_TRUE(m.Matches(Tuple2(5L, 6)));
2011  EXPECT_TRUE(m.Matches(Tuple2(5L, 4)));
2012  EXPECT_FALSE(m.Matches(Tuple2(5L, 5)));
2013 }
internal::NeMatcher< Rhs > Ne(Rhs x)
::testing::tuple< long, int > Tuple2
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( Ne2Test  ,
CanDescribeSelf   
)

Definition at line 2016 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, m, and testing::Ne().

2016  {
2017  Matcher<const Tuple2&> m = Ne();
2018  EXPECT_EQ("are an unequal pair", Describe(m));
2019 }
string Describe(const Matcher< T > &m)
internal::NeMatcher< Rhs > Ne(Rhs x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
testing::gmock_matchers_test::TEST ( NotTest  ,
NegatesMatcher   
)

Definition at line 2022 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::Not().

2022  {
2023  Matcher<int> m;
2024  m = Not(Eq(2));
2025  EXPECT_TRUE(m.Matches(3));
2026  EXPECT_FALSE(m.Matches(2));
2027 }
internal::EqMatcher< T > Eq(T x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( NotTest  ,
CanDescribeSelf   
)

Definition at line 2030 of file gmock-matchers_test.cc.

References Describe(), testing::Eq(), EXPECT_EQ, m, and testing::Not().

2030  {
2031  Matcher<int> m = Not(Eq(5));
2032  EXPECT_EQ("isn't equal to 5", Describe(m));
2033 }
string Describe(const Matcher< T > &m)
internal::EqMatcher< T > Eq(T x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
static map< string, int > m
testing::gmock_matchers_test::TEST ( NotTest  ,
NotMatcherSafelyCastsMonomorphicMatchers   
)

Definition at line 2036 of file gmock-matchers_test.cc.

References testing::Gt(), m, and testing::Not().

2036  {
2037  // greater_than_5 is a monomorphic matcher.
2038  Matcher<int> greater_than_5 = Gt(5);
2039 
2040  Matcher<const int&> m = Not(greater_than_5);
2041  Matcher<int&> m2 = Not(greater_than_5);
2042  Matcher<int&> m3 = Not(m);
2043 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
static map< string, int > m
testing::gmock_matchers_test::TEST ( AllOfTest  ,
MatchesWhenAllMatch   
)

Definition at line 2057 of file gmock-matchers_test.cc.

References testing::AllOf(), AllOfMatches(), Describe(), testing::EndsWith(), EXPECT_FALSE, EXPECT_THAT, EXPECT_TRUE, testing::Ge(), testing::Gt(), testing::Le(), testing::Lt(), m, testing::internal::MatcherBase< T >::Matches(), testing::Ne(), and testing::internal::TEST().

2057  {
2058  Matcher<int> m;
2059  m = AllOf(Le(2), Ge(1));
2060  EXPECT_TRUE(m.Matches(1));
2061  EXPECT_TRUE(m.Matches(2));
2062  EXPECT_FALSE(m.Matches(0));
2063  EXPECT_FALSE(m.Matches(3));
2064 
2065  m = AllOf(Gt(0), Ne(1), Ne(2));
2066  EXPECT_TRUE(m.Matches(3));
2067  EXPECT_FALSE(m.Matches(2));
2068  EXPECT_FALSE(m.Matches(1));
2069  EXPECT_FALSE(m.Matches(0));
2070 
2071  m = AllOf(Gt(0), Ne(1), Ne(2), Ne(3));
2072  EXPECT_TRUE(m.Matches(4));
2073  EXPECT_FALSE(m.Matches(3));
2074  EXPECT_FALSE(m.Matches(2));
2075  EXPECT_FALSE(m.Matches(1));
2076  EXPECT_FALSE(m.Matches(0));
2077 
2078  m = AllOf(Ge(0), Lt(10), Ne(3), Ne(5), Ne(7));
2079  EXPECT_TRUE(m.Matches(0));
2080  EXPECT_TRUE(m.Matches(1));
2081  EXPECT_FALSE(m.Matches(3));
2082 
2083  // The following tests for varying number of sub-matchers. Due to the way
2084  // the sub-matchers are handled it is enough to test every sub-matcher once
2085  // with sub-matchers using the same matcher type. Varying matcher types are
2086  // checked for above.
2087  AllOfMatches(2, AllOf(Ne(1), Ne(2)));
2088  AllOfMatches(3, AllOf(Ne(1), Ne(2), Ne(3)));
2089  AllOfMatches(4, AllOf(Ne(1), Ne(2), Ne(3), Ne(4)));
2090  AllOfMatches(5, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5)));
2091  AllOfMatches(6, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6)));
2092  AllOfMatches(7, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7)));
2093  AllOfMatches(8, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7),
2094  Ne(8)));
2095  AllOfMatches(9, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7),
2096  Ne(8), Ne(9)));
2097  AllOfMatches(10, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7), Ne(8),
2098  Ne(9), Ne(10)));
2099 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::NeMatcher< Rhs > Ne(Rhs x)
void AllOfMatches(int num, const Matcher< int > &m)
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::LeMatcher< Rhs > Le(Rhs x)
static map< string, int > m
StrictConjunction< T< As >... > AllOf
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( AllOfTest  ,
CanDescribeSelf   
)

Definition at line 2124 of file gmock-matchers_test.cc.

References testing::AllOf(), Describe(), EXPECT_EQ, testing::Ge(), testing::Gt(), testing::Le(), testing::Lt(), m, and testing::Ne().

2124  {
2125  Matcher<int> m;
2126  m = AllOf(Le(2), Ge(1));
2127  EXPECT_EQ("(is <= 2) and (is >= 1)", Describe(m));
2128 
2129  m = AllOf(Gt(0), Ne(1), Ne(2));
2130  EXPECT_EQ("(is > 0) and "
2131  "((isn't equal to 1) and "
2132  "(isn't equal to 2))",
2133  Describe(m));
2134 
2135 
2136  m = AllOf(Gt(0), Ne(1), Ne(2), Ne(3));
2137  EXPECT_EQ("((is > 0) and "
2138  "(isn't equal to 1)) and "
2139  "((isn't equal to 2) and "
2140  "(isn't equal to 3))",
2141  Describe(m));
2142 
2143 
2144  m = AllOf(Ge(0), Lt(10), Ne(3), Ne(5), Ne(7));
2145  EXPECT_EQ("((is >= 0) and "
2146  "(is < 10)) and "
2147  "((isn't equal to 3) and "
2148  "((isn't equal to 5) and "
2149  "(isn't equal to 7)))",
2150  Describe(m));
2151 }
string Describe(const Matcher< T > &m)
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::NeMatcher< Rhs > Ne(Rhs x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::LeMatcher< Rhs > Le(Rhs x)
static map< string, int > m
StrictConjunction< T< As >... > AllOf
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( AllOfTest  ,
CanDescribeNegation   
)

Definition at line 2154 of file gmock-matchers_test.cc.

References testing::AllOf(), DescribeNegation(), EXPECT_EQ, testing::Ge(), testing::Gt(), testing::Le(), testing::Lt(), m, and testing::Ne().

2154  {
2155  Matcher<int> m;
2156  m = AllOf(Le(2), Ge(1));
2157  EXPECT_EQ("(isn't <= 2) or "
2158  "(isn't >= 1)",
2159  DescribeNegation(m));
2160 
2161  m = AllOf(Gt(0), Ne(1), Ne(2));
2162  EXPECT_EQ("(isn't > 0) or "
2163  "((is equal to 1) or "
2164  "(is equal to 2))",
2165  DescribeNegation(m));
2166 
2167 
2168  m = AllOf(Gt(0), Ne(1), Ne(2), Ne(3));
2169  EXPECT_EQ("((isn't > 0) or "
2170  "(is equal to 1)) or "
2171  "((is equal to 2) or "
2172  "(is equal to 3))",
2173  DescribeNegation(m));
2174 
2175 
2176  m = AllOf(Ge(0), Lt(10), Ne(3), Ne(5), Ne(7));
2177  EXPECT_EQ("((isn't >= 0) or "
2178  "(isn't < 10)) or "
2179  "((is equal to 3) or "
2180  "((is equal to 5) or "
2181  "(is equal to 7)))",
2182  DescribeNegation(m));
2183 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::NeMatcher< Rhs > Ne(Rhs x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::LeMatcher< Rhs > Le(Rhs x)
static map< string, int > m
StrictConjunction< T< As >... > AllOf
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( AllOfTest  ,
AllOfMatcherSafelyCastsMonomorphicMatchers   
)

Definition at line 2186 of file gmock-matchers_test.cc.

References testing::AllOf(), testing::Gt(), testing::Lt(), and m.

2186  {
2187  // greater_than_5 and less_than_10 are monomorphic matchers.
2188  Matcher<int> greater_than_5 = Gt(5);
2189  Matcher<int> less_than_10 = Lt(10);
2190 
2191  Matcher<const int&> m = AllOf(greater_than_5, less_than_10);
2192  Matcher<int&> m2 = AllOf(greater_than_5, less_than_10);
2193  Matcher<int&> m3 = AllOf(greater_than_5, m2);
2194 
2195  // Tests that BothOf works when composing itself.
2196  Matcher<const int&> m4 = AllOf(greater_than_5, less_than_10, less_than_10);
2197  Matcher<int&> m5 = AllOf(greater_than_5, less_than_10, less_than_10);
2198 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::LtMatcher< Rhs > Lt(Rhs x)
static map< string, int > m
StrictConjunction< T< As >... > AllOf
testing::gmock_matchers_test::TEST ( AllOfTest  ,
ExplainsResult   
)

Definition at line 2200 of file gmock-matchers_test.cc.

References testing::AllOf(), EXPECT_EQ, Explain(), GreaterThan(), testing::Lt(), and m.

2200  {
2201  Matcher<int> m;
2202 
2203  // Successful match. Both matchers need to explain. The second
2204  // matcher doesn't give an explanation, so only the first matcher's
2205  // explanation is printed.
2206  m = AllOf(GreaterThan(10), Lt(30));
2207  EXPECT_EQ("which is 15 more than 10", Explain(m, 25));
2208 
2209  // Successful match. Both matchers need to explain.
2210  m = AllOf(GreaterThan(10), GreaterThan(20));
2211  EXPECT_EQ("which is 20 more than 10, and which is 10 more than 20",
2212  Explain(m, 30));
2213 
2214  // Successful match. All matchers need to explain. The second
2215  // matcher doesn't given an explanation.
2216  m = AllOf(GreaterThan(10), Lt(30), GreaterThan(20));
2217  EXPECT_EQ("which is 15 more than 10, and which is 5 more than 20",
2218  Explain(m, 25));
2219 
2220  // Successful match. All matchers need to explain.
2221  m = AllOf(GreaterThan(10), GreaterThan(20), GreaterThan(30));
2222  EXPECT_EQ("which is 30 more than 10, and which is 20 more than 20, "
2223  "and which is 10 more than 30",
2224  Explain(m, 40));
2225 
2226  // Failed match. The first matcher, which failed, needs to
2227  // explain.
2228  m = AllOf(GreaterThan(10), GreaterThan(20));
2229  EXPECT_EQ("which is 5 less than 10", Explain(m, 5));
2230 
2231  // Failed match. The second matcher, which failed, needs to
2232  // explain. Since it doesn't given an explanation, nothing is
2233  // printed.
2234  m = AllOf(GreaterThan(10), Lt(30));
2235  EXPECT_EQ("", Explain(m, 40));
2236 
2237  // Failed match. The second matcher, which failed, needs to
2238  // explain.
2239  m = AllOf(GreaterThan(10), GreaterThan(20));
2240  EXPECT_EQ("which is 5 less than 20", Explain(m, 15));
2241 }
Matcher< int > GreaterThan(int n)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
internal::LtMatcher< Rhs > Lt(Rhs x)
static map< string, int > m
StrictConjunction< T< As >... > AllOf
testing::gmock_matchers_test::TEST ( AnyOfTest  ,
MatchesWhenAnyMatches   
)

Definition at line 2255 of file gmock-matchers_test.cc.

References testing::AnyOf(), AnyOfMatches(), Describe(), testing::EndsWith(), testing::Eq(), EXPECT_FALSE, EXPECT_THAT, EXPECT_TRUE, testing::Ge(), testing::Gt(), testing::Le(), testing::Lt(), m, testing::internal::MatcherBase< T >::Matches(), and testing::internal::TEST().

2255  {
2256  Matcher<int> m;
2257  m = AnyOf(Le(1), Ge(3));
2258  EXPECT_TRUE(m.Matches(1));
2259  EXPECT_TRUE(m.Matches(4));
2260  EXPECT_FALSE(m.Matches(2));
2261 
2262  m = AnyOf(Lt(0), Eq(1), Eq(2));
2263  EXPECT_TRUE(m.Matches(-1));
2264  EXPECT_TRUE(m.Matches(1));
2265  EXPECT_TRUE(m.Matches(2));
2266  EXPECT_FALSE(m.Matches(0));
2267 
2268  m = AnyOf(Lt(0), Eq(1), Eq(2), Eq(3));
2269  EXPECT_TRUE(m.Matches(-1));
2270  EXPECT_TRUE(m.Matches(1));
2271  EXPECT_TRUE(m.Matches(2));
2272  EXPECT_TRUE(m.Matches(3));
2273  EXPECT_FALSE(m.Matches(0));
2274 
2275  m = AnyOf(Le(0), Gt(10), 3, 5, 7);
2276  EXPECT_TRUE(m.Matches(0));
2277  EXPECT_TRUE(m.Matches(11));
2278  EXPECT_TRUE(m.Matches(3));
2279  EXPECT_FALSE(m.Matches(2));
2280 
2281  // The following tests for varying number of sub-matchers. Due to the way
2282  // the sub-matchers are handled it is enough to test every sub-matcher once
2283  // with sub-matchers using the same matcher type. Varying matcher types are
2284  // checked for above.
2285  AnyOfMatches(2, AnyOf(1, 2));
2286  AnyOfMatches(3, AnyOf(1, 2, 3));
2287  AnyOfMatches(4, AnyOf(1, 2, 3, 4));
2288  AnyOfMatches(5, AnyOf(1, 2, 3, 4, 5));
2289  AnyOfMatches(6, AnyOf(1, 2, 3, 4, 5, 6));
2290  AnyOfMatches(7, AnyOf(1, 2, 3, 4, 5, 6, 7));
2291  AnyOfMatches(8, AnyOf(1, 2, 3, 4, 5, 6, 7, 8));
2292  AnyOfMatches(9, AnyOf(1, 2, 3, 4, 5, 6, 7, 8, 9));
2293  AnyOfMatches(10, AnyOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
2294 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::EqMatcher< T > Eq(T x)
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::LeMatcher< Rhs > Le(Rhs x)
internal::AnyOfResult2< M1, M2 >::type AnyOf(M1 m1, M2 m2)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
void AnyOfMatches(int num, const Matcher< int > &m)
testing::gmock_matchers_test::TEST ( AnyOfTest  ,
CanDescribeSelf   
)

Definition at line 2315 of file gmock-matchers_test.cc.

References testing::AnyOf(), Describe(), testing::Eq(), EXPECT_EQ, testing::Ge(), testing::Gt(), testing::Le(), testing::Lt(), and m.

2315  {
2316  Matcher<int> m;
2317  m = AnyOf(Le(1), Ge(3));
2318  EXPECT_EQ("(is <= 1) or (is >= 3)",
2319  Describe(m));
2320 
2321  m = AnyOf(Lt(0), Eq(1), Eq(2));
2322  EXPECT_EQ("(is < 0) or "
2323  "((is equal to 1) or (is equal to 2))",
2324  Describe(m));
2325 
2326  m = AnyOf(Lt(0), Eq(1), Eq(2), Eq(3));
2327  EXPECT_EQ("((is < 0) or "
2328  "(is equal to 1)) or "
2329  "((is equal to 2) or "
2330  "(is equal to 3))",
2331  Describe(m));
2332 
2333  m = AnyOf(Le(0), Gt(10), 3, 5, 7);
2334  EXPECT_EQ("((is <= 0) or "
2335  "(is > 10)) or "
2336  "((is equal to 3) or "
2337  "((is equal to 5) or "
2338  "(is equal to 7)))",
2339  Describe(m));
2340 }
string Describe(const Matcher< T > &m)
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::EqMatcher< T > Eq(T x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::LeMatcher< Rhs > Le(Rhs x)
internal::AnyOfResult2< M1, M2 >::type AnyOf(M1 m1, M2 m2)
static map< string, int > m
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( AnyOfTest  ,
CanDescribeNegation   
)

Definition at line 2343 of file gmock-matchers_test.cc.

References testing::AnyOf(), DescribeNegation(), testing::Eq(), EXPECT_EQ, testing::Ge(), testing::Gt(), testing::Le(), testing::Lt(), and m.

2343  {
2344  Matcher<int> m;
2345  m = AnyOf(Le(1), Ge(3));
2346  EXPECT_EQ("(isn't <= 1) and (isn't >= 3)",
2347  DescribeNegation(m));
2348 
2349  m = AnyOf(Lt(0), Eq(1), Eq(2));
2350  EXPECT_EQ("(isn't < 0) and "
2351  "((isn't equal to 1) and (isn't equal to 2))",
2352  DescribeNegation(m));
2353 
2354  m = AnyOf(Lt(0), Eq(1), Eq(2), Eq(3));
2355  EXPECT_EQ("((isn't < 0) and "
2356  "(isn't equal to 1)) and "
2357  "((isn't equal to 2) and "
2358  "(isn't equal to 3))",
2359  DescribeNegation(m));
2360 
2361  m = AnyOf(Le(0), Gt(10), 3, 5, 7);
2362  EXPECT_EQ("((isn't <= 0) and "
2363  "(isn't > 10)) and "
2364  "((isn't equal to 3) and "
2365  "((isn't equal to 5) and "
2366  "(isn't equal to 7)))",
2367  DescribeNegation(m));
2368 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::EqMatcher< T > Eq(T x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::LeMatcher< Rhs > Le(Rhs x)
internal::AnyOfResult2< M1, M2 >::type AnyOf(M1 m1, M2 m2)
static map< string, int > m
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( AnyOfTest  ,
AnyOfMatcherSafelyCastsMonomorphicMatchers   
)

Definition at line 2371 of file gmock-matchers_test.cc.

References testing::AnyOf(), testing::Gt(), testing::Lt(), and m.

2371  {
2372  // greater_than_5 and less_than_10 are monomorphic matchers.
2373  Matcher<int> greater_than_5 = Gt(5);
2374  Matcher<int> less_than_10 = Lt(10);
2375 
2376  Matcher<const int&> m = AnyOf(greater_than_5, less_than_10);
2377  Matcher<int&> m2 = AnyOf(greater_than_5, less_than_10);
2378  Matcher<int&> m3 = AnyOf(greater_than_5, m2);
2379 
2380  // Tests that EitherOf works when composing itself.
2381  Matcher<const int&> m4 = AnyOf(greater_than_5, less_than_10, less_than_10);
2382  Matcher<int&> m5 = AnyOf(greater_than_5, less_than_10, less_than_10);
2383 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::AnyOfResult2< M1, M2 >::type AnyOf(M1 m1, M2 m2)
static map< string, int > m
testing::gmock_matchers_test::TEST ( AnyOfTest  ,
ExplainsResult   
)

Definition at line 2385 of file gmock-matchers_test.cc.

References testing::AnyOf(), EXPECT_EQ, Explain(), GreaterThan(), testing::Gt(), testing::Lt(), and m.

2385  {
2386  Matcher<int> m;
2387 
2388  // Failed match. Both matchers need to explain. The second
2389  // matcher doesn't give an explanation, so only the first matcher's
2390  // explanation is printed.
2391  m = AnyOf(GreaterThan(10), Lt(0));
2392  EXPECT_EQ("which is 5 less than 10", Explain(m, 5));
2393 
2394  // Failed match. Both matchers need to explain.
2395  m = AnyOf(GreaterThan(10), GreaterThan(20));
2396  EXPECT_EQ("which is 5 less than 10, and which is 15 less than 20",
2397  Explain(m, 5));
2398 
2399  // Failed match. All matchers need to explain. The second
2400  // matcher doesn't given an explanation.
2401  m = AnyOf(GreaterThan(10), Gt(20), GreaterThan(30));
2402  EXPECT_EQ("which is 5 less than 10, and which is 25 less than 30",
2403  Explain(m, 5));
2404 
2405  // Failed match. All matchers need to explain.
2406  m = AnyOf(GreaterThan(10), GreaterThan(20), GreaterThan(30));
2407  EXPECT_EQ("which is 5 less than 10, and which is 15 less than 20, "
2408  "and which is 25 less than 30",
2409  Explain(m, 5));
2410 
2411  // Successful match. The first matcher, which succeeded, needs to
2412  // explain.
2413  m = AnyOf(GreaterThan(10), GreaterThan(20));
2414  EXPECT_EQ("which is 5 more than 10", Explain(m, 15));
2415 
2416  // Successful match. The second matcher, which succeeded, needs to
2417  // explain. Since it doesn't given an explanation, nothing is
2418  // printed.
2419  m = AnyOf(GreaterThan(10), Lt(30));
2420  EXPECT_EQ("", Explain(m, 0));
2421 
2422  // Successful match. The second matcher, which succeeded, needs to
2423  // explain.
2424  m = AnyOf(GreaterThan(30), GreaterThan(20));
2425  EXPECT_EQ("which is 5 more than 20", Explain(m, 25));
2426 }
Matcher< int > GreaterThan(int n)
internal::GtMatcher< Rhs > Gt(Rhs x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::AnyOfResult2< M1, M2 >::type AnyOf(M1 m1, M2 m2)
static map< string, int > m
testing::gmock_matchers_test::TEST ( TrulyTest  ,
MatchesWhatSatisfiesThePredicate   
)

Definition at line 2462 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, IsPositive(), m, testing::internal::MatcherBase< T >::Matches(), and testing::Truly().

2462  {
2463  Matcher<double> m = Truly(IsPositive);
2464  EXPECT_TRUE(m.Matches(2.0));
2465  EXPECT_FALSE(m.Matches(-1.5));
2466 }
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
PolymorphicMatcher< internal::TrulyMatcher< Predicate > > Truly(Predicate pred)
testing::gmock_matchers_test::TEST ( TrulyTest  ,
CanBeUsedWithFunctor   
)

Definition at line 2469 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::Truly().

2469  {
2470  Matcher<int> m = Truly(IsGreaterThan(5));
2471  EXPECT_TRUE(m.Matches(6));
2472  EXPECT_FALSE(m.Matches(4));
2473 }
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
PolymorphicMatcher< internal::TrulyMatcher< Predicate > > Truly(Predicate pred)
testing::gmock_matchers_test::TEST ( TrulyTest  ,
PredicateCanReturnAClassConvertibleToBool   
)

Definition at line 2492 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, IsNotZero(), m, testing::internal::MatcherBase< T >::Matches(), and testing::Truly().

2492  {
2493  Matcher<int> m = Truly(IsNotZero);
2494  EXPECT_TRUE(m.Matches(1));
2495  EXPECT_FALSE(m.Matches(0));
2496 }
ConvertibleToBool IsNotZero(int number)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
PolymorphicMatcher< internal::TrulyMatcher< Predicate > > Truly(Predicate pred)
testing::gmock_matchers_test::TEST ( TrulyTest  ,
CanDescribeSelf   
)

Definition at line 2499 of file gmock-matchers_test.cc.

References Describe(), EXPECT_EQ, IsPositive(), m, and testing::Truly().

2499  {
2500  Matcher<double> m = Truly(IsPositive);
2501  EXPECT_EQ("satisfies the given predicate",
2502  Describe(m));
2503 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
PolymorphicMatcher< internal::TrulyMatcher< Predicate > > Truly(Predicate pred)
testing::gmock_matchers_test::TEST ( TrulyTest  ,
WorksForByRefArguments   
)

Definition at line 2507 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), ReferencesFooAndIsZero(), and testing::Truly().

2507  {
2508  Matcher<const int&> m = Truly(ReferencesFooAndIsZero);
2509  EXPECT_TRUE(m.Matches(foo));
2510  int n = 0;
2511  EXPECT_FALSE(m.Matches(n));
2512 }
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool ReferencesFooAndIsZero(const int &n)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
PolymorphicMatcher< internal::TrulyMatcher< Predicate > > Truly(Predicate pred)
testing::gmock_matchers_test::TEST ( MatchesTest  ,
IsSatisfiedByWhatMatchesTheMatcher   
)

Definition at line 2516 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), and testing::Matches().

2516  {
2517  EXPECT_TRUE(Matches(Ge(0))(1));
2518  EXPECT_FALSE(Matches(Eq('a'))('b'));
2519 }
internal::EqMatcher< T > Eq(T x)
internal::MatcherAsPredicate< M > Matches(M matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( MatchesTest  ,
WorksOnByRefArguments   
)

Definition at line 2523 of file gmock-matchers_test.cc.

References testing::AllOf(), testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, m, testing::Matches(), and testing::Ref().

2523  {
2524  int m = 0, n = 0;
2525  EXPECT_TRUE(Matches(AllOf(Ref(n), Eq(0)))(n));
2526  EXPECT_FALSE(Matches(Ref(m))(n));
2527 }
internal::EqMatcher< T > Eq(T x)
internal::RefMatcher< T & > Ref(T &x)
internal::MatcherAsPredicate< M > Matches(M matcher)
static map< string, int > m
StrictConjunction< T< As >... > AllOf
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( MatchesTest  ,
WorksWithMatcherOnNonRefType   
)

Definition at line 2531 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, and testing::Matches().

2531  {
2532  Matcher<int> eq5 = Eq(5);
2533  EXPECT_TRUE(Matches(eq5)(5));
2534  EXPECT_FALSE(Matches(eq5)(2));
2535 }
internal::EqMatcher< T > Eq(T x)
internal::MatcherAsPredicate< M > Matches(M matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ValueTest  ,
WorksWithPolymorphicMatcher   
)

Definition at line 2540 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Gt(), testing::StartsWith(), and testing::Value().

2540  {
2541  EXPECT_TRUE(Value("hi", StartsWith("h")));
2542  EXPECT_FALSE(Value(5, Gt(10)));
2543 }
internal::GtMatcher< Rhs > Gt(Rhs x)
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
bool Value(const T &value, M matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ValueTest  ,
WorksWithMonomorphicMatcher   
)

Definition at line 2545 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, testing::Ref(), and testing::Value().

2545  {
2546  const Matcher<int> is_zero = Eq(0);
2547  EXPECT_TRUE(Value(0, is_zero));
2548  EXPECT_FALSE(Value('a', is_zero));
2549 
2550  int n = 0;
2551  const Matcher<const int&> ref_n = Ref(n);
2552  EXPECT_TRUE(Value(n, ref_n));
2553  EXPECT_FALSE(Value(1, ref_n));
2554 }
internal::EqMatcher< T > Eq(T x)
internal::RefMatcher< T & > Ref(T &x)
bool Value(const T &value, M matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ExplainMatchResultTest  ,
WorksWithPolymorphicMatcher   
)

Definition at line 2556 of file gmock-matchers_test.cc.

References EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, testing::ExplainMatchResult(), testing::Ge(), PolymorphicIsEven(), and testing::StringMatchResultListener::str().

2556  {
2557  StringMatchResultListener listener1;
2558  EXPECT_TRUE(ExplainMatchResult(PolymorphicIsEven(), 42, &listener1));
2559  EXPECT_EQ("% 2 == 0", listener1.str());
2560 
2561  StringMatchResultListener listener2;
2562  EXPECT_FALSE(ExplainMatchResult(Ge(42), 1.5, &listener2));
2563  EXPECT_EQ("", listener2.str());
2564 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicMatcher< PolymorphicIsEvenImpl > PolymorphicIsEven()
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( ExplainMatchResultTest  ,
WorksWithMonomorphicMatcher   
)

Definition at line 2566 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, testing::ExplainMatchResult(), PolymorphicIsEven(), and testing::StringMatchResultListener::str().

2566  {
2567  const Matcher<int> is_even = PolymorphicIsEven();
2568  StringMatchResultListener listener1;
2569  EXPECT_TRUE(ExplainMatchResult(is_even, 42, &listener1));
2570  EXPECT_EQ("% 2 == 0", listener1.str());
2571 
2572  const Matcher<const double&> is_zero = Eq(0);
2573  StringMatchResultListener listener2;
2574  EXPECT_FALSE(ExplainMatchResult(is_zero, 1.5, &listener2));
2575  EXPECT_EQ("", listener2.str());
2576 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
PolymorphicMatcher< PolymorphicIsEvenImpl > PolymorphicIsEven()
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ExplainMatchResultTest  ,
WorksInsideMATCHER   
)

Definition at line 2582 of file gmock-matchers_test.cc.

References testing::Eq(), and EXPECT_THAT.

2582  {
2583  EXPECT_THAT(0, Really(Eq(0)));
2584 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( AllArgsTest  ,
WorksForTuple   
)

Definition at line 2586 of file gmock-matchers_test.cc.

References testing::AllArgs(), EXPECT_THAT, testing::Lt(), std::tr1::make_tuple(), and testing::Not().

2586  {
2587  EXPECT_THAT(make_tuple(1, 2L), AllArgs(Lt()));
2588  EXPECT_THAT(make_tuple(2L, 1), Not(AllArgs(Lt())));
2589 }
InnerMatcher AllArgs(const InnerMatcher &matcher)
tuple make_tuple()
Definition: gtest-tuple.h:675
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( AllArgsTest  ,
WorksForNonTuple   
)

Definition at line 2591 of file gmock-matchers_test.cc.

References testing::AllArgs(), testing::Eq(), EXPECT_THAT, testing::Gt(), and testing::Not().

2591  {
2592  EXPECT_THAT(42, AllArgs(Gt(0)));
2593  EXPECT_THAT('a', Not(AllArgs(Eq('b'))));
2594 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::EqMatcher< T > Eq(T x)
InnerMatcher AllArgs(const InnerMatcher &matcher)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( AllArgsTest  ,
WorksInWithClause   
)

Definition at line 2606 of file gmock-matchers_test.cc.

References testing::_, testing::AllArgs(), EXPECT_CALL, EXPECT_EQ, testing::Gt(), testing::Lt(), ON_CALL, and testing::Return().

2606  {
2607  AllArgsHelper helper;
2608  ON_CALL(helper, Helper(_, _))
2609  .With(AllArgs(Lt()))
2610  .WillByDefault(Return(1));
2611  EXPECT_CALL(helper, Helper(_, _));
2612  EXPECT_CALL(helper, Helper(_, _))
2613  .With(AllArgs(Gt()))
2614  .WillOnce(Return(2));
2615 
2616  EXPECT_EQ(1, helper.Helper('\1', 2));
2617  EXPECT_EQ(2, helper.Helper('a', 1));
2618 }
internal::GtMatcher< Rhs > Gt(Rhs x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
InnerMatcher AllArgs(const InnerMatcher &matcher)
internal::LtMatcher< Rhs > Lt(Rhs x)
#define ON_CALL(obj, call)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
internal::ReturnAction< R > Return(R value)
testing::gmock_matchers_test::TEST ( MatcherAssertionTest  ,
WorksWhenMatcherIsSatisfied   
)

Definition at line 2622 of file gmock-matchers_test.cc.

References testing::AllOf(), ASSERT_THAT, testing::EndsWith(), EXPECT_THAT, testing::Ge(), testing::Le(), and testing::StartsWith().

2622  {
2623  ASSERT_THAT(5, Ge(2)) << "This should succeed.";
2624  ASSERT_THAT("Foo", EndsWith("oo"));
2625  EXPECT_THAT(2, AllOf(Le(7), Ge(0))) << "This should succeed too.";
2626  EXPECT_THAT("Hello", StartsWith("Hell"));
2627 }
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
PolymorphicMatcher< internal::EndsWithMatcher< internal::string > > EndsWith(const internal::string &suffix)
internal::LeMatcher< Rhs > Le(Rhs x)
StrictConjunction< T< As >... > AllOf
#define EXPECT_THAT(value, matcher)
#define ASSERT_THAT(value, matcher)
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( MatcherAssertionTest  ,
WorksWhenMatcherIsNotSatisfied   
)

Definition at line 2631 of file gmock-matchers_test.cc.

References testing::AllOf(), ASSERT_THAT, EXPECT_FATAL_FAILURE, EXPECT_NONFATAL_FAILURE, EXPECT_THAT, testing::Ge(), testing::Gt(), testing::Le(), and OfType().

2631  {
2632  // 'n' must be static as it is used in an EXPECT_FATAL_FAILURE(),
2633  // which cannot reference auto variables.
2634  static unsigned short n; // NOLINT
2635  n = 5;
2636 
2637  // VC++ prior to version 8.0 SP1 has a bug where it will not see any
2638  // functions declared in the namespace scope from within nested classes.
2639  // EXPECT/ASSERT_(NON)FATAL_FAILURE macros use nested classes so that all
2640  // namespace-level functions invoked inside them need to be explicitly
2641  // resolved.
2643  "Value of: n\n"
2644  "Expected: is > 10\n"
2645  " Actual: 5" + OfType("unsigned short"));
2646  n = 0;
2649  "Value of: n\n"
2650  "Expected: (is <= 7) and (is >= 5)\n"
2651  " Actual: 0" + OfType("unsigned short"));
2652 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::AllOfResult2< M1, M2 >::type AllOf(M1 m1, M2 m2)
internal::LeMatcher< Rhs > Le(Rhs x)
#define EXPECT_FATAL_FAILURE(statement, substr)
Definition: gtest-spi.h:138
#define EXPECT_THAT(value, matcher)
#define ASSERT_THAT(value, matcher)
string OfType(const string &type_name)
#define EXPECT_NONFATAL_FAILURE(statement, substr)
Definition: gtest-spi.h:204
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( MatcherAssertionTest  ,
WorksForByRefArguments   
)

Definition at line 2656 of file gmock-matchers_test.cc.

References testing::AllOf(), ASSERT_THAT, EXPECT_FATAL_FAILURE, EXPECT_THAT, testing::Le(), testing::Not(), OfType(), and testing::Ref().

2656  {
2657  // We use a static variable here as EXPECT_FATAL_FAILURE() cannot
2658  // reference auto variables.
2659  static int n;
2660  n = 0;
2661  EXPECT_THAT(n, AllOf(Le(7), Ref(n)));
2663  "Value of: n\n"
2664  "Expected: does not reference the variable @");
2665  // Tests the "Actual" part.
2667  "Actual: 0" + OfType("int") + ", which is located @");
2668 }
internal::RefMatcher< T & > Ref(T &x)
internal::LeMatcher< Rhs > Le(Rhs x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_FATAL_FAILURE(statement, substr)
Definition: gtest-spi.h:138
StrictConjunction< T< As >... > AllOf
#define EXPECT_THAT(value, matcher)
#define ASSERT_THAT(value, matcher)
string OfType(const string &type_name)
testing::gmock_matchers_test::TEST ( MatcherAssertionTest  ,
WorksForMonomorphicMatcher   
)

Definition at line 2684 of file gmock-matchers_test.cc.

References ASSERT_THAT, testing::EndsWith(), EXPECT_NONFATAL_FAILURE, EXPECT_THAT, testing::Gt(), OfType(), and testing::StartsWith().

2684  {
2685  Matcher<const char*> starts_with_he = StartsWith("he");
2686  ASSERT_THAT("hello", starts_with_he);
2687 
2688  Matcher<const string&> ends_with_ok = EndsWith("ok");
2689  ASSERT_THAT("book", ends_with_ok);
2690  const string bad = "bad";
2691  EXPECT_NONFATAL_FAILURE(EXPECT_THAT(bad, ends_with_ok),
2692  "Value of: bad\n"
2693  "Expected: ends with \"ok\"\n"
2694  " Actual: \"bad\"");
2695  Matcher<int> is_greater_than_5 = Gt(5);
2696  EXPECT_NONFATAL_FAILURE(EXPECT_THAT(5, is_greater_than_5),
2697  "Value of: 5\n"
2698  "Expected: is > 5\n"
2699  " Actual: 5" + OfType("int"));
2700 }
internal::GtMatcher< Rhs > Gt(Rhs x)
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
PolymorphicMatcher< internal::EndsWithMatcher< internal::string > > EndsWith(const internal::string &suffix)
#define EXPECT_THAT(value, matcher)
#define ASSERT_THAT(value, matcher)
string OfType(const string &type_name)
#define EXPECT_NONFATAL_FAILURE(statement, substr)
Definition: gtest-spi.h:204
testing::gmock_matchers_test::TEST ( PointeeTest  ,
RawPointer   
)

Definition at line 3142 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), and testing::Pointee().

3142  {
3143  const Matcher<int*> m = Pointee(Ge(0));
3144 
3145  int n = 1;
3146  EXPECT_TRUE(m.Matches(&n));
3147  n = -1;
3148  EXPECT_FALSE(m.Matches(&n));
3149  EXPECT_FALSE(m.Matches(NULL));
3150 }
static map< string, int > m
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PointeeTest  ,
RawPointerToConst   
)

Definition at line 3152 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), and testing::Pointee().

3152  {
3153  const Matcher<const double*> m = Pointee(Ge(0));
3154 
3155  double x = 1;
3156  EXPECT_TRUE(m.Matches(&x));
3157  x = -1;
3158  EXPECT_FALSE(m.Matches(&x));
3159  EXPECT_FALSE(m.Matches(NULL));
3160 }
Definition: InvokeTest.cpp:58
static map< string, int > m
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PointeeTest  ,
ReferenceToConstRawPointer   
)

Definition at line 3162 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), and testing::Pointee().

3162  {
3163  const Matcher<int* const &> m = Pointee(Ge(0));
3164 
3165  int n = 1;
3166  EXPECT_TRUE(m.Matches(&n));
3167  n = -1;
3168  EXPECT_FALSE(m.Matches(&n));
3169  EXPECT_FALSE(m.Matches(NULL));
3170 }
static map< string, int > m
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PointeeTest  ,
ReferenceToNonConstRawPointer   
)

Definition at line 3172 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), testing::Pointee(), and x.

3172  {
3173  const Matcher<double* &> m = Pointee(Ge(0));
3174 
3175  double x = 1.0;
3176  double* p = &x;
3177  EXPECT_TRUE(m.Matches(p));
3178  x = -1;
3179  EXPECT_FALSE(m.Matches(p));
3180  p = NULL;
3181  EXPECT_FALSE(m.Matches(p));
3182 }
Definition: InvokeTest.cpp:58
const int x
static map< string, int > m
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PointeeTest  ,
WorksWithConstPropagatingPointers   
)

Definition at line 3304 of file gmock-matchers_test.cc.

References GCC61971::co, EXPECT_FALSE, EXPECT_TRUE, testing::Lt(), m, testing::internal::MatcherBase< T >::Matches(), and testing::Pointee().

3304  {
3305  const Matcher< ConstPropagatingPtr<int> > m = Pointee(Lt(5));
3306  int three = 3;
3307  const ConstPropagatingPtr<int> co(&three);
3308  ConstPropagatingPtr<int> o(&three);
3309  EXPECT_TRUE(m.Matches(o));
3310  EXPECT_TRUE(m.Matches(co));
3311  *o = 6;
3312  EXPECT_FALSE(m.Matches(o));
3313  EXPECT_FALSE(m.Matches(ConstPropagatingPtr<int>()));
3314 }
internal::LtMatcher< Rhs > Lt(Rhs x)
static map< string, int > m
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
constexpr auto co
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( PointeeTest  ,
NeverMatchesNull   
)

Definition at line 3316 of file gmock-matchers_test.cc.

References testing::_, EXPECT_FALSE, m, testing::internal::MatcherBase< T >::Matches(), and testing::Pointee().

3316  {
3317  const Matcher<const char*> m = Pointee(_);
3318  EXPECT_FALSE(m.Matches(NULL));
3319 }
static map< string, int > m
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( PointeeTest  ,
MatchesAgainstAValue   
)

Definition at line 3322 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::Pointee().

3322  {
3323  const Matcher<int*> m = Pointee(5);
3324 
3325  int n = 5;
3326  EXPECT_TRUE(m.Matches(&n));
3327  n = -1;
3328  EXPECT_FALSE(m.Matches(&n));
3329  EXPECT_FALSE(m.Matches(NULL));
3330 }
static map< string, int > m
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( PointeeTest  ,
CanDescribeSelf   
)

Definition at line 3332 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, testing::Gt(), m, and testing::Pointee().

3332  {
3333  const Matcher<int*> m = Pointee(Gt(3));
3334  EXPECT_EQ("points to a value that is > 3", Describe(m));
3335  EXPECT_EQ("does not point to a value that is > 3",
3336  DescribeNegation(m));
3337 }
string Describe(const Matcher< T > &m)
internal::GtMatcher< Rhs > Gt(Rhs x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
static map< string, int > m
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
testing::gmock_matchers_test::TEST ( PointeeTest  ,
CanExplainMatchResult   
)

Definition at line 3339 of file gmock-matchers_test.cc.

References EXPECT_EQ, Explain(), GreaterThan(), m, OfType(), testing::Pointee(), and testing::StartsWith().

3339  {
3340  const Matcher<const string*> m = Pointee(StartsWith("Hi"));
3341 
3342  EXPECT_EQ("", Explain(m, static_cast<const string*>(NULL)));
3343 
3344  const Matcher<long*> m2 = Pointee(GreaterThan(1)); // NOLINT
3345  long n = 3; // NOLINT
3346  EXPECT_EQ("which points to 3" + OfType("long") + ", which is 2 more than 1",
3347  Explain(m2, &n));
3348 }
Matcher< int > GreaterThan(int n)
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
string OfType(const string &type_name)
testing::gmock_matchers_test::TEST ( PointeeTest  ,
AlwaysExplainsPointee   
)

Definition at line 3350 of file gmock-matchers_test.cc.

References EXPECT_EQ, Explain(), m, OfType(), and testing::Pointee().

3350  {
3351  const Matcher<int*> m = Pointee(0);
3352  int n = 42;
3353  EXPECT_EQ("which points to 42" + OfType("int"), Explain(m, &n));
3354 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
string OfType(const string &type_name)
testing::gmock_matchers_test::TEST ( FieldTest  ,
WorksForNonConstField   
)

Definition at line 3401 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, testing::Field(), testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), x, and testing::gmock_matchers_test::AStruct::x.

3401  {
3402  Matcher<AStruct> m = Field(&AStruct::x, Ge(0));
3403 
3404  AStruct a;
3405  EXPECT_TRUE(m.Matches(a));
3406  a.x = -1;
3407  EXPECT_FALSE(m.Matches(a));
3408 }
const int x
static map< string, int > m
char a
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( FieldTest  ,
WorksForConstField   
)

Definition at line 3411 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, testing::Field(), testing::Ge(), testing::Le(), m, and testing::internal::MatcherBase< T >::Matches().

3411  {
3412  AStruct a;
3413 
3414  Matcher<AStruct> m = Field(&AStruct::y, Ge(0.0));
3415  EXPECT_TRUE(m.Matches(a));
3416  m = Field(&AStruct::y, Le(0.0));
3417  EXPECT_FALSE(m.Matches(a));
3418 }
internal::LeMatcher< Rhs > Le(Rhs x)
static map< string, int > m
char a
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( FieldTest  ,
WorksForUncopyableField   
)

Definition at line 3421 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, testing::Field(), m, testing::internal::MatcherBase< T >::Matches(), testing::Not(), testing::Truly(), and ValueIsPositive().

3421  {
3422  AStruct a;
3423 
3424  Matcher<AStruct> m = Field(&AStruct::z, Truly(ValueIsPositive));
3425  EXPECT_TRUE(m.Matches(a));
3426  m = Field(&AStruct::z, Not(Truly(ValueIsPositive)));
3427  EXPECT_FALSE(m.Matches(a));
3428 }
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
bool ValueIsPositive(const Uncopyable &x)
static map< string, int > m
char a
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
PolymorphicMatcher< internal::TrulyMatcher< Predicate > > Truly(Predicate pred)
testing::gmock_matchers_test::TEST ( FieldTest  ,
WorksForPointerField   
)

Definition at line 3431 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, testing::Field(), m, testing::internal::MatcherBase< T >::Matches(), testing::gmock_matchers_test::AStruct::p, and testing::StartsWith().

3431  {
3432  // Matching against NULL.
3433  Matcher<AStruct> m = Field(&AStruct::p, static_cast<const char*>(NULL));
3434  AStruct a;
3435  EXPECT_TRUE(m.Matches(a));
3436  a.p = "hi";
3437  EXPECT_FALSE(m.Matches(a));
3438 
3439  // Matching a pointer that is not NULL.
3440  m = Field(&AStruct::p, StartsWith("hi"));
3441  a.p = "hill";
3442  EXPECT_TRUE(m.Matches(a));
3443  a.p = "hole";
3444  EXPECT_FALSE(m.Matches(a));
3445 }
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
static map< string, int > m
char a
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( FieldTest  ,
WorksForByRefArgument   
)

Definition at line 3448 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, testing::Field(), testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), x, and testing::gmock_matchers_test::AStruct::x.

3448  {
3449  Matcher<const AStruct&> m = Field(&AStruct::x, Ge(0));
3450 
3451  AStruct a;
3452  EXPECT_TRUE(m.Matches(a));
3453  a.x = -1;
3454  EXPECT_FALSE(m.Matches(a));
3455 }
const int x
static map< string, int > m
char a
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( FieldTest  ,
WorksForArgumentOfSubType   
)

Definition at line 3459 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Field(), testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), x, and testing::gmock_matchers_test::AStruct::x.

3459  {
3460  // Note that the matcher expects DerivedStruct but we say AStruct
3461  // inside Field().
3462  Matcher<const DerivedStruct&> m = Field(&AStruct::x, Ge(0));
3463 
3464  DerivedStruct d;
3465  EXPECT_TRUE(m.Matches(d));
3466  d.x = -1;
3467  EXPECT_FALSE(m.Matches(d));
3468 }
const int x
static map< string, int > m
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( FieldTest  ,
WorksForCompatibleMatcherType   
)

Definition at line 3472 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, testing::Field(), testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), x, and testing::gmock_matchers_test::AStruct::x.

3472  {
3473  // The field is an int, but the inner matcher expects a signed char.
3474  Matcher<const AStruct&> m = Field(&AStruct::x,
3475  Matcher<signed char>(Ge(0)));
3476 
3477  AStruct a;
3478  EXPECT_TRUE(m.Matches(a));
3479  a.x = -1;
3480  EXPECT_FALSE(m.Matches(a));
3481 }
const int x
static map< string, int > m
char a
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( FieldTest  ,
CanDescribeSelf   
)

Definition at line 3484 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, testing::Field(), testing::Ge(), m, and x.

3484  {
3485  Matcher<const AStruct&> m = Field(&AStruct::x, Ge(0));
3486 
3487  EXPECT_EQ("is an object whose given field is >= 0", Describe(m));
3488  EXPECT_EQ("is an object whose given field isn't >= 0", DescribeNegation(m));
3489 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const int x
string DescribeNegation(const Matcher< T > &m)
static map< string, int > m
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( FieldTest  ,
CanExplainMatchResult   
)

Definition at line 3492 of file gmock-matchers_test.cc.

References a, EXPECT_EQ, Explain(), testing::Field(), testing::Ge(), GreaterThan(), m, OfType(), x, and testing::gmock_matchers_test::AStruct::x.

3492  {
3493  Matcher<const AStruct&> m = Field(&AStruct::x, Ge(0));
3494 
3495  AStruct a;
3496  a.x = 1;
3497  EXPECT_EQ("whose given field is 1" + OfType("int"), Explain(m, a));
3498 
3499  m = Field(&AStruct::x, GreaterThan(0));
3500  EXPECT_EQ(
3501  "whose given field is 1" + OfType("int") + ", which is 1 more than 0",
3502  Explain(m, a));
3503 }
Matcher< int > GreaterThan(int n)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const int x
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
char a
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
string OfType(const string &type_name)
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( FieldForPointerTest  ,
WorksForPointerToConst   
)

Definition at line 3506 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, testing::Field(), testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), x, and testing::gmock_matchers_test::AStruct::x.

3506  {
3507  Matcher<const AStruct*> m = Field(&AStruct::x, Ge(0));
3508 
3509  AStruct a;
3510  EXPECT_TRUE(m.Matches(&a));
3511  a.x = -1;
3512  EXPECT_FALSE(m.Matches(&a));
3513 }
const int x
static map< string, int > m
char a
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( FieldForPointerTest  ,
WorksForPointerToNonConst   
)

Definition at line 3516 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, testing::Field(), testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), x, and testing::gmock_matchers_test::AStruct::x.

3516  {
3517  Matcher<AStruct*> m = Field(&AStruct::x, Ge(0));
3518 
3519  AStruct a;
3520  EXPECT_TRUE(m.Matches(&a));
3521  a.x = -1;
3522  EXPECT_FALSE(m.Matches(&a));
3523 }
const int x
static map< string, int > m
char a
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( FieldForPointerTest  ,
WorksForReferenceToConstPointer   
)

Definition at line 3526 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, testing::Field(), testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), x, and testing::gmock_matchers_test::AStruct::x.

3526  {
3527  Matcher<AStruct* const&> m = Field(&AStruct::x, Ge(0));
3528 
3529  AStruct a;
3530  EXPECT_TRUE(m.Matches(&a));
3531  a.x = -1;
3532  EXPECT_FALSE(m.Matches(&a));
3533 }
const int x
static map< string, int > m
char a
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( FieldForPointerTest  ,
DoesNotMatchNull   
)

Definition at line 3536 of file gmock-matchers_test.cc.

References testing::_, EXPECT_FALSE, testing::Field(), m, testing::internal::MatcherBase< T >::Matches(), and x.

3536  {
3537  Matcher<const AStruct*> m = Field(&AStruct::x, _);
3538  EXPECT_FALSE(m.Matches(NULL));
3539 }
const int x
static map< string, int > m
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( FieldForPointerTest  ,
WorksForArgumentOfSubType   
)

Definition at line 3543 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Field(), testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), x, and testing::gmock_matchers_test::AStruct::x.

3543  {
3544  // Note that the matcher expects DerivedStruct but we say AStruct
3545  // inside Field().
3546  Matcher<DerivedStruct*> m = Field(&AStruct::x, Ge(0));
3547 
3548  DerivedStruct d;
3549  EXPECT_TRUE(m.Matches(&d));
3550  d.x = -1;
3551  EXPECT_FALSE(m.Matches(&d));
3552 }
const int x
static map< string, int > m
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( FieldForPointerTest  ,
CanDescribeSelf   
)

Definition at line 3555 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, testing::Field(), testing::Ge(), m, and x.

3555  {
3556  Matcher<const AStruct*> m = Field(&AStruct::x, Ge(0));
3557 
3558  EXPECT_EQ("is an object whose given field is >= 0", Describe(m));
3559  EXPECT_EQ("is an object whose given field isn't >= 0", DescribeNegation(m));
3560 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const int x
string DescribeNegation(const Matcher< T > &m)
static map< string, int > m
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( FieldForPointerTest  ,
CanExplainMatchResult   
)

Definition at line 3563 of file gmock-matchers_test.cc.

References a, EXPECT_EQ, Explain(), testing::Field(), testing::Ge(), GreaterThan(), m, OfType(), x, and testing::gmock_matchers_test::AStruct::x.

3563  {
3564  Matcher<const AStruct*> m = Field(&AStruct::x, Ge(0));
3565 
3566  AStruct a;
3567  a.x = 1;
3568  EXPECT_EQ("", Explain(m, static_cast<const AStruct*>(NULL)));
3569  EXPECT_EQ("which points to an object whose given field is 1" + OfType("int"),
3570  Explain(m, &a));
3571 
3572  m = Field(&AStruct::x, GreaterThan(0));
3573  EXPECT_EQ("which points to an object whose given field is 1" + OfType("int") +
3574  ", which is 1 more than 0", Explain(m, &a));
3575 }
Matcher< int > GreaterThan(int n)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const int x
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
char a
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
string OfType(const string &type_name)
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PropertyTest  ,
WorksForNonReferenceProperty   
)

Definition at line 3613 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), testing::Property(), and testing::gmock_matchers_test::AClass::set_n().

3613  {
3614  Matcher<const AClass&> m = Property(&AClass::n, Ge(0));
3615 
3616  AClass a;
3617  a.set_n(1);
3618  EXPECT_TRUE(m.Matches(a));
3619 
3620  a.set_n(-1);
3621  EXPECT_FALSE(m.Matches(a));
3622 }
static map< string, int > m
char a
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PropertyTest  ,
WorksForReferenceToConstProperty   
)

Definition at line 3626 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), testing::Property(), s, testing::gmock_matchers_test::AClass::set_s(), and testing::StartsWith().

3626  {
3627  Matcher<const AClass&> m = Property(&AClass::s, StartsWith("hi"));
3628 
3629  AClass a;
3630  a.set_s("hill");
3631  EXPECT_TRUE(m.Matches(a));
3632 
3633  a.set_s("hole");
3634  EXPECT_FALSE(m.Matches(a));
3635 }
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
static map< string, int > m
char a
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static set< string > s
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( PropertyTest  ,
WorksForReferenceToNonConstProperty   
)

Definition at line 3639 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), testing::Not(), testing::Property(), testing::Ref(), and x.

3639  {
3640  double x = 0.0;
3641  AClass a;
3642 
3643  Matcher<const AClass&> m = Property(&AClass::x, Ref(x));
3644  EXPECT_FALSE(m.Matches(a));
3645 
3646  m = Property(&AClass::x, Not(Ref(x)));
3647  EXPECT_TRUE(m.Matches(a));
3648 }
Definition: InvokeTest.cpp:58
const int x
internal::RefMatcher< T & > Ref(T &x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
static map< string, int > m
char a
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( PropertyTest  ,
WorksForByValueArgument   
)

Definition at line 3652 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), testing::Property(), s, testing::gmock_matchers_test::AClass::set_s(), and testing::StartsWith().

3652  {
3653  Matcher<AClass> m = Property(&AClass::s, StartsWith("hi"));
3654 
3655  AClass a;
3656  a.set_s("hill");
3657  EXPECT_TRUE(m.Matches(a));
3658 
3659  a.set_s("hole");
3660  EXPECT_FALSE(m.Matches(a));
3661 }
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
static map< string, int > m
char a
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static set< string > s
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( PropertyTest  ,
WorksForArgumentOfSubType   
)

Definition at line 3665 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), testing::Property(), and testing::gmock_matchers_test::AClass::set_n().

3665  {
3666  // The matcher expects a DerivedClass, but inside the Property() we
3667  // say AClass.
3668  Matcher<const DerivedClass&> m = Property(&AClass::n, Ge(0));
3669 
3670  DerivedClass d;
3671  d.set_n(1);
3672  EXPECT_TRUE(m.Matches(d));
3673 
3674  d.set_n(-1);
3675  EXPECT_FALSE(m.Matches(d));
3676 }
static map< string, int > m
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PropertyTest  ,
WorksForCompatibleMatcherType   
)

Definition at line 3680 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), testing::Property(), and testing::gmock_matchers_test::AClass::set_n().

3680  {
3681  // n() returns an int but the inner matcher expects a signed char.
3682  Matcher<const AClass&> m = Property(&AClass::n,
3683  Matcher<signed char>(Ge(0)));
3684 
3685  AClass a;
3686  EXPECT_TRUE(m.Matches(a));
3687  a.set_n(-1);
3688  EXPECT_FALSE(m.Matches(a));
3689 }
static map< string, int > m
char a
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PropertyTest  ,
CanDescribeSelf   
)

Definition at line 3692 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, testing::Ge(), m, and testing::Property().

3692  {
3693  Matcher<const AClass&> m = Property(&AClass::n, Ge(0));
3694 
3695  EXPECT_EQ("is an object whose given property is >= 0", Describe(m));
3696  EXPECT_EQ("is an object whose given property isn't >= 0",
3697  DescribeNegation(m));
3698 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
static map< string, int > m
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PropertyTest  ,
CanExplainMatchResult   
)

Definition at line 3701 of file gmock-matchers_test.cc.

References a, EXPECT_EQ, Explain(), testing::Ge(), GreaterThan(), m, OfType(), testing::Property(), and testing::gmock_matchers_test::AClass::set_n().

3701  {
3702  Matcher<const AClass&> m = Property(&AClass::n, Ge(0));
3703 
3704  AClass a;
3705  a.set_n(1);
3706  EXPECT_EQ("whose given property is 1" + OfType("int"), Explain(m, a));
3707 
3708  m = Property(&AClass::n, GreaterThan(0));
3709  EXPECT_EQ(
3710  "whose given property is 1" + OfType("int") + ", which is 1 more than 0",
3711  Explain(m, a));
3712 }
Matcher< int > GreaterThan(int n)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
char a
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
string OfType(const string &type_name)
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PropertyForPointerTest  ,
WorksForPointerToConst   
)

Definition at line 3715 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), testing::Property(), and testing::gmock_matchers_test::AClass::set_n().

3715  {
3716  Matcher<const AClass*> m = Property(&AClass::n, Ge(0));
3717 
3718  AClass a;
3719  a.set_n(1);
3720  EXPECT_TRUE(m.Matches(&a));
3721 
3722  a.set_n(-1);
3723  EXPECT_FALSE(m.Matches(&a));
3724 }
static map< string, int > m
char a
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PropertyForPointerTest  ,
WorksForPointerToNonConst   
)

Definition at line 3727 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), testing::Property(), s, testing::gmock_matchers_test::AClass::set_s(), and testing::StartsWith().

3727  {
3728  Matcher<AClass*> m = Property(&AClass::s, StartsWith("hi"));
3729 
3730  AClass a;
3731  a.set_s("hill");
3732  EXPECT_TRUE(m.Matches(&a));
3733 
3734  a.set_s("hole");
3735  EXPECT_FALSE(m.Matches(&a));
3736 }
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
static map< string, int > m
char a
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static set< string > s
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( PropertyForPointerTest  ,
WorksForReferenceToConstPointer   
)

Definition at line 3740 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), testing::Property(), s, testing::gmock_matchers_test::AClass::set_s(), and testing::StartsWith().

3740  {
3741  Matcher<AClass* const&> m = Property(&AClass::s, StartsWith("hi"));
3742 
3743  AClass a;
3744  a.set_s("hill");
3745  EXPECT_TRUE(m.Matches(&a));
3746 
3747  a.set_s("hole");
3748  EXPECT_FALSE(m.Matches(&a));
3749 }
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
static map< string, int > m
char a
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static set< string > s
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( PropertyForPointerTest  ,
WorksForReferenceToNonConstProperty   
)

Definition at line 3752 of file gmock-matchers_test.cc.

References testing::_, EXPECT_FALSE, m, testing::internal::MatcherBase< T >::Matches(), testing::Property(), and x.

3752  {
3753  Matcher<const AClass*> m = Property(&AClass::x, _);
3754  EXPECT_FALSE(m.Matches(NULL));
3755 }
const int x
static map< string, int > m
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( PropertyForPointerTest  ,
WorksForArgumentOfSubType   
)

Definition at line 3759 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), m, testing::internal::MatcherBase< T >::Matches(), testing::Property(), and testing::gmock_matchers_test::AClass::set_n().

3759  {
3760  // The matcher expects a DerivedClass, but inside the Property() we
3761  // say AClass.
3762  Matcher<const DerivedClass*> m = Property(&AClass::n, Ge(0));
3763 
3764  DerivedClass d;
3765  d.set_n(1);
3766  EXPECT_TRUE(m.Matches(&d));
3767 
3768  d.set_n(-1);
3769  EXPECT_FALSE(m.Matches(&d));
3770 }
static map< string, int > m
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PropertyForPointerTest  ,
CanDescribeSelf   
)

Definition at line 3773 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, testing::Ge(), m, and testing::Property().

3773  {
3774  Matcher<const AClass*> m = Property(&AClass::n, Ge(0));
3775 
3776  EXPECT_EQ("is an object whose given property is >= 0", Describe(m));
3777  EXPECT_EQ("is an object whose given property isn't >= 0",
3778  DescribeNegation(m));
3779 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
static map< string, int > m
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( PropertyForPointerTest  ,
CanExplainMatchResult   
)

Definition at line 3782 of file gmock-matchers_test.cc.

References a, EXPECT_EQ, Explain(), testing::Ge(), GreaterThan(), m, OfType(), testing::Property(), and testing::gmock_matchers_test::AClass::set_n().

3782  {
3783  Matcher<const AClass*> m = Property(&AClass::n, Ge(0));
3784 
3785  AClass a;
3786  a.set_n(1);
3787  EXPECT_EQ("", Explain(m, static_cast<const AClass*>(NULL)));
3788  EXPECT_EQ(
3789  "which points to an object whose given property is 1" + OfType("int"),
3790  Explain(m, &a));
3791 
3792  m = Property(&AClass::n, GreaterThan(0));
3793  EXPECT_EQ("which points to an object whose given property is 1" +
3794  OfType("int") + ", which is 1 more than 0",
3795  Explain(m, &a));
3796 }
Matcher< int > GreaterThan(int n)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
char a
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
string OfType(const string &type_name)
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( ResultOfTest  ,
WorksForFunctionPointers   
)

Definition at line 3804 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, IntToStringFunction(), testing::internal::MatcherBase< T >::Matches(), and testing::ResultOf().

3804  {
3805  Matcher<int> matcher = ResultOf(&IntToStringFunction, Eq(string("foo")));
3806 
3807  EXPECT_TRUE(matcher.Matches(1));
3808  EXPECT_FALSE(matcher.Matches(2));
3809 }
internal::EqMatcher< T > Eq(T x)
typename NonSharedPtr< invoke_result_t< F >>::type ResultOf
Definition: Observer-pre.h:40
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ResultOfTest  ,
CanDescribeItself   
)

Definition at line 3812 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, IntToStringFunction(), testing::ResultOf(), and testing::StrEq().

3812  {
3813  Matcher<int> matcher = ResultOf(&IntToStringFunction, StrEq("foo"));
3814 
3815  EXPECT_EQ("is mapped by the given callable to a value that "
3816  "is equal to \"foo\"", Describe(matcher));
3817  EXPECT_EQ("is mapped by the given callable to a value that "
3818  "isn't equal to \"foo\"", DescribeNegation(matcher));
3819 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
typename NonSharedPtr< invoke_result_t< F >>::type ResultOf
Definition: Observer-pre.h:40
string DescribeNegation(const Matcher< T > &m)
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrEq(const internal::string &str)
testing::gmock_matchers_test::TEST ( ResultOfTest  ,
CanExplainMatchResult   
)

Definition at line 3824 of file gmock-matchers_test.cc.

References EXPECT_EQ, Explain(), testing::Ge(), GreaterThan(), IntFunction(), OfType(), and testing::ResultOf().

3824  {
3825  Matcher<int> matcher = ResultOf(&IntFunction, Ge(85));
3826  EXPECT_EQ("which is mapped by the given callable to 90" + OfType("int"),
3827  Explain(matcher, 36));
3828 
3829  matcher = ResultOf(&IntFunction, GreaterThan(85));
3830  EXPECT_EQ("which is mapped by the given callable to 90" + OfType("int") +
3831  ", which is 5 more than 85", Explain(matcher, 36));
3832 }
Matcher< int > GreaterThan(int n)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
typename NonSharedPtr< invoke_result_t< F >>::type ResultOf
Definition: Observer-pre.h:40
string OfType(const string &type_name)
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( ResultOfTest  ,
WorksForNonReferenceResults   
)

Definition at line 3836 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, IntFunction(), testing::internal::MatcherBase< T >::Matches(), and testing::ResultOf().

3836  {
3837  Matcher<int> matcher = ResultOf(&IntFunction, Eq(80));
3838 
3839  EXPECT_TRUE(matcher.Matches(42));
3840  EXPECT_FALSE(matcher.Matches(36));
3841 }
internal::EqMatcher< T > Eq(T x)
typename NonSharedPtr< invoke_result_t< F >>::type ResultOf
Definition: Observer-pre.h:40
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ResultOfTest  ,
WorksForReferenceToNonConstResults   
)

Definition at line 3851 of file gmock-matchers_test.cc.

References DoubleFunction(), EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), testing::Ref(), RefUncopyableFunction(), testing::ResultOf(), and x.

3851  {
3852  double x = 3.14;
3853  double x2 = x;
3854  Matcher<double&> matcher = ResultOf(&DoubleFunction, Ref(x));
3855 
3856  EXPECT_TRUE(matcher.Matches(x));
3857  EXPECT_FALSE(matcher.Matches(x2));
3858 
3859  // Test that ResultOf works with uncopyable objects
3860  Uncopyable obj(0);
3861  Uncopyable obj2(0);
3862  Matcher<Uncopyable&> matcher2 =
3864 
3865  EXPECT_TRUE(matcher2.Matches(obj));
3866  EXPECT_FALSE(matcher2.Matches(obj2));
3867 }
Definition: InvokeTest.cpp:58
const int x
typename NonSharedPtr< invoke_result_t< F >>::type ResultOf
Definition: Observer-pre.h:40
double & DoubleFunction(double &input)
internal::RefMatcher< T & > Ref(T &x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
Uncopyable & RefUncopyableFunction(Uncopyable &obj)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ResultOfTest  ,
WorksForReferenceToConstResults   
)

Definition at line 3873 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), testing::Ref(), testing::ResultOf(), s, and StringFunction().

3873  {
3874  string s = "foo";
3875  string s2 = s;
3876  Matcher<const string&> matcher = ResultOf(&StringFunction, Ref(s));
3877 
3878  EXPECT_TRUE(matcher.Matches(s));
3879  EXPECT_FALSE(matcher.Matches(s2));
3880 }
typename NonSharedPtr< invoke_result_t< F >>::type ResultOf
Definition: Observer-pre.h:40
internal::RefMatcher< T & > Ref(T &x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static set< string > s
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
const string & StringFunction(const string &input)
testing::gmock_matchers_test::TEST ( ResultOfTest  ,
WorksForCompatibleMatcherTypes   
)

Definition at line 3884 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), IntFunction(), testing::internal::MatcherBase< T >::Matches(), and testing::ResultOf().

3884  {
3885  // IntFunction() returns int but the inner matcher expects a signed char.
3886  Matcher<int> matcher = ResultOf(IntFunction, Matcher<signed char>(Ge(85)));
3887 
3888  EXPECT_TRUE(matcher.Matches(36));
3889  EXPECT_FALSE(matcher.Matches(42));
3890 }
typename NonSharedPtr< invoke_result_t< F >>::type ResultOf
Definition: Observer-pre.h:40
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( ResultOfDeathTest  ,
DiesOnNullFunctionPointers   
)

Definition at line 3894 of file gmock-matchers_test.cc.

References dummy(), testing::Eq(), EXPECT_DEATH_IF_SUPPORTED, and testing::ResultOf().

3894  {
3896  ResultOf(static_cast<string(*)(int dummy)>(NULL), Eq(string("foo"))),
3897  "NULL function pointer is passed into ResultOf\\(\\)\\.");
3898 }
internal::EqMatcher< T > Eq(T x)
typename NonSharedPtr< invoke_result_t< F >>::type ResultOf
Definition: Observer-pre.h:40
void dummy()
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex)
testing::gmock_matchers_test::TEST ( ResultOfTest  ,
WorksForFunctionReferences   
)

Definition at line 3902 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, IntToStringFunction(), testing::internal::MatcherBase< T >::Matches(), testing::ResultOf(), and testing::StrEq().

3902  {
3903  Matcher<int> matcher = ResultOf(IntToStringFunction, StrEq("foo"));
3904  EXPECT_TRUE(matcher.Matches(1));
3905  EXPECT_FALSE(matcher.Matches(2));
3906 }
typename NonSharedPtr< invoke_result_t< F >>::type ResultOf
Definition: Observer-pre.h:40
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrEq(const internal::string &str)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ResultOfTest  ,
WorksForFunctors   
)

Definition at line 3916 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), and testing::ResultOf().

3916  {
3917  Matcher<int> matcher = ResultOf(Functor(), Eq(string("foo")));
3918 
3919  EXPECT_TRUE(matcher.Matches(1));
3920  EXPECT_FALSE(matcher.Matches(2));
3921 }
internal::EqMatcher< T > Eq(T x)
typename NonSharedPtr< invoke_result_t< F >>::type ResultOf
Definition: Observer-pre.h:40
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ResultOfTest  ,
WorksForPolymorphicFunctors   
)

Definition at line 3932 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), testing::internal::MatcherBase< T >::Matches(), and testing::ResultOf().

3932  {
3933  Matcher<int> matcher_int = ResultOf(PolymorphicFunctor(), Ge(5));
3934 
3935  EXPECT_TRUE(matcher_int.Matches(10));
3936  EXPECT_FALSE(matcher_int.Matches(2));
3937 
3938  Matcher<const char*> matcher_string = ResultOf(PolymorphicFunctor(), Ge(5));
3939 
3940  EXPECT_TRUE(matcher_string.Matches("long string"));
3941  EXPECT_FALSE(matcher_string.Matches("shrt"));
3942 }
typename NonSharedPtr< invoke_result_t< F >>::type ResultOf
Definition: Observer-pre.h:40
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( ResultOfTest  ,
WorksForReferencingCallables   
)

Definition at line 3951 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, testing::internal::MatcherBase< T >::Matches(), ReferencingFunction(), and testing::ResultOf().

3951  {
3952  const int n = 1;
3953  const int n2 = 1;
3954  Matcher<const int&> matcher2 = ResultOf(ReferencingFunction, Eq(&n));
3955  EXPECT_TRUE(matcher2.Matches(n));
3956  EXPECT_FALSE(matcher2.Matches(n2));
3957 
3958  Matcher<const int&> matcher3 = ResultOf(ReferencingFunctor(), Eq(&n));
3959  EXPECT_TRUE(matcher3.Matches(n));
3960  EXPECT_FALSE(matcher3.Matches(n2));
3961 }
internal::EqMatcher< T > Eq(T x)
typename NonSharedPtr< invoke_result_t< F >>::type ResultOf
Definition: Observer-pre.h:40
const int * ReferencingFunction(const int &n)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ExplainMatchResultTest  ,
AllOf_False_False   
)

Definition at line 3996 of file gmock-matchers_test.cc.

References testing::AllOf(), DivisibleBy(), EXPECT_EQ, Explain(), and m.

3996  {
3997  const Matcher<int> m = AllOf(DivisibleBy(4), DivisibleBy(3));
3998  EXPECT_EQ("which is 1 modulo 4", Explain(m, 5));
3999 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
StrictConjunction< T< As >... > AllOf
PolymorphicMatcher< DivisibleByImpl > DivisibleBy(int n)
testing::gmock_matchers_test::TEST ( ExplainMatchResultTest  ,
AllOf_False_True   
)

Definition at line 4003 of file gmock-matchers_test.cc.

References testing::AllOf(), DivisibleBy(), EXPECT_EQ, Explain(), and m.

4003  {
4004  const Matcher<int> m = AllOf(DivisibleBy(4), DivisibleBy(3));
4005  EXPECT_EQ("which is 2 modulo 4", Explain(m, 6));
4006 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
StrictConjunction< T< As >... > AllOf
PolymorphicMatcher< DivisibleByImpl > DivisibleBy(int n)
testing::gmock_matchers_test::TEST ( ExplainMatchResultTest  ,
AllOf_True_False   
)

Definition at line 4010 of file gmock-matchers_test.cc.

References testing::AllOf(), DivisibleBy(), EXPECT_EQ, Explain(), testing::Ge(), and m.

4010  {
4011  const Matcher<int> m = AllOf(Ge(1), DivisibleBy(3));
4012  EXPECT_EQ("which is 2 modulo 3", Explain(m, 5));
4013 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
StrictConjunction< T< As >... > AllOf
internal::GeMatcher< Rhs > Ge(Rhs x)
PolymorphicMatcher< DivisibleByImpl > DivisibleBy(int n)
testing::gmock_matchers_test::TEST ( ExplainMatchResultTest  ,
AllOf_True_True   
)

Definition at line 4017 of file gmock-matchers_test.cc.

References testing::AllOf(), DivisibleBy(), EXPECT_EQ, Explain(), and m.

4017  {
4018  const Matcher<int> m = AllOf(DivisibleBy(2), DivisibleBy(3));
4019  EXPECT_EQ("which is 0 modulo 2, and which is 0 modulo 3", Explain(m, 6));
4020 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
StrictConjunction< T< As >... > AllOf
PolymorphicMatcher< DivisibleByImpl > DivisibleBy(int n)
testing::gmock_matchers_test::TEST ( ExplainMatchResultTest  ,
AllOf_True_True_2   
)

Definition at line 4022 of file gmock-matchers_test.cc.

References testing::AllOf(), EXPECT_EQ, Explain(), testing::Ge(), testing::Le(), and m.

4022  {
4023  const Matcher<int> m = AllOf(Ge(2), Le(3));
4024  EXPECT_EQ("", Explain(m, 2));
4025 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
internal::LeMatcher< Rhs > Le(Rhs x)
static map< string, int > m
StrictConjunction< T< As >... > AllOf
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( ExplainmatcherResultTest  ,
MonomorphicMatcher   
)

Definition at line 4027 of file gmock-matchers_test.cc.

References EXPECT_EQ, Explain(), GreaterThan(), and m.

4027  {
4028  const Matcher<int> m = GreaterThan(5);
4029  EXPECT_EQ("which is 1 more than 5", Explain(m, 6));
4030 }
Matcher< int > GreaterThan(int n)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
testing::gmock_matchers_test::TEST ( ByRefTest  ,
AllowsNotCopyableConstValueInMatchers   
)

Definition at line 4055 of file gmock-matchers_test.cc.

References testing::ByRef(), testing::Eq(), EXPECT_FALSE, EXPECT_TRUE, m, and testing::internal::MatcherBase< T >::Matches().

4055  {
4056  const NotCopyable const_value1(1);
4057  const Matcher<const NotCopyable&> m = Eq(ByRef(const_value1));
4058 
4059  const NotCopyable n1(1), n2(2);
4060  EXPECT_TRUE(m.Matches(n1));
4061  EXPECT_FALSE(m.Matches(n2));
4062 }
internal::EqMatcher< T > Eq(T x)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
internal::ReferenceWrapper< T > ByRef(T &l_value)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ByRefTest  ,
AllowsNotCopyableValueInMatchers   
)

Definition at line 4064 of file gmock-matchers_test.cc.

References testing::ByRef(), EXPECT_FALSE, EXPECT_TRUE, testing::Ge(), m, and testing::internal::MatcherBase< T >::Matches().

4064  {
4065  NotCopyable value2(2);
4066  const Matcher<NotCopyable&> m = Ge(ByRef(value2));
4067 
4068  NotCopyable n1(1), n2(2);
4069  EXPECT_FALSE(m.Matches(n1));
4070  EXPECT_TRUE(m.Matches(n2));
4071 }
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
internal::ReferenceWrapper< T > ByRef(T &l_value)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::GeMatcher< Rhs > Ge(Rhs x)
testing::gmock_matchers_test::TEST ( IsEmptyTest  ,
ImplementsIsEmpty   
)

Definition at line 4073 of file gmock-matchers_test.cc.

References EXPECT_THAT, and testing::Not().

4073  {
4074  vector<int> container;
4075  EXPECT_THAT(container, IsEmpty());
4076  container.push_back(0);
4077  EXPECT_THAT(container, Not(IsEmpty()));
4078  container.push_back(1);
4079  EXPECT_THAT(container, Not(IsEmpty()));
4080 }
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
Definition: Traits.h:588
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( IsEmptyTest  ,
WorksWithString   
)

Definition at line 4082 of file gmock-matchers_test.cc.

References EXPECT_THAT, and testing::Not().

4082  {
4083  string text;
4084  EXPECT_THAT(text, IsEmpty());
4085  text = "foo";
4086  EXPECT_THAT(text, Not(IsEmpty()));
4087  text = string("\0", 1);
4088  EXPECT_THAT(text, Not(IsEmpty()));
4089 }
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
const char * string
Definition: Conv.cpp:212
testing::gmock_matchers_test::TEST ( IsEmptyTest  ,
CanDescribeSelf   
)

Definition at line 4091 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, and m.

4091  {
4092  Matcher<vector<int> > m = IsEmpty();
4093  EXPECT_EQ("is empty", Describe(m));
4094  EXPECT_EQ("isn't empty", DescribeNegation(m));
4095 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
static map< string, int > m
testing::gmock_matchers_test::TEST ( IsEmptyTest  ,
ExplainsResult   
)

Definition at line 4097 of file gmock-matchers_test.cc.

References EXPECT_EQ, Explain(), and m.

4097  {
4098  Matcher<vector<int> > m = IsEmpty();
4099  vector<int> container;
4100  EXPECT_EQ("", Explain(m, container));
4101  container.push_back(0);
4102  EXPECT_EQ("whose size is 1", Explain(m, container));
4103 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
Definition: Traits.h:588
testing::gmock_matchers_test::TEST ( SizeIsTest  ,
ImplementsSizeIs   
)

Definition at line 4105 of file gmock-matchers_test.cc.

References EXPECT_THAT, testing::Not(), and testing::SizeIs().

4105  {
4106  vector<int> container;
4107  EXPECT_THAT(container, SizeIs(0));
4108  EXPECT_THAT(container, Not(SizeIs(1)));
4109  container.push_back(0);
4110  EXPECT_THAT(container, Not(SizeIs(0)));
4111  EXPECT_THAT(container, SizeIs(1));
4112  container.push_back(0);
4113  EXPECT_THAT(container, Not(SizeIs(0)));
4114  EXPECT_THAT(container, SizeIs(2));
4115 }
internal::SizeIsMatcher< SizeMatcher > SizeIs(const SizeMatcher &size_matcher)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
Definition: Traits.h:588
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( SizeIsTest  ,
WorksWithMap   
)

Definition at line 4117 of file gmock-matchers_test.cc.

References EXPECT_THAT, testing::Not(), and testing::SizeIs().

4117  {
4118  map<string, int> container;
4119  EXPECT_THAT(container, SizeIs(0));
4120  EXPECT_THAT(container, Not(SizeIs(1)));
4121  container.insert(make_pair("foo", 1));
4122  EXPECT_THAT(container, Not(SizeIs(0)));
4123  EXPECT_THAT(container, SizeIs(1));
4124  container.insert(make_pair("bar", 2));
4125  EXPECT_THAT(container, Not(SizeIs(0)));
4126  EXPECT_THAT(container, SizeIs(2));
4127 }
internal::SizeIsMatcher< SizeMatcher > SizeIs(const SizeMatcher &size_matcher)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
Definition: Traits.h:594
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( SizeIsTest  ,
WorksWithReferences   
)

Definition at line 4129 of file gmock-matchers_test.cc.

References EXPECT_THAT, m, testing::Not(), and testing::SizeIs().

4129  {
4130  vector<int> container;
4131  Matcher<const vector<int>&> m = SizeIs(1);
4132  EXPECT_THAT(container, Not(m));
4133  container.push_back(0);
4134  EXPECT_THAT(container, m);
4135 }
internal::SizeIsMatcher< SizeMatcher > SizeIs(const SizeMatcher &size_matcher)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
static map< string, int > m
Definition: Traits.h:588
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( SizeIsTest  ,
CanDescribeSelf   
)

Definition at line 4137 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, m, and testing::SizeIs().

4137  {
4138  Matcher<vector<int> > m = SizeIs(2);
4139  EXPECT_EQ("size is equal to 2", Describe(m));
4140  EXPECT_EQ("size isn't equal to 2", DescribeNegation(m));
4141 }
string Describe(const Matcher< T > &m)
internal::SizeIsMatcher< SizeMatcher > SizeIs(const SizeMatcher &size_matcher)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
static map< string, int > m
testing::gmock_matchers_test::TEST ( SizeIsTest  ,
ExplainsResult   
)

Definition at line 4143 of file gmock-matchers_test.cc.

References testing::AnyOf(), testing::ContainerEq(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, Explain(), GreaterThan(), testing::Lt(), m, testing::internal::MatcherBase< T >::Matches(), testing::SizeIs(), testing::TYPED_TEST(), and testing::TYPED_TEST_CASE().

4143  {
4144  Matcher<vector<int> > m1 = SizeIs(2);
4145  Matcher<vector<int> > m2 = SizeIs(Lt(2u));
4146  Matcher<vector<int> > m3 = SizeIs(AnyOf(0, 3));
4147  Matcher<vector<int> > m4 = SizeIs(GreaterThan(1));
4148  vector<int> container;
4149  EXPECT_EQ("whose size 0 doesn't match", Explain(m1, container));
4150  EXPECT_EQ("whose size 0 matches", Explain(m2, container));
4151  EXPECT_EQ("whose size 0 matches", Explain(m3, container));
4152  EXPECT_EQ("whose size 0 doesn't match, which is 1 less than 1",
4153  Explain(m4, container));
4154  container.push_back(0);
4155  container.push_back(0);
4156  EXPECT_EQ("whose size 2 matches", Explain(m1, container));
4157  EXPECT_EQ("whose size 2 doesn't match", Explain(m2, container));
4158  EXPECT_EQ("whose size 2 doesn't match", Explain(m3, container));
4159  EXPECT_EQ("whose size 2 matches, which is 1 more than 1",
4160  Explain(m4, container));
4161 }
Matcher< int > GreaterThan(int n)
internal::SizeIsMatcher< SizeMatcher > SizeIs(const SizeMatcher &size_matcher)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::AnyOfResult2< M1, M2 >::type AnyOf(M1 m1, M2 m2)
Definition: Traits.h:588
testing::gmock_matchers_test::TEST ( ContainerEqExtraTest  ,
MultipleValuesMissing   
)

Definition at line 4239 of file gmock-matchers_test.cc.

References testing::ContainerEq(), EXPECT_EQ, EXPECT_FALSE, Explain(), m, and testing::internal::MatcherBase< T >::Matches().

4239  {
4240  static const int vals[] = {1, 1, 2, 3, 5, 8};
4241  static const int test_vals[] = {2, 1, 5};
4242  vector<int> my_set(vals, vals + 6);
4243  vector<int> test_set(test_vals, test_vals + 3);
4244  const Matcher<vector<int> > m = ContainerEq(my_set);
4245  EXPECT_FALSE(m.Matches(test_set));
4246  EXPECT_EQ("which doesn't have these expected elements: 3, 8",
4247  Explain(m, test_set));
4248 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
static map< string, int > m
Definition: Traits.h:588
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ContainerEqExtraTest  ,
MultipleValuesAdded   
)

Definition at line 4252 of file gmock-matchers_test.cc.

References testing::ContainerEq(), EXPECT_EQ, EXPECT_FALSE, Explain(), m, and testing::internal::MatcherBase< T >::Matches().

4252  {
4253  static const int vals[] = {1, 1, 2, 3, 5, 8};
4254  static const int test_vals[] = {1, 2, 92, 3, 5, 8, 46};
4255  list<size_t> my_set(vals, vals + 6);
4256  list<size_t> test_set(test_vals, test_vals + 7);
4257  const Matcher<const list<size_t>&> m = ContainerEq(my_set);
4258  EXPECT_FALSE(m.Matches(test_set));
4259  EXPECT_EQ("which has these unexpected elements: 92, 46",
4260  Explain(m, test_set));
4261 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
static map< string, int > m
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ContainerEqExtraTest  ,
MultipleValuesAddedAndRemoved   
)

Definition at line 4264 of file gmock-matchers_test.cc.

References testing::ContainerEq(), EXPECT_EQ, EXPECT_FALSE, Explain(), m, and testing::internal::MatcherBase< T >::Matches().

4264  {
4265  static const int vals[] = {1, 1, 2, 3, 5, 8};
4266  static const int test_vals[] = {1, 2, 3, 92, 46};
4267  list<size_t> my_set(vals, vals + 6);
4268  list<size_t> test_set(test_vals, test_vals + 5);
4269  const Matcher<const list<size_t> > m = ContainerEq(my_set);
4270  EXPECT_FALSE(m.Matches(test_set));
4271  EXPECT_EQ("which has these unexpected elements: 92, 46,\n"
4272  "and doesn't have these expected elements: 5, 8",
4273  Explain(m, test_set));
4274 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
static map< string, int > m
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ContainerEqExtraTest  ,
MultiSetOfIntDuplicateDifference   
)

Definition at line 4278 of file gmock-matchers_test.cc.

References testing::ContainerEq(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, Explain(), m, and testing::internal::MatcherBase< T >::Matches().

4278  {
4279  static const int vals[] = {1, 1, 2, 3, 5, 8};
4280  static const int test_vals[] = {1, 2, 3, 5, 8};
4281  vector<int> my_set(vals, vals + 6);
4282  vector<int> test_set(test_vals, test_vals + 5);
4283  const Matcher<vector<int> > m = ContainerEq(my_set);
4284  EXPECT_TRUE(m.Matches(my_set));
4285  EXPECT_FALSE(m.Matches(test_set));
4286  // There is nothing to report when both sets contain all the same values.
4287  EXPECT_EQ("", Explain(m, test_set));
4288 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
static map< string, int > m
Definition: Traits.h:588
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ContainerEqExtraTest  ,
WorksForMaps   
)

Definition at line 4292 of file gmock-matchers_test.cc.

References testing::ContainerEq(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, Explain(), m, and testing::internal::MatcherBase< T >::Matches().

4292  {
4293  map<int, std::string> my_map;
4294  my_map[0] = "a";
4295  my_map[1] = "b";
4296 
4297  map<int, std::string> test_map;
4298  test_map[0] = "aa";
4299  test_map[1] = "b";
4300 
4301  const Matcher<const map<int, std::string>&> m = ContainerEq(my_map);
4302  EXPECT_TRUE(m.Matches(my_map));
4303  EXPECT_FALSE(m.Matches(test_map));
4304 
4305  EXPECT_EQ("which has these unexpected elements: (0, \"aa\"),\n"
4306  "and doesn't have these expected elements: (0, \"a\")",
4307  Explain(m, test_map));
4308 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
static map< string, int > m
Definition: Traits.h:594
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( ContainerEqExtraTest  ,
WorksForNativeArray   
)

Definition at line 4310 of file gmock-matchers_test.cc.

References b, testing::ContainerEq(), EXPECT_THAT, and testing::Not().

4310  {
4311  int a1[] = {1, 2, 3};
4312  int a2[] = {1, 2, 3};
4313  int b[] = {1, 2, 4};
4314 
4315  EXPECT_THAT(a1, ContainerEq(a2));
4316  EXPECT_THAT(a1, Not(ContainerEq(b)));
4317 }
char b
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( ContainerEqExtraTest  ,
WorksForTwoDimensionalNativeArray   
)

Definition at line 4319 of file gmock-matchers_test.cc.

References b, testing::ContainerEq(), testing::ElementsAre(), EXPECT_THAT, and testing::Not().

4319  {
4320  const char a1[][3] = {"hi", "lo"};
4321  const char a2[][3] = {"hi", "lo"};
4322  const char b[][3] = {"lo", "hi"};
4323 
4324  // Tests using ContainerEq() in the first dimension.
4325  EXPECT_THAT(a1, ContainerEq(a2));
4326  EXPECT_THAT(a1, Not(ContainerEq(b)));
4327 
4328  // Tests using ContainerEq() in the second dimension.
4329  EXPECT_THAT(a1, ElementsAre(ContainerEq(a2[0]), ContainerEq(a2[1])));
4330  EXPECT_THAT(a1, ElementsAre(Not(ContainerEq(b[0])), ContainerEq(a2[1])));
4331 }
char b
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
testing::gmock_matchers_test::TEST ( ContainerEqExtraTest  ,
WorksForNativeArrayAsTuple   
)

Definition at line 4333 of file gmock-matchers_test.cc.

References b, c, testing::ContainerEq(), EXPECT_THAT, std::tr1::make_tuple(), and testing::Not().

4333  {
4334  const int a1[] = {1, 2, 3};
4335  const int a2[] = {1, 2, 3};
4336  const int b[] = {1, 2, 3, 4};
4337 
4338  const int* const p1 = a1;
4339  EXPECT_THAT(make_tuple(p1, 3), ContainerEq(a2));
4340  EXPECT_THAT(make_tuple(p1, 3), Not(ContainerEq(b)));
4341 
4342  const int c[] = {1, 3, 2};
4343  EXPECT_THAT(make_tuple(p1, 3), Not(ContainerEq(c)));
4344 }
char b
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
tuple make_tuple()
Definition: gtest-tuple.h:675
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
char c
testing::gmock_matchers_test::TEST ( ContainerEqExtraTest  ,
CopiesNativeArrayParameter   
)

Definition at line 4346 of file gmock-matchers_test.cc.

References testing::ContainerEq(), EXPECT_THAT, m, and string.

4346  {
4347  std::string a1[][3] = {
4348  {"hi", "hello", "ciao"},
4349  {"bye", "see you", "ciao"}
4350  };
4351 
4352  std::string a2[][3] = {
4353  {"hi", "hello", "ciao"},
4354  {"bye", "see you", "ciao"}
4355  };
4356 
4357  const Matcher<const std::string(&)[2][3]> m = ContainerEq(a2);
4358  EXPECT_THAT(a1, m);
4359 
4360  a2[0][0] = "ha";
4361  EXPECT_THAT(a1, m);
4362 }
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
static map< string, int > m
#define EXPECT_THAT(value, matcher)
const char * string
Definition: Conv.cpp:212
testing::gmock_matchers_test::TEST ( WhenSortedByTest  ,
WorksForEmptyContainer   
)

Definition at line 4364 of file gmock-matchers_test.cc.

References testing::ElementsAre(), EXPECT_THAT, testing::Not(), and testing::WhenSortedBy().

4364  {
4365  const vector<int> numbers;
4366  EXPECT_THAT(numbers, WhenSortedBy(less<int>(), ElementsAre()));
4367  EXPECT_THAT(numbers, Not(WhenSortedBy(less<int>(), ElementsAre(1))));
4368 }
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
Definition: Traits.h:588
#define EXPECT_THAT(value, matcher)
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
internal::WhenSortedByMatcher< Comparator, ContainerMatcher > WhenSortedBy(const Comparator &comparator, const ContainerMatcher &container_matcher)
testing::gmock_matchers_test::TEST ( WhenSortedByTest  ,
WorksForNonEmptyContainer   
)

Definition at line 4370 of file gmock-matchers_test.cc.

References testing::ElementsAre(), EXPECT_THAT, testing::Not(), and testing::WhenSortedBy().

4370  {
4371  vector<unsigned> numbers;
4372  numbers.push_back(3);
4373  numbers.push_back(1);
4374  numbers.push_back(2);
4375  numbers.push_back(2);
4376  EXPECT_THAT(numbers, WhenSortedBy(greater<unsigned>(),
4377  ElementsAre(3, 2, 2, 1)));
4378  EXPECT_THAT(numbers, Not(WhenSortedBy(greater<unsigned>(),
4379  ElementsAre(1, 2, 2, 3))));
4380 }
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
Definition: Traits.h:588
#define EXPECT_THAT(value, matcher)
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
internal::WhenSortedByMatcher< Comparator, ContainerMatcher > WhenSortedBy(const Comparator &comparator, const ContainerMatcher &container_matcher)
testing::gmock_matchers_test::TEST ( WhenSortedByTest  ,
WorksForNonVectorContainer   
)

Definition at line 4382 of file gmock-matchers_test.cc.

References testing::ElementsAre(), EXPECT_THAT, testing::Not(), and testing::WhenSortedBy().

4382  {
4383  list<string> words;
4384  words.push_back("say");
4385  words.push_back("hello");
4386  words.push_back("world");
4387  EXPECT_THAT(words, WhenSortedBy(less<string>(),
4388  ElementsAre("hello", "say", "world")));
4389  EXPECT_THAT(words, Not(WhenSortedBy(less<string>(),
4390  ElementsAre("say", "hello", "world"))));
4391 }
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
internal::WhenSortedByMatcher< Comparator, ContainerMatcher > WhenSortedBy(const Comparator &comparator, const ContainerMatcher &container_matcher)
testing::gmock_matchers_test::TEST ( WhenSortedByTest  ,
WorksForNativeArray   
)

Definition at line 4393 of file gmock-matchers_test.cc.

References testing::ElementsAre(), testing::ElementsAreArray(), EXPECT_THAT, testing::Not(), and testing::WhenSortedBy().

4393  {
4394  const int numbers[] = {1, 3, 2, 4};
4395  const int sorted_numbers[] = {1, 2, 3, 4};
4396  EXPECT_THAT(numbers, WhenSortedBy(less<int>(), ElementsAre(1, 2, 3, 4)));
4397  EXPECT_THAT(numbers, WhenSortedBy(less<int>(),
4398  ElementsAreArray(sorted_numbers)));
4399  EXPECT_THAT(numbers, Not(WhenSortedBy(less<int>(), ElementsAre(1, 3, 2, 4))));
4400 }
internal::ElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > ElementsAreArray(Iter first, Iter last)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
internal::WhenSortedByMatcher< Comparator, ContainerMatcher > WhenSortedBy(const Comparator &comparator, const ContainerMatcher &container_matcher)
testing::gmock_matchers_test::TEST ( WhenSortedByTest  ,
CanDescribeSelf   
)

Definition at line 4402 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), testing::ElementsAre(), EXPECT_EQ, m, and testing::WhenSortedBy().

4402  {
4403  const Matcher<vector<int> > m = WhenSortedBy(less<int>(), ElementsAre(1, 2));
4404  EXPECT_EQ("(when sorted) has 2 elements where\n"
4405  "element #0 is equal to 1,\n"
4406  "element #1 is equal to 2",
4407  Describe(m));
4408  EXPECT_EQ("(when sorted) doesn't have 2 elements, or\n"
4409  "element #0 isn't equal to 1, or\n"
4410  "element #1 isn't equal to 2",
4411  DescribeNegation(m));
4412 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
static map< string, int > m
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
internal::WhenSortedByMatcher< Comparator, ContainerMatcher > WhenSortedBy(const Comparator &comparator, const ContainerMatcher &container_matcher)
testing::gmock_matchers_test::TEST ( WhenSortedByTest  ,
ExplainsMatchResult   
)

Definition at line 4414 of file gmock-matchers_test.cc.

References a, testing::ElementsAre(), EXPECT_EQ, Explain(), and testing::WhenSortedBy().

4414  {
4415  const int a[] = {2, 1};
4416  EXPECT_EQ("which is { 1, 2 } when sorted, whose element #0 doesn't match",
4417  Explain(WhenSortedBy(less<int>(), ElementsAre(2, 3)), a));
4418  EXPECT_EQ("which is { 1, 2 } when sorted",
4419  Explain(WhenSortedBy(less<int>(), ElementsAre(1, 2)), a));
4420 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
char a
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
internal::WhenSortedByMatcher< Comparator, ContainerMatcher > WhenSortedBy(const Comparator &comparator, const ContainerMatcher &container_matcher)
testing::gmock_matchers_test::TEST ( WhenSortedTest  ,
WorksForEmptyContainer   
)

Definition at line 4425 of file gmock-matchers_test.cc.

References testing::ElementsAre(), EXPECT_THAT, testing::Not(), and testing::WhenSorted().

4425  {
4426  const vector<int> numbers;
4427  EXPECT_THAT(numbers, WhenSorted(ElementsAre()));
4428  EXPECT_THAT(numbers, Not(WhenSorted(ElementsAre(1))));
4429 }
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
Definition: Traits.h:588
internal::WhenSortedByMatcher< internal::LessComparator, ContainerMatcher > WhenSorted(const ContainerMatcher &container_matcher)
#define EXPECT_THAT(value, matcher)
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
testing::gmock_matchers_test::TEST ( WhenSortedTest  ,
WorksForNonEmptyContainer   
)

Definition at line 4431 of file gmock-matchers_test.cc.

References testing::ElementsAre(), EXPECT_THAT, testing::Not(), and testing::WhenSorted().

4431  {
4432  list<string> words;
4433  words.push_back("3");
4434  words.push_back("1");
4435  words.push_back("2");
4436  words.push_back("2");
4437  EXPECT_THAT(words, WhenSorted(ElementsAre("1", "2", "2", "3")));
4438  EXPECT_THAT(words, Not(WhenSorted(ElementsAre("3", "1", "2", "2"))));
4439 }
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
internal::WhenSortedByMatcher< internal::LessComparator, ContainerMatcher > WhenSorted(const ContainerMatcher &container_matcher)
#define EXPECT_THAT(value, matcher)
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
testing::gmock_matchers_test::TEST ( WhenSortedTest  ,
WorksForMapTypes   
)

Definition at line 4441 of file gmock-matchers_test.cc.

References testing::ElementsAre(), EXPECT_THAT, testing::Not(), testing::Pair(), and testing::WhenSorted().

4441  {
4442  map<string, int> word_counts;
4443  word_counts["and"] = 1;
4444  word_counts["the"] = 1;
4445  word_counts["buffalo"] = 2;
4446  EXPECT_THAT(word_counts, WhenSorted(ElementsAre(
4447  Pair("and", 1), Pair("buffalo", 2), Pair("the", 1))));
4448  EXPECT_THAT(word_counts, Not(WhenSorted(ElementsAre(
4449  Pair("and", 1), Pair("the", 1), Pair("buffalo", 2)))));
4450 }
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
Definition: Traits.h:594
internal::WhenSortedByMatcher< internal::LessComparator, ContainerMatcher > WhenSorted(const ContainerMatcher &container_matcher)
#define EXPECT_THAT(value, matcher)
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
testing::gmock_matchers_test::TEST ( WhenSortedTest  ,
WorksForMultiMapTypes   
)

Definition at line 4452 of file gmock-matchers_test.cc.

References testing::ElementsAre(), EXPECT_THAT, testing::Not(), testing::Pair(), and testing::WhenSorted().

4452  {
4453  multimap<int, int> ifib;
4454  ifib.insert(make_pair(8, 6));
4455  ifib.insert(make_pair(2, 3));
4456  ifib.insert(make_pair(1, 1));
4457  ifib.insert(make_pair(3, 4));
4458  ifib.insert(make_pair(1, 2));
4459  ifib.insert(make_pair(5, 5));
4460  EXPECT_THAT(ifib, WhenSorted(ElementsAre(Pair(1, 1),
4461  Pair(1, 2),
4462  Pair(2, 3),
4463  Pair(3, 4),
4464  Pair(5, 5),
4465  Pair(8, 6))));
4467  Pair(2, 3),
4468  Pair(1, 1),
4469  Pair(3, 4),
4470  Pair(1, 2),
4471  Pair(5, 5)))));
4472 }
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
internal::WhenSortedByMatcher< internal::LessComparator, ContainerMatcher > WhenSorted(const ContainerMatcher &container_matcher)
#define EXPECT_THAT(value, matcher)
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
testing::gmock_matchers_test::TEST ( WhenSortedTest  ,
WorksForPolymorphicMatcher   
)

Definition at line 4474 of file gmock-matchers_test.cc.

References testing::ElementsAre(), EXPECT_THAT, testing::Not(), and testing::WhenSorted().

4474  {
4475  std::deque<int> d;
4476  d.push_back(2);
4477  d.push_back(1);
4478  EXPECT_THAT(d, WhenSorted(ElementsAre(1, 2)));
4479  EXPECT_THAT(d, Not(WhenSorted(ElementsAre(2, 1))));
4480 }
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
internal::WhenSortedByMatcher< internal::LessComparator, ContainerMatcher > WhenSorted(const ContainerMatcher &container_matcher)
#define EXPECT_THAT(value, matcher)
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
testing::gmock_matchers_test::TEST ( WhenSortedTest  ,
WorksForVectorConstRefMatcher   
)

Definition at line 4482 of file gmock-matchers_test.cc.

References testing::ElementsAre(), EXPECT_THAT, testing::Not(), and testing::WhenSorted().

4482  {
4483  std::deque<int> d;
4484  d.push_back(2);
4485  d.push_back(1);
4486  Matcher<const std::vector<int>&> vector_match = ElementsAre(1, 2);
4487  EXPECT_THAT(d, WhenSorted(vector_match));
4488  Matcher<const std::vector<int>&> not_vector_match = ElementsAre(2, 1);
4489  EXPECT_THAT(d, Not(WhenSorted(not_vector_match)));
4490 }
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
internal::WhenSortedByMatcher< internal::LessComparator, ContainerMatcher > WhenSorted(const ContainerMatcher &container_matcher)
#define EXPECT_THAT(value, matcher)
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
testing::gmock_matchers_test::TEST ( StreamlikeTest  ,
Iteration   
)

Definition at line 4572 of file gmock-matchers_test.cc.

References a, testing::gmock_matchers_test::Streamlike< T >::begin(), testing::BeginEndDistanceIs(), testing::gmock_matchers_test::Streamlike< T >::end(), EXPECT_EQ, EXPECT_THAT, testing::Not(), s, SCOPED_TRACE, and testing::internal::TEST().

4572  {
4573  const int a[5] = {2, 1, 4, 5, 3};
4574  Streamlike<int> s(a, a + 5);
4575  Streamlike<int>::const_iterator it = s.begin();
4576  const int* ip = a;
4577  while (it != s.end()) {
4578  SCOPED_TRACE(ip - a);
4579  EXPECT_EQ(*ip++, *it++);
4580  }
4581 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define SCOPED_TRACE(message)
Definition: gtest.h:2115
char a
static set< string > s
testing::gmock_matchers_test::TEST ( BeginEndDistanceIsTest  ,
WorksWithNonStdList   
)

Definition at line 4597 of file gmock-matchers_test.cc.

References a, testing::BeginEndDistanceIs(), EXPECT_THAT, and s.

4597  {
4598  const int a[5] = {1, 2, 3, 4, 5};
4599  Streamlike<int> s(a, a + 5);
4601 }
internal::BeginEndDistanceIsMatcher< DistanceMatcher > BeginEndDistanceIs(const DistanceMatcher &distance_matcher)
char a
#define EXPECT_THAT(value, matcher)
static set< string > s
testing::gmock_matchers_test::TEST ( BeginEndDistanceIsTest  ,
CanDescribeSelf   
)

Definition at line 4603 of file gmock-matchers_test.cc.

References testing::BeginEndDistanceIs(), Describe(), DescribeNegation(), EXPECT_EQ, and m.

4603  {
4604  Matcher<vector<int> > m = BeginEndDistanceIs(2);
4605  EXPECT_EQ("distance between begin() and end() is equal to 2", Describe(m));
4606  EXPECT_EQ("distance between begin() and end() isn't equal to 2",
4607  DescribeNegation(m));
4608 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::BeginEndDistanceIsMatcher< DistanceMatcher > BeginEndDistanceIs(const DistanceMatcher &distance_matcher)
string DescribeNegation(const Matcher< T > &m)
static map< string, int > m
testing::gmock_matchers_test::TEST ( BeginEndDistanceIsTest  ,
ExplainsResult   
)

Definition at line 4610 of file gmock-matchers_test.cc.

References testing::AnyOf(), testing::BeginEndDistanceIs(), EXPECT_EQ, Explain(), GreaterThan(), and testing::Lt().

4610  {
4611  Matcher<vector<int> > m1 = BeginEndDistanceIs(2);
4612  Matcher<vector<int> > m2 = BeginEndDistanceIs(Lt(2));
4613  Matcher<vector<int> > m3 = BeginEndDistanceIs(AnyOf(0, 3));
4614  Matcher<vector<int> > m4 = BeginEndDistanceIs(GreaterThan(1));
4615  vector<int> container;
4616  EXPECT_EQ("whose distance between begin() and end() 0 doesn't match",
4617  Explain(m1, container));
4618  EXPECT_EQ("whose distance between begin() and end() 0 matches",
4619  Explain(m2, container));
4620  EXPECT_EQ("whose distance between begin() and end() 0 matches",
4621  Explain(m3, container));
4622  EXPECT_EQ(
4623  "whose distance between begin() and end() 0 doesn't match, which is 1 "
4624  "less than 1",
4625  Explain(m4, container));
4626  container.push_back(0);
4627  container.push_back(0);
4628  EXPECT_EQ("whose distance between begin() and end() 2 matches",
4629  Explain(m1, container));
4630  EXPECT_EQ("whose distance between begin() and end() 2 doesn't match",
4631  Explain(m2, container));
4632  EXPECT_EQ("whose distance between begin() and end() 2 doesn't match",
4633  Explain(m3, container));
4634  EXPECT_EQ(
4635  "whose distance between begin() and end() 2 matches, which is 1 more "
4636  "than 1",
4637  Explain(m4, container));
4638 }
Matcher< int > GreaterThan(int n)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::BeginEndDistanceIsMatcher< DistanceMatcher > BeginEndDistanceIs(const DistanceMatcher &distance_matcher)
string Explain(const MatcherType &m, const Value &x)
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::AnyOfResult2< M1, M2 >::type AnyOf(M1 m1, M2 m2)
Definition: Traits.h:588
testing::gmock_matchers_test::TEST ( WhenSortedTest  ,
WorksForStreamlike   
)

Definition at line 4640 of file gmock-matchers_test.cc.

References a, testing::ElementsAre(), EXPECT_THAT, GTEST_ARRAY_SIZE_, testing::Not(), s, and testing::WhenSorted().

4640  {
4641  // Streamlike 'container' provides only minimal iterator support.
4642  // Its iterators are tagged with input_iterator_tag.
4643  const int a[5] = {2, 1, 4, 5, 3};
4644  Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a));
4645  EXPECT_THAT(s, WhenSorted(ElementsAre(1, 2, 3, 4, 5)));
4646  EXPECT_THAT(s, Not(WhenSorted(ElementsAre(2, 1, 4, 5, 3))));
4647 }
#define GTEST_ARRAY_SIZE_(array)
Definition: gtest-port.h:1092
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
char a
internal::WhenSortedByMatcher< internal::LessComparator, ContainerMatcher > WhenSorted(const ContainerMatcher &container_matcher)
#define EXPECT_THAT(value, matcher)
static set< string > s
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
testing::gmock_matchers_test::TEST ( WhenSortedTest  ,
WorksForVectorConstRefMatcherOnStreamlike   
)

Definition at line 4649 of file gmock-matchers_test.cc.

References a, testing::ElementsAre(), EXPECT_THAT, GTEST_ARRAY_SIZE_, testing::Not(), s, and testing::WhenSorted().

4649  {
4650  const int a[] = {2, 1, 4, 5, 3};
4651  Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a));
4652  Matcher<const std::vector<int>&> vector_match = ElementsAre(1, 2, 3, 4, 5);
4653  EXPECT_THAT(s, WhenSorted(vector_match));
4654  EXPECT_THAT(s, Not(WhenSorted(ElementsAre(2, 1, 4, 5, 3))));
4655 }
#define GTEST_ARRAY_SIZE_(array)
Definition: gtest-port.h:1092
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
char a
internal::WhenSortedByMatcher< internal::LessComparator, ContainerMatcher > WhenSorted(const ContainerMatcher &container_matcher)
#define EXPECT_THAT(value, matcher)
static set< string > s
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
testing::gmock_matchers_test::TEST ( ElemensAreStreamTest  ,
WorksForStreamlike   
)

Definition at line 4660 of file gmock-matchers_test.cc.

References a, testing::ElementsAre(), EXPECT_THAT, GTEST_ARRAY_SIZE_, testing::Not(), and s.

4660  {
4661  const int a[5] = {1, 2, 3, 4, 5};
4662  Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a));
4663  EXPECT_THAT(s, ElementsAre(1, 2, 3, 4, 5));
4664  EXPECT_THAT(s, Not(ElementsAre(2, 1, 4, 5, 3)));
4665 }
#define GTEST_ARRAY_SIZE_(array)
Definition: gtest-port.h:1092
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
char a
#define EXPECT_THAT(value, matcher)
static set< string > s
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
testing::gmock_matchers_test::TEST ( ElemensAreArrayStreamTest  ,
WorksForStreamlike   
)

Definition at line 4667 of file gmock-matchers_test.cc.

References a, testing::ElementsAreArray(), EXPECT_THAT, GTEST_ARRAY_SIZE_, testing::Not(), and s.

4667  {
4668  const int a[5] = {1, 2, 3, 4, 5};
4669  Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a));
4670 
4671  vector<int> expected;
4672  expected.push_back(1);
4673  expected.push_back(2);
4674  expected.push_back(3);
4675  expected.push_back(4);
4676  expected.push_back(5);
4677  EXPECT_THAT(s, ElementsAreArray(expected));
4678 
4679  expected[3] = 0;
4680  EXPECT_THAT(s, Not(ElementsAreArray(expected)));
4681 }
#define GTEST_ARRAY_SIZE_(array)
Definition: gtest-port.h:1092
internal::ElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > ElementsAreArray(Iter first, Iter last)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
char a
Definition: Traits.h:588
#define EXPECT_THAT(value, matcher)
static set< string > s
testing::gmock_matchers_test::TEST ( ElementsAreTest  ,
WorksWithUncopyable   
)

Definition at line 4683 of file gmock-matchers_test.cc.

References testing::ElementsAre(), EXPECT_THAT, testing::gmock_matchers_test::Uncopyable::set_value(), testing::Truly(), and ValueIsPositive().

4683  {
4684  Uncopyable objs[2];
4685  objs[0].set_value(-3);
4686  objs[1].set_value(1);
4687  EXPECT_THAT(objs, ElementsAre(UncopyableIs(-3), Truly(ValueIsPositive)));
4688 }
bool ValueIsPositive(const Uncopyable &x)
#define EXPECT_THAT(value, matcher)
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
PolymorphicMatcher< internal::TrulyMatcher< Predicate > > Truly(Predicate pred)
testing::gmock_matchers_test::TEST ( ElementsAreTest  ,
TakesStlContainer   
)

Definition at line 4690 of file gmock-matchers_test.cc.

References testing::ElementsAreArray(), EXPECT_THAT, and testing::Not().

4690  {
4691  const int actual[] = {3, 1, 2};
4692 
4693  ::std::list<int> expected;
4694  expected.push_back(3);
4695  expected.push_back(1);
4696  expected.push_back(2);
4697  EXPECT_THAT(actual, ElementsAreArray(expected));
4698 
4699  expected.push_back(4);
4700  EXPECT_THAT(actual, Not(ElementsAreArray(expected)));
4701 }
internal::ElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > ElementsAreArray(Iter first, Iter last)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( UnorderedElementsAreArrayTest  ,
SucceedsWhenExpected   
)

Definition at line 4705 of file gmock-matchers_test.cc.

References a, EXPECT_TRUE, testing::ExplainMatchResult(), GTEST_ARRAY_SIZE_, s, testing::StringMatchResultListener::str(), and testing::UnorderedElementsAreArray().

4705  {
4706  const int a[] = {0, 1, 2, 3, 4};
4707  std::vector<int> s(a, a + GTEST_ARRAY_SIZE_(a));
4708  do {
4709  StringMatchResultListener listener;
4711  s, &listener)) << listener.str();
4712  } while (std::next_permutation(s.begin(), s.end()));
4713 }
#define GTEST_ARRAY_SIZE_(array)
Definition: gtest-port.h:1092
internal::UnorderedElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > UnorderedElementsAreArray(Iter first, Iter last)
char a
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
static set< string > s
testing::gmock_matchers_test::TEST ( UnorderedElementsAreArrayTest  ,
VectorBool   
)

Definition at line 4715 of file gmock-matchers_test.cc.

References a, b, EXPECT_TRUE, testing::ExplainMatchResult(), GTEST_ARRAY_SIZE_, testing::StringMatchResultListener::str(), and testing::UnorderedElementsAreArray().

4715  {
4716  const bool a[] = {0, 1, 0, 1, 1};
4717  const bool b[] = {1, 0, 1, 1, 0};
4718  std::vector<bool> expected(a, a + GTEST_ARRAY_SIZE_(a));
4719  std::vector<bool> actual(b, b + GTEST_ARRAY_SIZE_(b));
4720  StringMatchResultListener listener;
4722  actual, &listener)) << listener.str();
4723 }
char b
#define GTEST_ARRAY_SIZE_(array)
Definition: gtest-port.h:1092
internal::UnorderedElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > UnorderedElementsAreArray(Iter first, Iter last)
char a
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
testing::gmock_matchers_test::TEST ( UnorderedElementsAreArrayTest  ,
WorksForStreamlike   
)

Definition at line 4725 of file gmock-matchers_test.cc.

References a, EXPECT_THAT, GTEST_ARRAY_SIZE_, testing::Not(), s, and testing::UnorderedElementsAreArray().

4725  {
4726  // Streamlike 'container' provides only minimal iterator support.
4727  // Its iterators are tagged with input_iterator_tag, and it has no
4728  // size() or empty() methods.
4729  const int a[5] = {2, 1, 4, 5, 3};
4730  Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a));
4731 
4732  ::std::vector<int> expected;
4733  expected.push_back(1);
4734  expected.push_back(2);
4735  expected.push_back(3);
4736  expected.push_back(4);
4737  expected.push_back(5);
4739 
4740  expected.push_back(6);
4742 }
#define GTEST_ARRAY_SIZE_(array)
Definition: gtest-port.h:1092
internal::UnorderedElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > UnorderedElementsAreArray(Iter first, Iter last)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
char a
#define EXPECT_THAT(value, matcher)
static set< string > s
testing::gmock_matchers_test::TEST ( UnorderedElementsAreArrayTest  ,
TakesStlContainer   
)

Definition at line 4744 of file gmock-matchers_test.cc.

References a, testing::Eq(), EXPECT_THAT, testing::Ge(), testing::Le(), testing::Ne(), testing::Not(), testing::internal::TEST(), and testing::UnorderedElementsAreArray().

4744  {
4745  const int actual[] = {3, 1, 2};
4746 
4747  ::std::list<int> expected;
4748  expected.push_back(1);
4749  expected.push_back(2);
4750  expected.push_back(3);
4751  EXPECT_THAT(actual, UnorderedElementsAreArray(expected));
4752 
4753  expected.push_back(4);
4754  EXPECT_THAT(actual, Not(UnorderedElementsAreArray(expected)));
4755 }
internal::UnorderedElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > UnorderedElementsAreArray(Iter first, Iter last)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( IsReadableTypeNameTest  ,
ReturnsTrueForShortNames   
)

Definition at line 5218 of file gmock-matchers_test.cc.

References EXPECT_TRUE, and testing::internal::IsReadableTypeName().

5218  {
5220  EXPECT_TRUE(IsReadableTypeName("const unsigned char*"));
5221  EXPECT_TRUE(IsReadableTypeName("MyMap<int, void*>"));
5222  EXPECT_TRUE(IsReadableTypeName("void (*)(int, bool)"));
5223 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool IsReadableTypeName(const string &type_name)
testing::gmock_matchers_test::TEST ( IsReadableTypeNameTest  ,
ReturnsTrueForLongNonTemplateNonFunctionNames   
)

Definition at line 5225 of file gmock-matchers_test.cc.

References EXPECT_TRUE, and testing::internal::IsReadableTypeName().

5225  {
5226  EXPECT_TRUE(IsReadableTypeName("my_long_namespace::MyClassName"));
5227  EXPECT_TRUE(IsReadableTypeName("int [5][6][7][8][9][10][11]"));
5228  EXPECT_TRUE(IsReadableTypeName("my_namespace::MyOuterClass::MyInnerClass"));
5229 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool IsReadableTypeName(const string &type_name)
testing::gmock_matchers_test::TEST ( IsReadableTypeNameTest  ,
ReturnsFalseForLongTemplateNames   
)

Definition at line 5231 of file gmock-matchers_test.cc.

References EXPECT_FALSE, and testing::internal::IsReadableTypeName().

5231  {
5232  EXPECT_FALSE(
5233  IsReadableTypeName("basic_string<char, std::char_traits<char> >"));
5234  EXPECT_FALSE(IsReadableTypeName("std::vector<int, std::alloc_traits<int> >"));
5235 }
bool IsReadableTypeName(const string &type_name)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( IsReadableTypeNameTest  ,
ReturnsFalseForLongFunctionTypeNames   
)

Definition at line 5237 of file gmock-matchers_test.cc.

References EXPECT_FALSE, and testing::internal::IsReadableTypeName().

5237  {
5238  EXPECT_FALSE(IsReadableTypeName("void (&)(int, bool, char, float)"));
5239 }
bool IsReadableTypeName(const string &type_name)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST ( JoinAsTupleTest  ,
JoinsEmptyTuple   
)

Definition at line 5243 of file gmock-matchers_test.cc.

References EXPECT_EQ, and testing::internal::JoinAsTuple().

5243  {
5244  EXPECT_EQ("", JoinAsTuple(Strings()));
5245 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
GTEST_API_ string JoinAsTuple(const Strings &fields)
::std::vector< string > Strings
testing::gmock_matchers_test::TEST ( JoinAsTupleTest  ,
JoinsOneTuple   
)

Definition at line 5247 of file gmock-matchers_test.cc.

References EXPECT_EQ, and testing::internal::JoinAsTuple().

5247  {
5248  const char* fields[] = {"1"};
5249  EXPECT_EQ("1", JoinAsTuple(Strings(fields, fields + 1)));
5250 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
GTEST_API_ string JoinAsTuple(const Strings &fields)
::std::vector< string > Strings
testing::gmock_matchers_test::TEST ( JoinAsTupleTest  ,
JoinsTwoTuple   
)

Definition at line 5252 of file gmock-matchers_test.cc.

References EXPECT_EQ, and testing::internal::JoinAsTuple().

5252  {
5253  const char* fields[] = {"1", "a"};
5254  EXPECT_EQ("(1, a)", JoinAsTuple(Strings(fields, fields + 2)));
5255 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
GTEST_API_ string JoinAsTuple(const Strings &fields)
::std::vector< string > Strings
testing::gmock_matchers_test::TEST ( JoinAsTupleTest  ,
JoinsTenTuple   
)

Definition at line 5257 of file gmock-matchers_test.cc.

References EXPECT_EQ, and testing::internal::JoinAsTuple().

5257  {
5258  const char* fields[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
5259  EXPECT_EQ("(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)",
5260  JoinAsTuple(Strings(fields, fields + 10)));
5261 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
GTEST_API_ string JoinAsTuple(const Strings &fields)
::std::vector< string > Strings
testing::gmock_matchers_test::TEST ( FormatMatcherDescriptionTest  ,
WorksForEmptyDescription   
)

Definition at line 5265 of file gmock-matchers_test.cc.

References EXPECT_EQ, testing::internal::FormatMatcherDescription(), and params.

5265  {
5266  EXPECT_EQ("is even",
5267  FormatMatcherDescription(false, "IsEven", Strings()));
5268  EXPECT_EQ("not (is even)",
5269  FormatMatcherDescription(true, "IsEven", Strings()));
5270 
5271  const char* params[] = {"5"};
5272  EXPECT_EQ("equals 5",
5273  FormatMatcherDescription(false, "Equals",
5274  Strings(params, params + 1)));
5275 
5276  const char* params2[] = {"5", "8"};
5277  EXPECT_EQ("is in range (5, 8)",
5278  FormatMatcherDescription(false, "IsInRange",
5279  Strings(params2, params2 + 2)));
5280 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr Params params[]
GTEST_API_ string FormatMatcherDescription(bool negation, const char *matcher_name, const Strings &param_values)
::std::vector< string > Strings
testing::gmock_matchers_test::TEST ( PolymorphicMatcherTest  ,
CanAccessMutableImpl   
)

Definition at line 5283 of file gmock-matchers_test.cc.

References testing::gmock_matchers_test::DivisibleByImpl::divider(), EXPECT_EQ, m, testing::PolymorphicMatcher< Impl >::mutable_impl(), and testing::gmock_matchers_test::DivisibleByImpl::set_divider().

5283  {
5284  PolymorphicMatcher<DivisibleByImpl> m(DivisibleByImpl(42));
5285  DivisibleByImpl& impl = m.mutable_impl();
5286  EXPECT_EQ(42, impl.divider());
5287 
5288  impl.set_divider(0);
5289  EXPECT_EQ(0, m.mutable_impl().divider());
5290 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
testing::gmock_matchers_test::TEST ( PolymorphicMatcherTest  ,
CanAccessImpl   
)

Definition at line 5293 of file gmock-matchers_test.cc.

References testing::gmock_matchers_test::DivisibleByImpl::divider(), EXPECT_EQ, testing::PolymorphicMatcher< Impl >::impl(), and m.

5293  {
5294  const PolymorphicMatcher<DivisibleByImpl> m(DivisibleByImpl(42));
5295  const DivisibleByImpl& impl = m.impl();
5296  EXPECT_EQ(42, impl.divider());
5297 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static map< string, int > m
testing::gmock_matchers_test::TEST ( MatcherTupleTest  ,
ExplainsMatchFailure   
)

Definition at line 5299 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_EQ, testing::internal::ExplainMatchFailureTupleTo(), GreaterThan(), and std::tr1::make_tuple().

5299  {
5300  stringstream ss1;
5301  ExplainMatchFailureTupleTo(make_tuple(Matcher<char>(Eq('a')), GreaterThan(5)),
5302  make_tuple('a', 10), &ss1);
5303  EXPECT_EQ("", ss1.str()); // Successful match.
5304 
5305  stringstream ss2;
5306  ExplainMatchFailureTupleTo(make_tuple(GreaterThan(5), Matcher<char>(Eq('a'))),
5307  make_tuple(2, 'b'), &ss2);
5308  EXPECT_EQ(" Expected arg #0: is > 5\n"
5309  " Actual: 2, which is 3 less than 5\n"
5310  " Expected arg #1: is equal to 'a' (97, 0x61)\n"
5311  " Actual: 'b' (98, 0x62)\n",
5312  ss2.str()); // Failed match where both arguments need explanation.
5313 
5314  stringstream ss3;
5315  ExplainMatchFailureTupleTo(make_tuple(GreaterThan(5), Matcher<char>(Eq('a'))),
5316  make_tuple(2, 'a'), &ss3);
5317  EXPECT_EQ(" Expected arg #0: is > 5\n"
5318  " Actual: 2, which is 3 less than 5\n",
5319  ss3.str()); // Failed match where only one argument needs
5320  // explanation.
5321 }
Matcher< int > GreaterThan(int n)
internal::EqMatcher< T > Eq(T x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
tuple make_tuple()
Definition: gtest-tuple.h:675
void ExplainMatchFailureTupleTo(const MatcherTuple &matchers, const ValueTuple &values,::std::ostream *os)
testing::gmock_matchers_test::TEST ( EachTest  ,
ExplainsMatchResultCorrectly   
)

Definition at line 5325 of file gmock-matchers_test.cc.

References a, b, testing::Each(), EXPECT_EQ, Explain(), GreaterThan(), and m.

5325  {
5326  set<int> a; // empty
5327 
5328  Matcher<set<int> > m = Each(2);
5329  EXPECT_EQ("", Explain(m, a));
5330 
5331  Matcher<const int(&)[1]> n = Each(1); // NOLINT
5332 
5333  const int b[1] = {1};
5334  EXPECT_EQ("", Explain(n, b));
5335 
5336  n = Each(3);
5337  EXPECT_EQ("whose element #0 doesn't match", Explain(n, b));
5338 
5339  a.insert(1);
5340  a.insert(2);
5341  a.insert(3);
5342  m = Each(GreaterThan(0));
5343  EXPECT_EQ("", Explain(m, a));
5344 
5345  m = Each(GreaterThan(10));
5346  EXPECT_EQ("whose element #0 doesn't match, which is 9 less than 10",
5347  Explain(m, a));
5348 }
Matcher< int > GreaterThan(int n)
char b
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
static map< string, int > m
char a
internal::EachMatcher< M > Each(M matcher)
Definition: Traits.h:592
testing::gmock_matchers_test::TEST ( EachTest  ,
DescribesItselfCorrectly   
)

Definition at line 5350 of file gmock-matchers_test.cc.

References Describe(), testing::Each(), EXPECT_EQ, m, and testing::Not().

5350  {
5351  Matcher<vector<int> > m = Each(1);
5352  EXPECT_EQ("only contains elements that is equal to 1", Describe(m));
5353 
5354  Matcher<vector<int> > m2 = Not(m);
5355  EXPECT_EQ("contains some element that isn't equal to 1", Describe(m2));
5356 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
static map< string, int > m
internal::EachMatcher< M > Each(M matcher)
testing::gmock_matchers_test::TEST ( EachTest  ,
MatchesVectorWhenAllElementsMatch   
)

Definition at line 5358 of file gmock-matchers_test.cc.

References testing::Each(), EXPECT_THAT, testing::Lt(), and testing::Not().

5358  {
5359  vector<int> some_vector;
5360  EXPECT_THAT(some_vector, Each(1));
5361  some_vector.push_back(3);
5362  EXPECT_THAT(some_vector, Not(Each(1)));
5363  EXPECT_THAT(some_vector, Each(3));
5364  some_vector.push_back(1);
5365  some_vector.push_back(2);
5366  EXPECT_THAT(some_vector, Not(Each(3)));
5367  EXPECT_THAT(some_vector, Each(Lt(3.5)));
5368 
5369  vector<string> another_vector;
5370  another_vector.push_back("fee");
5371  EXPECT_THAT(another_vector, Each(string("fee")));
5372  another_vector.push_back("fie");
5373  another_vector.push_back("foe");
5374  another_vector.push_back("fum");
5375  EXPECT_THAT(another_vector, Not(Each(string("fee"))));
5376 }
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
Definition: Traits.h:588
#define EXPECT_THAT(value, matcher)
internal::EachMatcher< M > Each(M matcher)
testing::gmock_matchers_test::TEST ( EachTest  ,
MatchesMapWhenAllElementsMatch   
)

Definition at line 5378 of file gmock-matchers_test.cc.

References testing::_, bar, testing::Each(), EXPECT_THAT, testing::Gt(), testing::Not(), and testing::Pair().

5378  {
5379  map<const char*, int> my_map;
5380  const char* bar = "a string";
5381  my_map[bar] = 2;
5382  EXPECT_THAT(my_map, Each(make_pair(bar, 2)));
5383 
5384  map<string, int> another_map;
5385  EXPECT_THAT(another_map, Each(make_pair(string("fee"), 1)));
5386  another_map["fee"] = 1;
5387  EXPECT_THAT(another_map, Each(make_pair(string("fee"), 1)));
5388  another_map["fie"] = 2;
5389  another_map["foe"] = 3;
5390  another_map["fum"] = 4;
5391  EXPECT_THAT(another_map, Not(Each(make_pair(string("fee"), 1))));
5392  EXPECT_THAT(another_map, Not(Each(make_pair(string("fum"), 1))));
5393  EXPECT_THAT(another_map, Each(Pair(_, Gt(0))));
5394 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
Definition: Traits.h:594
folly::Singleton< int > bar
#define EXPECT_THAT(value, matcher)
internal::EachMatcher< M > Each(M matcher)
const internal::AnythingMatcher _
testing::gmock_matchers_test::TEST ( EachTest  ,
AcceptsMatcher   
)

Definition at line 5396 of file gmock-matchers_test.cc.

References a, testing::Each(), EXPECT_THAT, testing::Gt(), and testing::Not().

5396  {
5397  const int a[] = {1, 2, 3};
5398  EXPECT_THAT(a, Each(Gt(0)));
5399  EXPECT_THAT(a, Not(Each(Gt(1))));
5400 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
char a
#define EXPECT_THAT(value, matcher)
internal::EachMatcher< M > Each(M matcher)
testing::gmock_matchers_test::TEST ( EachTest  ,
WorksForNativeArrayAsTuple   
)

Definition at line 5402 of file gmock-matchers_test.cc.

References a, testing::Each(), EXPECT_THAT, testing::Gt(), std::tr1::make_tuple(), and testing::Not().

5402  {
5403  const int a[] = {1, 2};
5404  const int* const pointer = a;
5405  EXPECT_THAT(make_tuple(pointer, 2), Each(Gt(0)));
5406  EXPECT_THAT(make_tuple(pointer, 2), Not(Each(Gt(1))));
5407 }
internal::GtMatcher< Rhs > Gt(Rhs x)
tuple make_tuple()
Definition: gtest-tuple.h:675
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
char a
#define EXPECT_THAT(value, matcher)
internal::EachMatcher< M > Each(M matcher)
testing::gmock_matchers_test::TEST ( PointwiseTest  ,
DescribesSelf   
)

Definition at line 5437 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, IsHalfOf(), m, testing::Pointwise(), and folly::detail::rhs.

5437  {
5438  vector<int> rhs;
5439  rhs.push_back(1);
5440  rhs.push_back(2);
5441  rhs.push_back(3);
5442  const Matcher<const vector<int>&> m = Pointwise(IsHalfOf(), rhs);
5443  EXPECT_EQ("contains 3 values, where each value and its corresponding value "
5444  "in { 1, 2, 3 } are a pair where the first is half of the second",
5445  Describe(m));
5446  EXPECT_EQ("doesn't contain exactly 3 values, or contains a value x at some "
5447  "index i where x and the i-th value of { 1, 2, 3 } are a pair "
5448  "where the first isn't half of the second",
5449  DescribeNegation(m));
5450 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::PointwiseMatcher< TupleMatcher, GTEST_REMOVE_CONST_(Container)> Pointwise(const TupleMatcher &tuple_matcher, const Container &rhs)
string DescribeNegation(const Matcher< T > &m)
PolymorphicMatcher< IsHalfOfMatcher > IsHalfOf()
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
static map< string, int > m
Definition: Traits.h:588
testing::gmock_matchers_test::TEST ( PointwiseTest  ,
MakesCopyOfRhs   
)

Definition at line 5452 of file gmock-matchers_test.cc.

References EXPECT_THAT, IsHalfOf(), m, testing::Pointwise(), and folly::detail::rhs.

5452  {
5453  list<signed char> rhs;
5454  rhs.push_back(2);
5455  rhs.push_back(4);
5456 
5457  int lhs[] = {1, 2};
5458  const Matcher<const int (&)[2]> m = Pointwise(IsHalfOf(), rhs);
5459  EXPECT_THAT(lhs, m);
5460 
5461  // Changing rhs now shouldn't affect m, which made a copy of rhs.
5462  rhs.push_back(6);
5463  EXPECT_THAT(lhs, m);
5464 }
internal::PointwiseMatcher< TupleMatcher, GTEST_REMOVE_CONST_(Container)> Pointwise(const TupleMatcher &tuple_matcher, const Container &rhs)
PolymorphicMatcher< IsHalfOfMatcher > IsHalfOf()
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
static map< string, int > m
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( PointwiseTest  ,
WorksForLhsNativeArray   
)

Definition at line 5466 of file gmock-matchers_test.cc.

References EXPECT_THAT, testing::Gt(), testing::Lt(), testing::Not(), testing::Pointwise(), and folly::detail::rhs.

5466  {
5467  const int lhs[] = {1, 2, 3};
5468  vector<int> rhs;
5469  rhs.push_back(2);
5470  rhs.push_back(4);
5471  rhs.push_back(6);
5472  EXPECT_THAT(lhs, Pointwise(Lt(), rhs));
5473  EXPECT_THAT(lhs, Not(Pointwise(Gt(), rhs)));
5474 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::PointwiseMatcher< TupleMatcher, GTEST_REMOVE_CONST_(Container)> Pointwise(const TupleMatcher &tuple_matcher, const Container &rhs)
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
Definition: Traits.h:588
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( PointwiseTest  ,
WorksForRhsNativeArray   
)

Definition at line 5476 of file gmock-matchers_test.cc.

References EXPECT_THAT, testing::Gt(), testing::Lt(), testing::Not(), testing::Pointwise(), folly::detail::rhs, and testing::internal::TEST().

5476  {
5477  const int rhs[] = {1, 2, 3};
5478  vector<int> lhs;
5479  lhs.push_back(2);
5480  lhs.push_back(4);
5481  lhs.push_back(6);
5482  EXPECT_THAT(lhs, Pointwise(Gt(), rhs));
5483  EXPECT_THAT(lhs, Not(Pointwise(Lt(), rhs)));
5484 }
internal::GtMatcher< Rhs > Gt(Rhs x)
internal::PointwiseMatcher< TupleMatcher, GTEST_REMOVE_CONST_(Container)> Pointwise(const TupleMatcher &tuple_matcher, const Container &rhs)
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
Definition: Traits.h:588
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( PointwiseTest  ,
RejectsWrongSize   
)

Definition at line 5496 of file gmock-matchers_test.cc.

References EXPECT_EQ, EXPECT_THAT, Explain(), testing::Gt(), testing::Not(), testing::Pointwise(), and folly::detail::rhs.

5496  {
5497  const double lhs[2] = {1, 2};
5498  const int rhs[1] = {0};
5499  EXPECT_THAT(lhs, Not(Pointwise(Gt(), rhs)));
5500  EXPECT_EQ("which contains 2 values",
5501  Explain(Pointwise(Gt(), rhs), lhs));
5502 
5503  const int rhs2[3] = {0, 1, 2};
5504  EXPECT_THAT(lhs, Not(Pointwise(Gt(), rhs2)));
5505 }
internal::GtMatcher< Rhs > Gt(Rhs x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::PointwiseMatcher< TupleMatcher, GTEST_REMOVE_CONST_(Container)> Pointwise(const TupleMatcher &tuple_matcher, const Container &rhs)
string Explain(const MatcherType &m, const Value &x)
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( PointwiseTest  ,
RejectsWrongContent   
)

Definition at line 5507 of file gmock-matchers_test.cc.

References EXPECT_EQ, EXPECT_THAT, Explain(), IsHalfOf(), testing::Not(), testing::Pointwise(), and folly::detail::rhs.

5507  {
5508  const double lhs[3] = {1, 2, 3};
5509  const int rhs[3] = {2, 6, 4};
5510  EXPECT_THAT(lhs, Not(Pointwise(IsHalfOf(), rhs)));
5511  EXPECT_EQ("where the value pair (2, 6) at index #1 don't match, "
5512  "where the second/2 is 3",
5513  Explain(Pointwise(IsHalfOf(), rhs), lhs));
5514 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::PointwiseMatcher< TupleMatcher, GTEST_REMOVE_CONST_(Container)> Pointwise(const TupleMatcher &tuple_matcher, const Container &rhs)
string Explain(const MatcherType &m, const Value &x)
PolymorphicMatcher< IsHalfOfMatcher > IsHalfOf()
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( PointwiseTest  ,
AcceptsCorrectContent   
)

Definition at line 5516 of file gmock-matchers_test.cc.

References EXPECT_EQ, EXPECT_THAT, Explain(), IsHalfOf(), testing::Pointwise(), and folly::detail::rhs.

5516  {
5517  const double lhs[3] = {1, 2, 3};
5518  const int rhs[3] = {2, 4, 6};
5519  EXPECT_THAT(lhs, Pointwise(IsHalfOf(), rhs));
5520  EXPECT_EQ("", Explain(Pointwise(IsHalfOf(), rhs), lhs));
5521 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::PointwiseMatcher< TupleMatcher, GTEST_REMOVE_CONST_(Container)> Pointwise(const TupleMatcher &tuple_matcher, const Container &rhs)
string Explain(const MatcherType &m, const Value &x)
PolymorphicMatcher< IsHalfOfMatcher > IsHalfOf()
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( PointwiseTest  ,
AllowsMonomorphicInnerMatcher   
)

Definition at line 5523 of file gmock-matchers_test.cc.

References EXPECT_EQ, EXPECT_THAT, Explain(), IsHalfOf(), testing::Pointwise(), and folly::detail::rhs.

5523  {
5524  const double lhs[3] = {1, 2, 3};
5525  const int rhs[3] = {2, 4, 6};
5526  const Matcher<tuple<const double&, const int&> > m1 = IsHalfOf();
5527  EXPECT_THAT(lhs, Pointwise(m1, rhs));
5528  EXPECT_EQ("", Explain(Pointwise(m1, rhs), lhs));
5529 
5530  // This type works as a tuple<const double&, const int&> can be
5531  // implicitly cast to tuple<double, int>.
5532  const Matcher<tuple<double, int> > m2 = IsHalfOf();
5533  EXPECT_THAT(lhs, Pointwise(m2, rhs));
5534  EXPECT_EQ("", Explain(Pointwise(m2, rhs), lhs));
5535 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::PointwiseMatcher< TupleMatcher, GTEST_REMOVE_CONST_(Container)> Pointwise(const TupleMatcher &tuple_matcher, const Container &rhs)
string Explain(const MatcherType &m, const Value &x)
PolymorphicMatcher< IsHalfOfMatcher > IsHalfOf()
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( UnorderedPointwiseTest  ,
DescribesSelf   
)

Definition at line 5537 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, IsHalfOf(), m, folly::detail::rhs, and testing::UnorderedPointwise().

5537  {
5538  vector<int> rhs;
5539  rhs.push_back(1);
5540  rhs.push_back(2);
5541  rhs.push_back(3);
5542  const Matcher<const vector<int>&> m = UnorderedPointwise(IsHalfOf(), rhs);
5543  EXPECT_EQ(
5544  "has 3 elements and there exists some permutation of elements such "
5545  "that:\n"
5546  " - element #0 and 1 are a pair where the first is half of the second, "
5547  "and\n"
5548  " - element #1 and 2 are a pair where the first is half of the second, "
5549  "and\n"
5550  " - element #2 and 3 are a pair where the first is half of the second",
5551  Describe(m));
5552  EXPECT_EQ(
5553  "doesn't have 3 elements, or there exists no permutation of elements "
5554  "such that:\n"
5555  " - element #0 and 1 are a pair where the first is half of the second, "
5556  "and\n"
5557  " - element #1 and 2 are a pair where the first is half of the second, "
5558  "and\n"
5559  " - element #2 and 3 are a pair where the first is half of the second",
5560  DescribeNegation(m));
5561 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
PolymorphicMatcher< IsHalfOfMatcher > IsHalfOf()
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
internal::UnorderedElementsAreArrayMatcher< typename internal::BoundSecondMatcher< Tuple2Matcher, typename internal::StlContainerView< GTEST_REMOVE_CONST_(RhsContainer)>::type::value_type > > UnorderedPointwise(const Tuple2Matcher &tuple2_matcher, const RhsContainer &rhs_container)
static map< string, int > m
Definition: Traits.h:588
testing::gmock_matchers_test::TEST ( UnorderedPointwiseTest  ,
MakesCopyOfRhs   
)

Definition at line 5563 of file gmock-matchers_test.cc.

References EXPECT_THAT, IsHalfOf(), m, folly::detail::rhs, and testing::UnorderedPointwise().

5563  {
5564  list<signed char> rhs;
5565  rhs.push_back(2);
5566  rhs.push_back(4);
5567 
5568  int lhs[] = {2, 1};
5569  const Matcher<const int (&)[2]> m = UnorderedPointwise(IsHalfOf(), rhs);
5570  EXPECT_THAT(lhs, m);
5571 
5572  // Changing rhs now shouldn't affect m, which made a copy of rhs.
5573  rhs.push_back(6);
5574  EXPECT_THAT(lhs, m);
5575 }
PolymorphicMatcher< IsHalfOfMatcher > IsHalfOf()
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
internal::UnorderedElementsAreArrayMatcher< typename internal::BoundSecondMatcher< Tuple2Matcher, typename internal::StlContainerView< GTEST_REMOVE_CONST_(RhsContainer)>::type::value_type > > UnorderedPointwise(const Tuple2Matcher &tuple2_matcher, const RhsContainer &rhs_container)
static map< string, int > m
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( UnorderedPointwiseTest  ,
WorksForLhsNativeArray   
)

Definition at line 5577 of file gmock-matchers_test.cc.

References EXPECT_THAT, testing::Gt(), testing::Lt(), testing::Not(), folly::detail::rhs, and testing::UnorderedPointwise().

5577  {
5578  const int lhs[] = {1, 2, 3};
5579  vector<int> rhs;
5580  rhs.push_back(4);
5581  rhs.push_back(6);
5582  rhs.push_back(2);
5583  EXPECT_THAT(lhs, UnorderedPointwise(Lt(), rhs));
5584  EXPECT_THAT(lhs, Not(UnorderedPointwise(Gt(), rhs)));
5585 }
internal::GtMatcher< Rhs > Gt(Rhs x)
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
internal::UnorderedElementsAreArrayMatcher< typename internal::BoundSecondMatcher< Tuple2Matcher, typename internal::StlContainerView< GTEST_REMOVE_CONST_(RhsContainer)>::type::value_type > > UnorderedPointwise(const Tuple2Matcher &tuple2_matcher, const RhsContainer &rhs_container)
Definition: Traits.h:588
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( UnorderedPointwiseTest  ,
WorksForRhsNativeArray   
)

Definition at line 5587 of file gmock-matchers_test.cc.

References EXPECT_THAT, testing::Gt(), testing::Lt(), testing::Not(), folly::detail::rhs, testing::internal::TEST(), and testing::UnorderedPointwise().

5587  {
5588  const int rhs[] = {1, 2, 3};
5589  vector<int> lhs;
5590  lhs.push_back(4);
5591  lhs.push_back(2);
5592  lhs.push_back(6);
5593  EXPECT_THAT(lhs, UnorderedPointwise(Gt(), rhs));
5594  EXPECT_THAT(lhs, Not(UnorderedPointwise(Lt(), rhs)));
5595 }
internal::GtMatcher< Rhs > Gt(Rhs x)
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
internal::UnorderedElementsAreArrayMatcher< typename internal::BoundSecondMatcher< Tuple2Matcher, typename internal::StlContainerView< GTEST_REMOVE_CONST_(RhsContainer)>::type::value_type > > UnorderedPointwise(const Tuple2Matcher &tuple2_matcher, const RhsContainer &rhs_container)
Definition: Traits.h:588
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( UnorderedPointwiseTest  ,
RejectsWrongSize   
)

Definition at line 5607 of file gmock-matchers_test.cc.

References EXPECT_EQ, EXPECT_THAT, Explain(), testing::Gt(), testing::Not(), folly::detail::rhs, and testing::UnorderedPointwise().

5607  {
5608  const double lhs[2] = {1, 2};
5609  const int rhs[1] = {0};
5610  EXPECT_THAT(lhs, Not(UnorderedPointwise(Gt(), rhs)));
5611  EXPECT_EQ("which has 2 elements",
5612  Explain(UnorderedPointwise(Gt(), rhs), lhs));
5613 
5614  const int rhs2[3] = {0, 1, 2};
5615  EXPECT_THAT(lhs, Not(UnorderedPointwise(Gt(), rhs2)));
5616 }
internal::GtMatcher< Rhs > Gt(Rhs x)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
internal::UnorderedElementsAreArrayMatcher< typename internal::BoundSecondMatcher< Tuple2Matcher, typename internal::StlContainerView< GTEST_REMOVE_CONST_(RhsContainer)>::type::value_type > > UnorderedPointwise(const Tuple2Matcher &tuple2_matcher, const RhsContainer &rhs_container)
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( UnorderedPointwiseTest  ,
RejectsWrongContent   
)

Definition at line 5618 of file gmock-matchers_test.cc.

References EXPECT_EQ, EXPECT_THAT, Explain(), IsHalfOf(), testing::Not(), folly::detail::rhs, and testing::UnorderedPointwise().

5618  {
5619  const double lhs[3] = {1, 2, 3};
5620  const int rhs[3] = {2, 6, 6};
5621  EXPECT_THAT(lhs, Not(UnorderedPointwise(IsHalfOf(), rhs)));
5622  EXPECT_EQ("where the following elements don't match any matchers:\n"
5623  "element #1: 2",
5624  Explain(UnorderedPointwise(IsHalfOf(), rhs), lhs));
5625 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
PolymorphicMatcher< IsHalfOfMatcher > IsHalfOf()
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
internal::UnorderedElementsAreArrayMatcher< typename internal::BoundSecondMatcher< Tuple2Matcher, typename internal::StlContainerView< GTEST_REMOVE_CONST_(RhsContainer)>::type::value_type > > UnorderedPointwise(const Tuple2Matcher &tuple2_matcher, const RhsContainer &rhs_container)
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( UnorderedPointwiseTest  ,
AcceptsCorrectContentInSameOrder   
)

Definition at line 5627 of file gmock-matchers_test.cc.

References EXPECT_THAT, IsHalfOf(), folly::detail::rhs, and testing::UnorderedPointwise().

5627  {
5628  const double lhs[3] = {1, 2, 3};
5629  const int rhs[3] = {2, 4, 6};
5630  EXPECT_THAT(lhs, UnorderedPointwise(IsHalfOf(), rhs));
5631 }
PolymorphicMatcher< IsHalfOfMatcher > IsHalfOf()
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
internal::UnorderedElementsAreArrayMatcher< typename internal::BoundSecondMatcher< Tuple2Matcher, typename internal::StlContainerView< GTEST_REMOVE_CONST_(RhsContainer)>::type::value_type > > UnorderedPointwise(const Tuple2Matcher &tuple2_matcher, const RhsContainer &rhs_container)
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( UnorderedPointwiseTest  ,
AcceptsCorrectContentInDifferentOrder   
)

Definition at line 5633 of file gmock-matchers_test.cc.

References EXPECT_THAT, IsHalfOf(), folly::detail::rhs, and testing::UnorderedPointwise().

5633  {
5634  const double lhs[3] = {1, 2, 3};
5635  const int rhs[3] = {6, 4, 2};
5636  EXPECT_THAT(lhs, UnorderedPointwise(IsHalfOf(), rhs));
5637 }
PolymorphicMatcher< IsHalfOfMatcher > IsHalfOf()
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
internal::UnorderedElementsAreArrayMatcher< typename internal::BoundSecondMatcher< Tuple2Matcher, typename internal::StlContainerView< GTEST_REMOVE_CONST_(RhsContainer)>::type::value_type > > UnorderedPointwise(const Tuple2Matcher &tuple2_matcher, const RhsContainer &rhs_container)
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST ( UnorderedPointwiseTest  ,
AllowsMonomorphicInnerMatcher   
)

Definition at line 5639 of file gmock-matchers_test.cc.

References EXPECT_THAT, IsHalfOf(), folly::detail::rhs, and testing::UnorderedPointwise().

5639  {
5640  const double lhs[3] = {1, 2, 3};
5641  const int rhs[3] = {4, 6, 2};
5642  const Matcher<tuple<const double&, const int&> > m1 = IsHalfOf();
5643  EXPECT_THAT(lhs, UnorderedPointwise(m1, rhs));
5644 
5645  // This type works as a tuple<const double&, const int&> can be
5646  // implicitly cast to tuple<double, int>.
5647  const Matcher<tuple<double, int> > m2 = IsHalfOf();
5648  EXPECT_THAT(lhs, UnorderedPointwise(m2, rhs));
5649 }
PolymorphicMatcher< IsHalfOfMatcher > IsHalfOf()
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
internal::UnorderedElementsAreArrayMatcher< typename internal::BoundSecondMatcher< Tuple2Matcher, typename internal::StlContainerView< GTEST_REMOVE_CONST_(RhsContainer)>::type::value_type > > UnorderedPointwise(const Tuple2Matcher &tuple2_matcher, const RhsContainer &rhs_container)
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST_F ( FloatTest  ,
FloatEqApproximatelyMatchesFloats   
)

Definition at line 2902 of file gmock-matchers_test.cc.

References testing::FloatEq().

2902  {
2903  TestMatches(&FloatEq);
2904 }
internal::FloatingEqMatcher< float > FloatEq(float rhs)
testing::gmock_matchers_test::TEST_F ( FloatTest  ,
NanSensitiveFloatEqApproximatelyMatchesFloats   
)

Definition at line 2906 of file gmock-matchers_test.cc.

References testing::NanSensitiveFloatEq().

2906  {
2907  TestMatches(&NanSensitiveFloatEq);
2908 }
internal::FloatingEqMatcher< float > NanSensitiveFloatEq(float rhs)
testing::gmock_matchers_test::TEST_F ( FloatTest  ,
FloatEqCannotMatchNaN   
)

Definition at line 2910 of file gmock-matchers_test.cc.

References EXPECT_FALSE, testing::FloatEq(), m, and testing::internal::MatcherBase< T >::Matches().

2910  {
2911  // FloatEq never matches NaN.
2912  Matcher<float> m = FloatEq(nan1_);
2913  EXPECT_FALSE(m.Matches(nan1_));
2914  EXPECT_FALSE(m.Matches(nan2_));
2915  EXPECT_FALSE(m.Matches(1.0));
2916 }
static map< string, int > m
internal::FloatingEqMatcher< float > FloatEq(float rhs)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_F ( FloatTest  ,
NanSensitiveFloatEqCanMatchNaN   
)

Definition at line 2918 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::NanSensitiveFloatEq().

2918  {
2919  // NanSensitiveFloatEq will match NaN.
2920  Matcher<float> m = NanSensitiveFloatEq(nan1_);
2921  EXPECT_TRUE(m.Matches(nan1_));
2922  EXPECT_TRUE(m.Matches(nan2_));
2923  EXPECT_FALSE(m.Matches(1.0));
2924 }
internal::FloatingEqMatcher< float > NanSensitiveFloatEq(float rhs)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_F ( FloatTest  ,
FloatEqCanDescribeSelf   
)

Definition at line 2926 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, f, and testing::FloatEq().

2926  {
2927  Matcher<float> m1 = FloatEq(2.0f);
2928  EXPECT_EQ("is approximately 2", Describe(m1));
2929  EXPECT_EQ("isn't approximately 2", DescribeNegation(m1));
2930 
2931  Matcher<float> m2 = FloatEq(0.5f);
2932  EXPECT_EQ("is approximately 0.5", Describe(m2));
2933  EXPECT_EQ("isn't approximately 0.5", DescribeNegation(m2));
2934 
2935  Matcher<float> m3 = FloatEq(nan1_);
2936  EXPECT_EQ("never matches", Describe(m3));
2937  EXPECT_EQ("is anything", DescribeNegation(m3));
2938 }
string Describe(const Matcher< T > &m)
auto f
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
internal::FloatingEqMatcher< float > FloatEq(float rhs)
testing::gmock_matchers_test::TEST_F ( FloatTest  ,
NanSensitiveFloatEqCanDescribeSelf   
)

Definition at line 2940 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, f, and testing::NanSensitiveFloatEq().

2940  {
2941  Matcher<float> m1 = NanSensitiveFloatEq(2.0f);
2942  EXPECT_EQ("is approximately 2", Describe(m1));
2943  EXPECT_EQ("isn't approximately 2", DescribeNegation(m1));
2944 
2945  Matcher<float> m2 = NanSensitiveFloatEq(0.5f);
2946  EXPECT_EQ("is approximately 0.5", Describe(m2));
2947  EXPECT_EQ("isn't approximately 0.5", DescribeNegation(m2));
2948 
2949  Matcher<float> m3 = NanSensitiveFloatEq(nan1_);
2950  EXPECT_EQ("is NaN", Describe(m3));
2951  EXPECT_EQ("isn't NaN", DescribeNegation(m3));
2952 }
string Describe(const Matcher< T > &m)
auto f
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
internal::FloatingEqMatcher< float > NanSensitiveFloatEq(float rhs)
testing::gmock_matchers_test::TEST_F ( FloatNearTest  ,
FloatNearMatches   
)

Definition at line 2958 of file gmock-matchers_test.cc.

References testing::FloatNear().

2958  {
2959  TestNearMatches(&FloatNear);
2960 }
internal::FloatingEqMatcher< float > FloatNear(float rhs, float max_abs_error)
testing::gmock_matchers_test::TEST_F ( FloatNearTest  ,
NanSensitiveFloatNearApproximatelyMatchesFloats   
)

Definition at line 2962 of file gmock-matchers_test.cc.

References testing::NanSensitiveFloatNear().

2962  {
2963  TestNearMatches(&NanSensitiveFloatNear);
2964 }
internal::FloatingEqMatcher< float > NanSensitiveFloatNear(float rhs, float max_abs_error)
testing::gmock_matchers_test::TEST_F ( FloatNearTest  ,
FloatNearCanDescribeSelf   
)

Definition at line 2966 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, f, and testing::FloatNear().

2966  {
2967  Matcher<float> m1 = FloatNear(2.0f, 0.5f);
2968  EXPECT_EQ("is approximately 2 (absolute error <= 0.5)", Describe(m1));
2969  EXPECT_EQ(
2970  "isn't approximately 2 (absolute error > 0.5)", DescribeNegation(m1));
2971 
2972  Matcher<float> m2 = FloatNear(0.5f, 0.5f);
2973  EXPECT_EQ("is approximately 0.5 (absolute error <= 0.5)", Describe(m2));
2974  EXPECT_EQ(
2975  "isn't approximately 0.5 (absolute error > 0.5)", DescribeNegation(m2));
2976 
2977  Matcher<float> m3 = FloatNear(nan1_, 0.0);
2978  EXPECT_EQ("never matches", Describe(m3));
2979  EXPECT_EQ("is anything", DescribeNegation(m3));
2980 }
string Describe(const Matcher< T > &m)
auto f
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
internal::FloatingEqMatcher< float > FloatNear(float rhs, float max_abs_error)
testing::gmock_matchers_test::TEST_F ( FloatNearTest  ,
NanSensitiveFloatNearCanDescribeSelf   
)

Definition at line 2982 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, f, and testing::NanSensitiveFloatNear().

2982  {
2983  Matcher<float> m1 = NanSensitiveFloatNear(2.0f, 0.5f);
2984  EXPECT_EQ("is approximately 2 (absolute error <= 0.5)", Describe(m1));
2985  EXPECT_EQ(
2986  "isn't approximately 2 (absolute error > 0.5)", DescribeNegation(m1));
2987 
2988  Matcher<float> m2 = NanSensitiveFloatNear(0.5f, 0.5f);
2989  EXPECT_EQ("is approximately 0.5 (absolute error <= 0.5)", Describe(m2));
2990  EXPECT_EQ(
2991  "isn't approximately 0.5 (absolute error > 0.5)", DescribeNegation(m2));
2992 
2993  Matcher<float> m3 = NanSensitiveFloatNear(nan1_, 0.1f);
2994  EXPECT_EQ("is NaN", Describe(m3));
2995  EXPECT_EQ("isn't NaN", DescribeNegation(m3));
2996 }
string Describe(const Matcher< T > &m)
auto f
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
internal::FloatingEqMatcher< float > NanSensitiveFloatNear(float rhs, float max_abs_error)
testing::gmock_matchers_test::TEST_F ( FloatNearTest  ,
FloatNearCannotMatchNaN   
)

Definition at line 2998 of file gmock-matchers_test.cc.

References EXPECT_FALSE, f, testing::FloatNear(), m, and testing::internal::MatcherBase< T >::Matches().

2998  {
2999  // FloatNear never matches NaN.
3000  Matcher<float> m = FloatNear(ParentType::nan1_, 0.1f);
3001  EXPECT_FALSE(m.Matches(nan1_));
3002  EXPECT_FALSE(m.Matches(nan2_));
3003  EXPECT_FALSE(m.Matches(1.0));
3004 }
auto f
static map< string, int > m
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::FloatingEqMatcher< float > FloatNear(float rhs, float max_abs_error)
testing::gmock_matchers_test::TEST_F ( FloatNearTest  ,
NanSensitiveFloatNearCanMatchNaN   
)

Definition at line 3006 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, f, m, testing::internal::MatcherBase< T >::Matches(), and testing::NanSensitiveFloatNear().

3006  {
3007  // NanSensitiveFloatNear will match NaN.
3008  Matcher<float> m = NanSensitiveFloatNear(nan1_, 0.1f);
3009  EXPECT_TRUE(m.Matches(nan1_));
3010  EXPECT_TRUE(m.Matches(nan2_));
3011  EXPECT_FALSE(m.Matches(1.0));
3012 }
auto f
static map< string, int > m
internal::FloatingEqMatcher< float > NanSensitiveFloatNear(float rhs, float max_abs_error)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_F ( DoubleTest  ,
DoubleEqApproximatelyMatchesDoubles   
)

Definition at line 3017 of file gmock-matchers_test.cc.

References testing::DoubleEq().

3017  {
3018  TestMatches(&DoubleEq);
3019 }
internal::FloatingEqMatcher< double > DoubleEq(double rhs)
testing::gmock_matchers_test::TEST_F ( DoubleTest  ,
NanSensitiveDoubleEqApproximatelyMatchesDoubles   
)

Definition at line 3021 of file gmock-matchers_test.cc.

References testing::NanSensitiveDoubleEq().

3021  {
3022  TestMatches(&NanSensitiveDoubleEq);
3023 }
internal::FloatingEqMatcher< double > NanSensitiveDoubleEq(double rhs)
testing::gmock_matchers_test::TEST_F ( DoubleTest  ,
DoubleEqCannotMatchNaN   
)

Definition at line 3025 of file gmock-matchers_test.cc.

References testing::DoubleEq(), EXPECT_FALSE, m, and testing::internal::MatcherBase< T >::Matches().

3025  {
3026  // DoubleEq never matches NaN.
3027  Matcher<double> m = DoubleEq(nan1_);
3028  EXPECT_FALSE(m.Matches(nan1_));
3029  EXPECT_FALSE(m.Matches(nan2_));
3030  EXPECT_FALSE(m.Matches(1.0));
3031 }
internal::FloatingEqMatcher< double > DoubleEq(double rhs)
static map< string, int > m
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_F ( DoubleTest  ,
NanSensitiveDoubleEqCanMatchNaN   
)

Definition at line 3033 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::NanSensitiveDoubleEq().

3033  {
3034  // NanSensitiveDoubleEq will match NaN.
3035  Matcher<double> m = NanSensitiveDoubleEq(nan1_);
3036  EXPECT_TRUE(m.Matches(nan1_));
3037  EXPECT_TRUE(m.Matches(nan2_));
3038  EXPECT_FALSE(m.Matches(1.0));
3039 }
internal::FloatingEqMatcher< double > NanSensitiveDoubleEq(double rhs)
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_F ( DoubleTest  ,
DoubleEqCanDescribeSelf   
)

Definition at line 3041 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), testing::DoubleEq(), and EXPECT_EQ.

3041  {
3042  Matcher<double> m1 = DoubleEq(2.0);
3043  EXPECT_EQ("is approximately 2", Describe(m1));
3044  EXPECT_EQ("isn't approximately 2", DescribeNegation(m1));
3045 
3046  Matcher<double> m2 = DoubleEq(0.5);
3047  EXPECT_EQ("is approximately 0.5", Describe(m2));
3048  EXPECT_EQ("isn't approximately 0.5", DescribeNegation(m2));
3049 
3050  Matcher<double> m3 = DoubleEq(nan1_);
3051  EXPECT_EQ("never matches", Describe(m3));
3052  EXPECT_EQ("is anything", DescribeNegation(m3));
3053 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
internal::FloatingEqMatcher< double > DoubleEq(double rhs)
testing::gmock_matchers_test::TEST_F ( DoubleTest  ,
NanSensitiveDoubleEqCanDescribeSelf   
)

Definition at line 3055 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, and testing::NanSensitiveDoubleEq().

3055  {
3056  Matcher<double> m1 = NanSensitiveDoubleEq(2.0);
3057  EXPECT_EQ("is approximately 2", Describe(m1));
3058  EXPECT_EQ("isn't approximately 2", DescribeNegation(m1));
3059 
3060  Matcher<double> m2 = NanSensitiveDoubleEq(0.5);
3061  EXPECT_EQ("is approximately 0.5", Describe(m2));
3062  EXPECT_EQ("isn't approximately 0.5", DescribeNegation(m2));
3063 
3064  Matcher<double> m3 = NanSensitiveDoubleEq(nan1_);
3065  EXPECT_EQ("is NaN", Describe(m3));
3066  EXPECT_EQ("isn't NaN", DescribeNegation(m3));
3067 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::FloatingEqMatcher< double > NanSensitiveDoubleEq(double rhs)
string DescribeNegation(const Matcher< T > &m)
testing::gmock_matchers_test::TEST_F ( DoubleNearTest  ,
DoubleNearMatches   
)

Definition at line 3073 of file gmock-matchers_test.cc.

References testing::DoubleNear().

3073  {
3074  TestNearMatches(&DoubleNear);
3075 }
internal::FloatingEqMatcher< double > DoubleNear(double rhs, double max_abs_error)
testing::gmock_matchers_test::TEST_F ( DoubleNearTest  ,
NanSensitiveDoubleNearApproximatelyMatchesDoubles   
)

Definition at line 3077 of file gmock-matchers_test.cc.

References testing::NanSensitiveDoubleNear().

3077  {
3078  TestNearMatches(&NanSensitiveDoubleNear);
3079 }
internal::FloatingEqMatcher< double > NanSensitiveDoubleNear(double rhs, double max_abs_error)
testing::gmock_matchers_test::TEST_F ( DoubleNearTest  ,
DoubleNearCanDescribeSelf   
)

Definition at line 3081 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), testing::DoubleNear(), and EXPECT_EQ.

3081  {
3082  Matcher<double> m1 = DoubleNear(2.0, 0.5);
3083  EXPECT_EQ("is approximately 2 (absolute error <= 0.5)", Describe(m1));
3084  EXPECT_EQ(
3085  "isn't approximately 2 (absolute error > 0.5)", DescribeNegation(m1));
3086 
3087  Matcher<double> m2 = DoubleNear(0.5, 0.5);
3088  EXPECT_EQ("is approximately 0.5 (absolute error <= 0.5)", Describe(m2));
3089  EXPECT_EQ(
3090  "isn't approximately 0.5 (absolute error > 0.5)", DescribeNegation(m2));
3091 
3092  Matcher<double> m3 = DoubleNear(nan1_, 0.0);
3093  EXPECT_EQ("never matches", Describe(m3));
3094  EXPECT_EQ("is anything", DescribeNegation(m3));
3095 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
internal::FloatingEqMatcher< double > DoubleNear(double rhs, double max_abs_error)
testing::gmock_matchers_test::TEST_F ( DoubleNearTest  ,
ExplainsResultWhenMatchFails   
)

Definition at line 3097 of file gmock-matchers_test.cc.

References testing::DoubleNear(), EXPECT_EQ, EXPECT_TRUE, and Explain().

3097  {
3098  EXPECT_EQ("", Explain(DoubleNear(2.0, 0.1), 2.05));
3099  EXPECT_EQ("which is 0.2 from 2", Explain(DoubleNear(2.0, 0.1), 2.2));
3100  EXPECT_EQ("which is -0.3 from 2", Explain(DoubleNear(2.0, 0.1), 1.7));
3101 
3102  const string explanation = Explain(DoubleNear(2.1, 1e-10), 2.1 + 1.2e-10);
3103  // Different C++ implementations may print floating-point numbers
3104  // slightly differently.
3105  EXPECT_TRUE(explanation == "which is 1.2e-10 from 2.1" || // GCC
3106  explanation == "which is 1.2e-010 from 2.1") // MSVC
3107  << " where explanation is \"" << explanation << "\".";
3108 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string Explain(const MatcherType &m, const Value &x)
internal::FloatingEqMatcher< double > DoubleNear(double rhs, double max_abs_error)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
testing::gmock_matchers_test::TEST_F ( DoubleNearTest  ,
NanSensitiveDoubleNearCanDescribeSelf   
)

Definition at line 3110 of file gmock-matchers_test.cc.

References Describe(), DescribeNegation(), EXPECT_EQ, and testing::NanSensitiveDoubleNear().

3110  {
3111  Matcher<double> m1 = NanSensitiveDoubleNear(2.0, 0.5);
3112  EXPECT_EQ("is approximately 2 (absolute error <= 0.5)", Describe(m1));
3113  EXPECT_EQ(
3114  "isn't approximately 2 (absolute error > 0.5)", DescribeNegation(m1));
3115 
3116  Matcher<double> m2 = NanSensitiveDoubleNear(0.5, 0.5);
3117  EXPECT_EQ("is approximately 0.5 (absolute error <= 0.5)", Describe(m2));
3118  EXPECT_EQ(
3119  "isn't approximately 0.5 (absolute error > 0.5)", DescribeNegation(m2));
3120 
3121  Matcher<double> m3 = NanSensitiveDoubleNear(nan1_, 0.1);
3122  EXPECT_EQ("is NaN", Describe(m3));
3123  EXPECT_EQ("isn't NaN", DescribeNegation(m3));
3124 }
string Describe(const Matcher< T > &m)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
string DescribeNegation(const Matcher< T > &m)
internal::FloatingEqMatcher< double > NanSensitiveDoubleNear(double rhs, double max_abs_error)
testing::gmock_matchers_test::TEST_F ( DoubleNearTest  ,
DoubleNearCannotMatchNaN   
)

Definition at line 3126 of file gmock-matchers_test.cc.

References testing::DoubleNear(), EXPECT_FALSE, m, and testing::internal::MatcherBase< T >::Matches().

3126  {
3127  // DoubleNear never matches NaN.
3128  Matcher<double> m = DoubleNear(ParentType::nan1_, 0.1);
3129  EXPECT_FALSE(m.Matches(nan1_));
3130  EXPECT_FALSE(m.Matches(nan2_));
3131  EXPECT_FALSE(m.Matches(1.0));
3132 }
internal::FloatingEqMatcher< double > DoubleNear(double rhs, double max_abs_error)
static map< string, int > m
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_F ( DoubleNearTest  ,
NanSensitiveDoubleNearCanMatchNaN   
)

Definition at line 3134 of file gmock-matchers_test.cc.

References EXPECT_FALSE, EXPECT_TRUE, m, testing::internal::MatcherBase< T >::Matches(), and testing::NanSensitiveDoubleNear().

3134  {
3135  // NanSensitiveDoubleNear will match NaN.
3136  Matcher<double> m = NanSensitiveDoubleNear(nan1_, 0.1);
3137  EXPECT_TRUE(m.Matches(nan1_));
3138  EXPECT_TRUE(m.Matches(nan2_));
3139  EXPECT_FALSE(m.Matches(1.0));
3140 }
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
internal::FloatingEqMatcher< double > NanSensitiveDoubleNear(double rhs, double max_abs_error)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
WorksWithUncopyable   
)

Definition at line 4798 of file gmock-matchers_test.cc.

References EXPECT_THAT, testing::gmock_matchers_test::Uncopyable::set_value(), testing::Truly(), testing::UnorderedElementsAre(), and ValueIsPositive().

4798  {
4799  Uncopyable objs[2];
4800  objs[0].set_value(-3);
4801  objs[1].set_value(1);
4802  EXPECT_THAT(objs,
4803  UnorderedElementsAre(Truly(ValueIsPositive), UncopyableIs(-3)));
4804 }
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
bool ValueIsPositive(const Uncopyable &x)
#define EXPECT_THAT(value, matcher)
PolymorphicMatcher< internal::TrulyMatcher< Predicate > > Truly(Predicate pred)
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
SucceedsWhenExpected   
)

Definition at line 4806 of file gmock-matchers_test.cc.

References a, EXPECT_TRUE, testing::ExplainMatchResult(), GTEST_ARRAY_SIZE_, s, testing::StringMatchResultListener::str(), and testing::UnorderedElementsAre().

4806  {
4807  const int a[] = {1, 2, 3};
4808  std::vector<int> s(a, a + GTEST_ARRAY_SIZE_(a));
4809  do {
4810  StringMatchResultListener listener;
4812  s, &listener)) << listener.str();
4813  } while (std::next_permutation(s.begin(), s.end()));
4814 }
#define GTEST_ARRAY_SIZE_(array)
Definition: gtest-port.h:1092
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
char a
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
static set< string > s
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
FailsWhenAnElementMatchesNoMatcher   
)

Definition at line 4816 of file gmock-matchers_test.cc.

References a, EXPECT_FALSE, testing::ExplainMatchResult(), GTEST_ARRAY_SIZE_, s, testing::StringMatchResultListener::str(), and testing::UnorderedElementsAreArray().

4816  {
4817  const int a[] = {1, 2, 3};
4818  std::vector<int> s(a, a + GTEST_ARRAY_SIZE_(a));
4819  std::vector<Matcher<int> > mv;
4820  mv.push_back(1);
4821  mv.push_back(2);
4822  mv.push_back(2);
4823  // The element with value '3' matches nothing: fail fast.
4824  StringMatchResultListener listener;
4826  s, &listener)) << listener.str();
4827 }
#define GTEST_ARRAY_SIZE_(array)
Definition: gtest-port.h:1092
internal::UnorderedElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > UnorderedElementsAreArray(Iter first, Iter last)
char a
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
static set< string > s
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
WorksForStreamlike   
)

Definition at line 4829 of file gmock-matchers_test.cc.

References a, EXPECT_THAT, GTEST_ARRAY_SIZE_, testing::Not(), s, and testing::UnorderedElementsAre().

4829  {
4830  // Streamlike 'container' provides only minimal iterator support.
4831  // Its iterators are tagged with input_iterator_tag, and it has no
4832  // size() or empty() methods.
4833  const int a[5] = {2, 1, 4, 5, 3};
4834  Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a));
4835 
4836  EXPECT_THAT(s, UnorderedElementsAre(1, 2, 3, 4, 5));
4837  EXPECT_THAT(s, Not(UnorderedElementsAre(2, 2, 3, 4, 5)));
4838 }
#define GTEST_ARRAY_SIZE_(array)
Definition: gtest-port.h:1092
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
internal::NotMatcher< InnerMatcher > Not(InnerMatcher m)
char a
#define EXPECT_THAT(value, matcher)
static set< string > s
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
Performance   
)

Definition at line 4846 of file gmock-matchers_test.cc.

References testing::_, testing::Eq(), EXPECT_TRUE, testing::ExplainMatchResult(), i, s, testing::StringMatchResultListener::str(), and testing::UnorderedElementsAreArray().

4846  {
4847  std::vector<int> s;
4848  std::vector<Matcher<int> > mv;
4849  for (int i = 0; i < 100; ++i) {
4850  s.push_back(i);
4851  mv.push_back(_);
4852  }
4853  mv[50] = Eq(0);
4854  StringMatchResultListener listener;
4856  s, &listener)) << listener.str();
4857 }
internal::EqMatcher< T > Eq(T x)
internal::UnorderedElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > UnorderedElementsAreArray(Iter first, Iter last)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
static set< string > s
const internal::AnythingMatcher _
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
PerformanceHalfStrict   
)

Definition at line 4862 of file gmock-matchers_test.cc.

References testing::_, EXPECT_TRUE, testing::ExplainMatchResult(), i, s, testing::StringMatchResultListener::str(), and testing::UnorderedElementsAreArray().

4862  {
4863  std::vector<int> s;
4864  std::vector<Matcher<int> > mv;
4865  for (int i = 0; i < 100; ++i) {
4866  s.push_back(i);
4867  if (i & 1) {
4868  mv.push_back(_);
4869  } else {
4870  mv.push_back(i);
4871  }
4872  }
4873  StringMatchResultListener listener;
4875  s, &listener)) << listener.str();
4876 }
internal::UnorderedElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > UnorderedElementsAreArray(Iter first, Iter last)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
static set< string > s
const internal::AnythingMatcher _
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
FailMessageCountWrong   
)

Definition at line 4878 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_THAT, testing::ExplainMatchResult(), testing::StringMatchResultListener::str(), testing::UnorderedElementsAre(), and v.

4878  {
4879  std::vector<int> v;
4880  v.push_back(4);
4881  StringMatchResultListener listener;
4883  v, &listener)) << listener.str();
4884  EXPECT_THAT(listener.str(), Eq("which has 1 element"));
4885 }
auto v
internal::EqMatcher< T > Eq(T x)
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
#define EXPECT_THAT(value, matcher)
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
FailMessageCountWrongZero   
)

Definition at line 4887 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_THAT, testing::ExplainMatchResult(), testing::StringMatchResultListener::str(), testing::UnorderedElementsAre(), and v.

4887  {
4888  std::vector<int> v;
4889  StringMatchResultListener listener;
4891  v, &listener)) << listener.str();
4892  EXPECT_THAT(listener.str(), Eq(""));
4893 }
auto v
internal::EqMatcher< T > Eq(T x)
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
#define EXPECT_THAT(value, matcher)
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
FailMessageUnmatchedMatchers   
)

Definition at line 4895 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_THAT, testing::ExplainMatchResult(), testing::StringMatchResultListener::str(), testing::UnorderedElementsAre(), and v.

4895  {
4896  std::vector<int> v;
4897  v.push_back(1);
4898  v.push_back(1);
4899  StringMatchResultListener listener;
4901  v, &listener)) << listener.str();
4902  EXPECT_THAT(
4903  listener.str(),
4904  Eq("where the following matchers don't match any elements:\n"
4905  "matcher #1: is equal to 2"));
4906 }
auto v
internal::EqMatcher< T > Eq(T x)
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
#define EXPECT_THAT(value, matcher)
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
FailMessageUnmatchedElements   
)

Definition at line 4908 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_THAT, testing::ExplainMatchResult(), testing::StringMatchResultListener::str(), testing::UnorderedElementsAre(), and v.

4908  {
4909  std::vector<int> v;
4910  v.push_back(1);
4911  v.push_back(2);
4912  StringMatchResultListener listener;
4914  v, &listener)) << listener.str();
4915  EXPECT_THAT(
4916  listener.str(),
4917  Eq("where the following elements don't match any matchers:\n"
4918  "element #1: 2"));
4919 }
auto v
internal::EqMatcher< T > Eq(T x)
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
#define EXPECT_THAT(value, matcher)
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
FailMessageUnmatchedMatcherAndElement   
)

Definition at line 4921 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_FALSE, EXPECT_THAT, testing::ExplainMatchResult(), testing::StringMatchResultListener::str(), testing::UnorderedElementsAre(), and v.

4921  {
4922  std::vector<int> v;
4923  v.push_back(2);
4924  v.push_back(3);
4925  StringMatchResultListener listener;
4927  v, &listener)) << listener.str();
4928  EXPECT_THAT(
4929  listener.str(),
4930  Eq("where"
4931  " the following matchers don't match any elements:\n"
4932  "matcher #0: is equal to 1\n"
4933  "and"
4934  " where"
4935  " the following elements don't match any matchers:\n"
4936  "element #1: 3"));
4937 }
auto v
internal::EqMatcher< T > Eq(T x)
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
#define EXPECT_THAT(value, matcher)
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
FailMessageImperfectMatchOnly   
)

Definition at line 4946 of file gmock-matchers_test.cc.

References testing::AnyOf(), EMString(), EXPECT_FALSE, EXPECT_THAT, testing::ExplainMatchResult(), prefix(), testing::StringMatchResultListener::str(), testing::UnorderedElementsAre(), and v.

4946  {
4947  // A situation where all elements and matchers have a match
4948  // associated with them, but the max matching is not perfect.
4949  std::vector<string> v;
4950  v.push_back("a");
4951  v.push_back("b");
4952  v.push_back("c");
4953  StringMatchResultListener listener;
4955  UnorderedElementsAre("a", "a", AnyOf("b", "c")), v, &listener))
4956  << listener.str();
4957 
4958  string prefix =
4959  "where no permutation of the elements can satisfy all matchers, "
4960  "and the closest match is 2 of 3 matchers with the "
4961  "pairings:\n";
4962 
4963  // We have to be a bit loose here, because there are 4 valid max matches.
4964  EXPECT_THAT(
4965  listener.str(),
4966  AnyOf(prefix + "{\n " + EMString(0, 0) +
4967  ",\n " + EMString(1, 2) + "\n}",
4968  prefix + "{\n " + EMString(0, 1) +
4969  ",\n " + EMString(1, 2) + "\n}",
4970  prefix + "{\n " + EMString(0, 0) +
4971  ",\n " + EMString(2, 2) + "\n}",
4972  prefix + "{\n " + EMString(0, 1) +
4973  ",\n " + EMString(2, 2) + "\n}"));
4974 }
auto v
bool prefix(Cursor &c, uint32_t expected)
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
internal::AnyOfResult2< M1, M2 >::type AnyOf(M1 m1, M2 m2)
#define EXPECT_THAT(value, matcher)
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
static string EMString(int element, int matcher)
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
Describe   
)

Definition at line 4976 of file gmock-matchers_test.cc.

References testing::Eq(), EXPECT_THAT, and testing::UnorderedElementsAre().

4976  {
4977  EXPECT_THAT(Describe<IntVec>(UnorderedElementsAre()),
4978  Eq("is empty"));
4979  EXPECT_THAT(
4980  Describe<IntVec>(UnorderedElementsAre(345)),
4981  Eq("has 1 element and that element is equal to 345"));
4982  EXPECT_THAT(
4983  Describe<IntVec>(UnorderedElementsAre(111, 222, 333)),
4984  Eq("has 3 elements and there exists some permutation "
4985  "of elements such that:\n"
4986  " - element #0 is equal to 111, and\n"
4987  " - element #1 is equal to 222, and\n"
4988  " - element #2 is equal to 333"));
4989 }
internal::EqMatcher< T > Eq(T x)
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST_F ( UnorderedElementsAreTest  ,
DescribeNegation   
)

Definition at line 4991 of file gmock-matchers_test.cc.

References best_so_far_, testing::Eq(), EXPECT_THAT, g(), graph_, kUnused, lhs_used_, matches_, rhs_used_, and testing::UnorderedElementsAre().

4991  {
4992  EXPECT_THAT(DescribeNegation<IntVec>(UnorderedElementsAre()),
4993  Eq("isn't empty"));
4994  EXPECT_THAT(
4995  DescribeNegation<IntVec>(UnorderedElementsAre(345)),
4996  Eq("doesn't have 1 element, or has 1 element that isn't equal to 345"));
4997  EXPECT_THAT(
4998  DescribeNegation<IntVec>(UnorderedElementsAre(123, 234, 345)),
4999  Eq("doesn't have 3 elements, or there exists no permutation "
5000  "of elements such that:\n"
5001  " - element #0 is equal to 123, and\n"
5002  " - element #1 is equal to 234, and\n"
5003  " - element #2 is equal to 345"));
5004 }
internal::EqMatcher< T > Eq(T x)
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
#define EXPECT_THAT(value, matcher)
testing::gmock_matchers_test::TEST_F ( BipartiteNonSquareTest  ,
SimpleBacktracking   
)

Definition at line 5135 of file gmock-matchers_test.cc.

References testing::AnyOf(), testing::internal::MatchMatrix::DebugString(), testing::ElementsAre(), EXPECT_THAT, FindBacktrackingMaxBPM(), g(), GTEST_ARRAY_SIZE_, i, testing::Pair(), and testing::internal::MatchMatrix::SetEdge().

5135  {
5136  // .......
5137  // 0:-----\ :
5138  // 1:---\ | :
5139  // 2:---\ | :
5140  // 3:-\ | | :
5141  // :.......:
5142  // 0 1 2
5143  MatchMatrix g(4, 3);
5144  static const int kEdges[][2] = {{0, 2}, {1, 1}, {2, 1}, {3, 0}};
5145  for (size_t i = 0; i < GTEST_ARRAY_SIZE_(kEdges); ++i) {
5146  g.SetEdge(kEdges[i][0], kEdges[i][1], true);
5147  }
5149  ElementsAre(Pair(3, 0),
5150  Pair(AnyOf(1, 2), 1),
5151  Pair(0, 2))) << g.DebugString();
5152 }
#define GTEST_ARRAY_SIZE_(array)
Definition: gtest-port.h:1092
ElementMatcherPairs FindBacktrackingMaxBPM(const Graph &g)
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
internal::AnyOfResult2< M1, M2 >::type AnyOf(M1 m1, M2 m2)
#define EXPECT_THAT(value, matcher)
g_t g(f_t)
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
testing::gmock_matchers_test::TEST_P ( BipartiteTest  ,
Exhaustive   
)

Definition at line 5102 of file gmock-matchers_test.cc.

References testing::internal::MatchMatrix::DebugString(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, FindBacktrackingMaxBPM(), testing::internal::FindMaxBipartiteMatching(), testing::internal::MatchMatrix::HasEdge(), i, testing::INSTANTIATE_TEST_CASE_P(), testing::internal::MatchMatrix::LhsSize(), testing::internal::MatchMatrix::NextGraph(), testing::PrintToString(), testing::internal::MatchMatrix::RhsSize(), SCOPED_TRACE, and folly::size().

5102  {
5103  int nodes = GetParam();
5104  MatchMatrix graph(nodes, nodes);
5105  do {
5106  ElementMatcherPairs matches =
5108  EXPECT_EQ(FindBacktrackingMaxBPM(graph).size(), matches.size())
5109  << "graph: " << graph.DebugString();
5110  // Check that all elements of matches are in the graph.
5111  // Check that elements of first and second are unique.
5112  std::vector<bool> seen_element(graph.LhsSize());
5113  std::vector<bool> seen_matcher(graph.RhsSize());
5114  SCOPED_TRACE(PrintToString(matches));
5115  for (size_t i = 0; i < matches.size(); ++i) {
5116  size_t ilhs = matches[i].first;
5117  size_t irhs = matches[i].second;
5118  EXPECT_TRUE(graph.HasEdge(ilhs, irhs));
5119  EXPECT_FALSE(seen_element[ilhs]);
5120  EXPECT_FALSE(seen_matcher[irhs]);
5121  seen_element[ilhs] = true;
5122  seen_matcher[irhs] = true;
5123  }
5124  } while (graph.NextGraph());
5125 }
::std::string PrintToString(const T &value)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define SCOPED_TRACE(message)
Definition: gtest.h:2115
ElementMatcherPairs FindBacktrackingMaxBPM(const Graph &g)
::std::vector< ElementMatcherPair > ElementMatcherPairs
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
GTEST_API_ ElementMatcherPairs FindMaxBipartiteMatching(const MatchMatrix &g)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_matchers_test::TEST_P ( BipartiteNonSquareTest  ,
Exhaustive   
)

Definition at line 5155 of file gmock-matchers_test.cc.

References testing::internal::MatchMatrix::DebugString(), EXPECT_EQ, FindBacktrackingMaxBPM(), testing::internal::FindMaxBipartiteMatching(), testing::INSTANTIATE_TEST_CASE_P(), testing::internal::MatchMatrix::NextGraph(), testing::PrintToString(), and folly::size().

5155  {
5156  size_t nlhs = GetParam().first;
5157  size_t nrhs = GetParam().second;
5158  MatchMatrix graph(nlhs, nrhs);
5159  do {
5162  << "graph: " << graph.DebugString()
5163  << "\nbacktracking: "
5165  << "\nmax flow: "
5167  } while (graph.NextGraph());
5168 }
::std::string PrintToString(const T &value)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
ElementMatcherPairs FindBacktrackingMaxBPM(const Graph &g)
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
GTEST_API_ ElementMatcherPairs FindMaxBipartiteMatching(const MatchMatrix &g)
testing::gmock_matchers_test::TEST_P ( BipartiteRandomTest  ,
LargerNets   
)

Definition at line 5186 of file gmock-matchers_test.cc.

References testing::internal::MatchMatrix::DebugString(), EXPECT_EQ, FindBacktrackingMaxBPM(), testing::internal::FindMaxBipartiteMatching(), GTEST_FLAG, GTEST_FLAG_PREFIX_, testing::INSTANTIATE_TEST_CASE_P(), testing::internal::MatchMatrix::Randomize(), seed, folly::size(), and folly::detail::distributed_mutex::time().

5186  {
5187  int nodes = GetParam().first;
5188  int iters = GetParam().second;
5189  MatchMatrix graph(nodes, nodes);
5190 
5191  testing::internal::Int32 seed = GTEST_FLAG(random_seed);
5192  if (seed == 0) {
5193  seed = static_cast<testing::internal::Int32>(time(NULL));
5194  }
5195 
5196  for (; iters > 0; --iters, ++seed) {
5197  srand(static_cast<int>(seed));
5198  graph.Randomize();
5201  << " graph: " << graph.DebugString()
5202  << "\nTo reproduce the failure, rerun the test with the flag"
5203  " --" << GTEST_FLAG_PREFIX_ << "random_seed=" << seed;
5204  }
5205 }
#define GTEST_FLAG_PREFIX_
Definition: gtest-port.h:286
#define GTEST_FLAG(name)
Definition: gtest-port.h:2504
TypeWithSize< 4 >::Int Int32
Definition: gtest-port.h:2494
static const int seed
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
ElementMatcherPairs FindBacktrackingMaxBPM(const Graph &g)
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
GTEST_API_ ElementMatcherPairs FindMaxBipartiteMatching(const MatchMatrix &g)
std::chrono::nanoseconds time()
bool testing::gmock_matchers_test::ValueIsPositive ( const Uncopyable x)

Variable Documentation

const int testing::gmock_matchers_test::g_bar = 1