36 #include "gmock/gmock-matchers.h" 37 #include "gmock/gmock-more-matchers.h" 53 #include "gmock/gmock.h" 54 #include "gtest/gtest.h" 55 #include "gtest/gtest-spi.h" 57 #if GTEST_HAS_STD_FORWARD_LIST_ 58 # include <forward_list> 67 namespace gmock_matchers_test {
79 using std::stringstream;
99 using testing::IsEmpty;
159 using testing::tuple;
167 *os <<
"is > " << rhs_;
172 const int diff = lhs - rhs_;
174 *listener <<
"which is " << diff <<
" more than " << rhs_;
175 }
else if (diff == 0) {
176 *listener <<
"which is the same as " << rhs_;
178 *listener <<
"which is " << -diff <<
" less than " << rhs_;
194 return " (of type " + type_name +
")";
201 template <
typename T>
209 template <
typename T>
217 template <
typename MatcherType,
typename Value>
221 return listener.
str();
224 TEST(MatchResultListenerTest, StreamingWorks) {
226 listener <<
"hi" << 5;
240 TEST(MatchResultListenerTest, CanAccessUnderlyingStream) {
247 TEST(MatchResultListenerTest, IsInterestedWorks) {
265 *os <<
"is an even number";
274 TEST(MatcherInterfaceTest, CanBeImplementedUsingPublishedAPI) {
283 const bool match = x % 2 == 0;
285 *listener <<
"value % " << 2;
286 if (listener->
stream() != NULL) {
289 *listener->
stream() <<
" == " << (x % 2);
295 *os <<
"is an even number";
299 TEST(MatcherInterfaceTest, CanBeImplementedUsingNewAPI) {
308 TEST(MatcherTest, CanBeDefaultConstructed) {
313 TEST(MatcherTest, CanBeConstructedFromMatcherInterface) {
321 TEST(MatcherTest, CanBeImplicitlyConstructedFromValue) {
328 TEST(MatcherTest, CanBeImplicitlyConstructedFromNULL) {
350 TEST(MatcherTest, CanDescribeItself) {
356 TEST(MatcherTest, MatchAndExplain) {
364 EXPECT_EQ(
"which is 9 less than 0", listener2.str());
369 TEST(StringMatcherTest, CanBeImplicitlyConstructedFromCStringLiteral) {
381 TEST(StringMatcherTest, CanBeImplicitlyConstructedFromString) {
391 #if GTEST_HAS_STRING_PIECE_ 394 TEST(StringPieceMatcherTest, CanBeImplicitlyConstructedFromCStringLiteral) {
406 TEST(StringPieceMatcherTest, CanBeImplicitlyConstructedFromString) {
418 TEST(StringPieceMatcherTest, CanBeImplicitlyConstructedFromStringPiece) {
427 #endif // GTEST_HAS_STRING_PIECE_ 432 TEST(MakeMatcherTest, ConstructsMatcherFromMatcherInterface) {
442 template <
typename T>
446 return p == &g_bar || x == 0;
449 void DescribeTo(ostream* os)
const { *os <<
"g_bar or zero"; }
452 *os <<
"doesn't reference g_bar and is not zero";
462 TEST(MakePolymorphicMatcherTest, ConstructsMatcherUsingOldAPI) {
488 template <
typename T>
491 *listener <<
"% " << 2;
492 if (listener->
stream() != NULL) {
495 *listener->
stream() <<
" == " << (x % 2);
505 TEST(MakePolymorphicMatcherTest, ConstructsMatcherUsingNewAPI) {
530 TEST(MatcherCastTest, FromPolymorphicMatcher) {
541 explicit IntValue(
int a_value) : value_(a_value) {}
543 int value()
const {
return value_; }
550 return foo.
value() > 0;
555 TEST(MatcherCastTest, FromCompatibleType) {
571 TEST(MatcherCastTest, FromConstReferenceToNonReference) {
579 TEST(MatcherCastTest, FromReferenceToNonReference) {
587 TEST(MatcherCastTest, FromNonReferenceToConstReference) {
595 TEST(MatcherCastTest, FromNonReferenceToReference) {
605 TEST(MatcherCastTest, FromSameType) {
615 template <
typename T>
627 return os << a.
value;
630 TEST(MatcherCastTest, ConversionConstructorIsUsed) {
636 TEST(MatcherCastTest, FromConvertibleFromAny) {
652 TEST(MatcherCastTest, ValueIsNotCopied) {
676 TEST(SafeMatcherCastTest, FromPolymorphicMatcher) {
685 TEST(SafeMatcherCastTest, FromLosslesslyConvertibleArithmeticType) {
698 TEST(SafeMatcherCastTest, FromBaseClass) {
712 TEST(SafeMatcherCastTest, FromConstReferenceToReference) {
722 TEST(SafeMatcherCastTest, FromNonReferenceToConstReference) {
730 TEST(SafeMatcherCastTest, FromNonReferenceToReference) {
740 TEST(SafeMatcherCastTest, FromSameType) {
747 TEST(SafeMatcherCastTest, ConversionConstructorIsUsed) {
753 TEST(SafeMatcherCastTest, FromConvertibleFromAny) {
760 TEST(SafeMatcherCastTest, ValueIsNotCopied) {
767 TEST(ExpectThat, TakesLiterals) {
773 TEST(ExpectThat, TakesFunctions) {
775 static void Func() {}
797 TEST(ATest, WorksForDerivedClass) {
812 TEST(AnTest, MatchesAnyValue) {
827 TEST(AnTest, CanDescribeSelf) {
833 TEST(UnderscoreTest, MatchesAnyValue) {
848 TEST(UnderscoreTest, CanDescribeSelf) {
854 TEST(EqTest, MatchesEqualValue) {
856 const char a1[] =
"hi";
857 const char a2[] =
"hi";
879 TEST(EqTest, CanDescribeSelf) {
897 TEST(TypedEqTest, ChecksEqualityForGivenType) {
908 TEST(TypedEqTest, CanDescribeSelf) {
918 template <
typename T>
922 template <
typename T2>
923 static void IsTypeOf(
T2 v);
926 TEST(TypedEqTest, HasSpecifiedType) {
933 TEST(GeTest, ImplementsGreaterThanOrEqual) {
941 TEST(GeTest, CanDescribeSelf) {
947 TEST(GtTest, ImplementsGreaterThan) {
955 TEST(GtTest, CanDescribeSelf) {
961 TEST(LeTest, ImplementsLessThanOrEqual) {
969 TEST(LeTest, CanDescribeSelf) {
975 TEST(LtTest, ImplementsLessThan) {
983 TEST(LtTest, CanDescribeSelf) {
989 TEST(NeTest, ImplementsNotEqual) {
997 TEST(NeTest, CanDescribeSelf) {
1003 TEST(IsNullTest, MatchesNullPointer) {
1011 const char* p2 = NULL;
1015 #if !GTEST_OS_SYMBIAN 1027 EXPECT_FALSE(m3.Matches(reinterpret_cast<void*>(0xbeef)));
1040 TEST(IsNullTest, ReferenceToConstLinkedPtr) {
1049 #if GTEST_HAS_STD_FUNCTION_ 1050 TEST(IsNullTest, StdFunction) {
1056 #endif // GTEST_HAS_STD_FUNCTION_ 1059 TEST(IsNullTest, CanDescribeSelf) {
1066 TEST(NotNullTest, MatchesNonNullPointer) {
1074 const char* p2 = NULL;
1088 TEST(NotNullTest, ReferenceToConstLinkedPtr) {
1097 #if GTEST_HAS_STD_FUNCTION_ 1098 TEST(NotNullTest, StdFunction) {
1104 #endif // GTEST_HAS_STD_FUNCTION_ 1107 TEST(NotNullTest, CanDescribeSelf) {
1114 TEST(RefTest, MatchesSameVariable) {
1127 ss <<
"references the variable @" << &n <<
" 5";
1133 TEST(RefTest, CanBeUsedAsMatcherForConstReference) {
1171 TEST(StrEqTest, MatchesEqualString) {
1184 EXPECT_EQ(
"is equal to \"Hi-\'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\\xD3\"",
1187 string str(
"01204500800");
1191 str[0] = str[6] = str[7] = str[9] = str[10] =
'\0';
1196 TEST(StrNeTest, MatchesUnequalString) {
1212 TEST(StrCaseEqTest, MatchesEqualStringIgnoringCase) {
1224 TEST(StrCaseEqTest, MatchesEqualStringWith0IgnoringCase) {
1225 string str1(
"oabocdooeoo");
1226 string str2(
"OABOCDOOEOO");
1230 str1[3] = str2[3] =
'\0';
1234 str1[0] = str1[6] = str1[7] = str1[10] =
'\0';
1235 str2[0] = str2[6] = str2[7] = str2[10] =
'\0';
1237 str1[9] = str2[9] =
'\0';
1244 str2.append(1,
'\0');
1249 TEST(StrCaseEqTest, CanDescribeSelf) {
1254 TEST(StrCaseNeTest, MatchesUnequalStringIgnoringCase) {
1266 TEST(StrCaseNeTest, CanDescribeSelf) {
1272 TEST(HasSubstrTest, WorksForStringClasses) {
1283 TEST(HasSubstrTest, WorksForCStrings) {
1296 TEST(HasSubstrTest, CanDescribeSelf) {
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)));
1316 pair<int, std::string> p(25,
"foo");
1323 TEST(KeyTest, SafelyCastsInnerMatcher) {
1326 pair<char, bool> p(
'a',
true);
1331 TEST(KeyTest, InsideContainsUsingMap) {
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'));
1340 TEST(KeyTest, InsideContainsUsingMultimap) {
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'));
1347 container.insert(make_pair(25,
'd'));
1349 container.insert(make_pair(25,
'e'));
1368 EXPECT_EQ(
"has a first field that is equal to \"foo\"" 1369 ", and has a second field that is equal to 42",
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",
1376 EXPECT_EQ(
"has a first field that isn't equal to 13" 1377 ", and has a second field that is equal to 42",
1381 TEST(PairTest, CanExplainMatchResultTo) {
1385 EXPECT_EQ(
"whose first field does not match, which is 1 less than 0",
1386 Explain(m, make_pair(-1, -2)));
1390 EXPECT_EQ(
"whose second field does not match, which is 2 less than 0",
1391 Explain(m, make_pair(1, -2)));
1395 EXPECT_EQ(
"whose first field does not match, which is 1 less than 0",
1396 Explain(m, make_pair(-1, 2)));
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",
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)));
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)));
1420 pair<int, std::string> p(25,
"foo");
1439 TEST(PairTest, SafelyCastsInnerMatchers) {
1442 pair<char, bool> p(
'a',
true);
1449 TEST(PairTest, InsideContainsUsingMap) {
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'));
1462 TEST(StartsWithTest, MatchesStringWithGivenPrefix) {
1476 TEST(StartsWithTest, CanDescribeSelf) {
1483 TEST(EndsWithTest, MatchesStringWithGivenSuffix) {
1497 TEST(EndsWithTest, CanDescribeSelf) {
1504 TEST(MatchesRegexTest, MatchesStringMatchingGivenRegex) {
1516 TEST(MatchesRegexTest, CanDescribeSelf) {
1526 TEST(ContainsRegexTest, MatchesStringContainingGivenRegex) {
1538 TEST(ContainsRegexTest, CanDescribeSelf) {
1547 #if GTEST_HAS_STD_WSTRING 1548 TEST(StdWideStrEqTest, MatchesEqual) {
1566 str[0] = str[6] = str[7] = str[9] = str[10] = L
'\0';
1571 TEST(StdWideStrEqTest, CanDescribeSelf) {
1573 EXPECT_EQ(
"is equal to L\"Hi-\'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\"",
1577 EXPECT_EQ(
"is equal to L\"\\xD3\\x576\\x8D3\\xC74D\"",
1584 str[0] = str[6] = str[7] = str[9] = str[10] = L
'\0';
1589 TEST(StdWideStrNeTest, MatchesUnequalString) {
1600 TEST(StdWideStrNeTest, CanDescribeSelf) {
1605 TEST(StdWideStrCaseEqTest, MatchesEqualStringIgnoringCase) {
1617 TEST(StdWideStrCaseEqTest, MatchesEqualStringWith0IgnoringCase) {
1623 str1[3] = str2[3] = L
'\0';
1627 str1[0] = str1[6] = str1[7] = str1[10] = L
'\0';
1628 str2[0] = str2[6] = str2[7] = str2[10] = L
'\0';
1630 str1[9] = str2[9] = L
'\0';
1637 str2.append(1, L
'\0');
1642 TEST(StdWideStrCaseEqTest, CanDescribeSelf) {
1647 TEST(StdWideStrCaseNeTest, MatchesUnequalStringIgnoringCase) {
1659 TEST(StdWideStrCaseNeTest, CanDescribeSelf) {
1665 TEST(StdWideHasSubstrTest, WorksForStringClasses) {
1676 TEST(StdWideHasSubstrTest, WorksForCStrings) {
1689 TEST(StdWideHasSubstrTest, CanDescribeSelf) {
1696 TEST(StdWideStartsWithTest, MatchesStringWithGivenPrefix) {
1710 TEST(StdWideStartsWithTest, CanDescribeSelf) {
1717 TEST(StdWideEndsWithTest, MatchesStringWithGivenSuffix) {
1731 TEST(StdWideEndsWithTest, CanDescribeSelf) {
1736 #endif // GTEST_HAS_STD_WSTRING 1738 #if GTEST_HAS_GLOBAL_WSTRING 1739 TEST(GlobalWideStrEqTest, MatchesEqual) {
1757 str[0] = str[6] = str[7] = str[9] = str[10] = L
'\0';
1762 TEST(GlobalWideStrEqTest, CanDescribeSelf) {
1764 EXPECT_EQ(
"is equal to L\"Hi-\'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\"",
1768 EXPECT_EQ(
"is equal to L\"\\xD3\\x576\\x8D3\\xC74D\"",
1775 str[0] = str[6] = str[7] = str[9] = str[10] = L
'\0';
1780 TEST(GlobalWideStrNeTest, MatchesUnequalString) {
1791 TEST(GlobalWideStrNeTest, CanDescribeSelf) {
1796 TEST(GlobalWideStrCaseEqTest, MatchesEqualStringIgnoringCase) {
1808 TEST(GlobalWideStrCaseEqTest, MatchesEqualStringWith0IgnoringCase) {
1814 str1[3] = str2[3] = L
'\0';
1818 str1[0] = str1[6] = str1[7] = str1[10] = L
'\0';
1819 str2[0] = str2[6] = str2[7] = str2[10] = L
'\0';
1821 str1[9] = str2[9] = L
'\0';
1828 str2.append(1, L
'\0');
1833 TEST(GlobalWideStrCaseEqTest, CanDescribeSelf) {
1838 TEST(GlobalWideStrCaseNeTest, MatchesUnequalStringIgnoringCase) {
1850 TEST(GlobalWideStrCaseNeTest, CanDescribeSelf) {
1856 TEST(GlobalWideHasSubstrTest, WorksForStringClasses) {
1867 TEST(GlobalWideHasSubstrTest, WorksForCStrings) {
1880 TEST(GlobalWideHasSubstrTest, CanDescribeSelf) {
1887 TEST(GlobalWideStartsWithTest, MatchesStringWithGivenPrefix) {
1901 TEST(GlobalWideStartsWithTest, CanDescribeSelf) {
1908 TEST(GlobalWideEndsWithTest, MatchesStringWithGivenSuffix) {
1922 TEST(GlobalWideEndsWithTest, CanDescribeSelf) {
1927 #endif // GTEST_HAS_GLOBAL_WSTRING 1934 TEST(Eq2Test, MatchesEqualArguments) {
1948 TEST(Ge2Test, MatchesGreaterThanOrEqualArguments) {
1963 TEST(Gt2Test, MatchesGreaterThanArguments) {
1978 TEST(Le2Test, MatchesLessThanOrEqualArguments) {
1993 TEST(Lt2Test, MatchesLessThanArguments) {
2008 TEST(Ne2Test, MatchesUnequalArguments) {
2036 TEST(NotTest, NotMatcherSafelyCastsMonomorphicMatchers) {
2049 for (
int i = 1;
i <= num; ++
i) {
2057 TEST(AllOfTest, MatchesWhenAllMatch) {
2101 #if GTEST_LANG_CXX11 2103 TEST(AllOfTest, VariadicMatchesWhenAllMatch) {
2106 ::testing::AllOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
2121 #endif // GTEST_LANG_CXX11 2131 "((isn't equal to 1) and " 2132 "(isn't equal to 2))",
2138 "(isn't equal to 1)) and " 2139 "((isn't equal to 2) and " 2140 "(isn't equal to 3))",
2147 "((isn't equal to 3) and " 2148 "((isn't equal to 5) and " 2149 "(isn't equal to 7)))",
2154 TEST(AllOfTest, CanDescribeNegation) {
2163 "((is equal to 1) or " 2170 "(is equal to 1)) or " 2171 "((is equal to 2) or " 2179 "((is equal to 3) or " 2180 "((is equal to 5) or " 2181 "(is equal to 7)))",
2186 TEST(AllOfTest, AllOfMatcherSafelyCastsMonomorphicMatchers) {
2211 EXPECT_EQ(
"which is 20 more than 10, and which is 10 more than 20",
2217 EXPECT_EQ(
"which is 15 more than 10, and which is 5 more than 20",
2222 EXPECT_EQ(
"which is 30 more than 10, and which is 20 more than 20, " 2223 "and which is 10 more than 30",
2247 for (
int i = 1;
i <= num; ++
i) {
2255 TEST(AnyOfTest, MatchesWhenAnyMatches) {
2293 AnyOfMatches(10,
AnyOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
2296 #if GTEST_LANG_CXX11 2298 TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
2301 Matcher<int> m =
::testing::AnyOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
2305 AnyOfMatches(50,
AnyOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
2306 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2307 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
2308 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
2309 41, 42, 43, 44, 45, 46, 47, 48, 49, 50));
2312 #endif // GTEST_LANG_CXX11 2323 "((is equal to 1) or (is equal to 2))",
2328 "(is equal to 1)) or " 2329 "((is equal to 2) or " 2336 "((is equal to 3) or " 2337 "((is equal to 5) or " 2338 "(is equal to 7)))",
2343 TEST(AnyOfTest, CanDescribeNegation) {
2346 EXPECT_EQ(
"(isn't <= 1) and (isn't >= 3)",
2351 "((isn't equal to 1) and (isn't equal to 2))",
2356 "(isn't equal to 1)) and " 2357 "((isn't equal to 2) and " 2358 "(isn't equal to 3))",
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)))",
2371 TEST(AnyOfTest, AnyOfMatcherSafelyCastsMonomorphicMatchers) {
2396 EXPECT_EQ(
"which is 5 less than 10, and which is 15 less than 20",
2402 EXPECT_EQ(
"which is 5 less than 10, and which is 25 less than 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",
2436 return x > 0 ? 1 : 0;
2457 return (&n == &foo) && (n == 0);
2462 TEST(TrulyTest, MatchesWhatSatisfiesThePredicate) {
2469 TEST(TrulyTest, CanBeUsedWithFunctor) {
2479 operator bool()
const {
return number_ != 0; }
2492 TEST(TrulyTest, PredicateCanReturnAClassConvertibleToBool) {
2501 EXPECT_EQ(
"satisfies the given predicate",
2507 TEST(TrulyTest, WorksForByRefArguments) {
2516 TEST(MatchesTest, IsSatisfiedByWhatMatchesTheMatcher) {
2523 TEST(MatchesTest, WorksOnByRefArguments) {
2531 TEST(MatchesTest, WorksWithMatcherOnNonRefType) {
2540 TEST(ValueTest, WorksWithPolymorphicMatcher) {
2545 TEST(ValueTest, WorksWithMonomorphicMatcher) {
2556 TEST(ExplainMatchResultTest, WorksWithPolymorphicMatcher) {
2566 TEST(ExplainMatchResultTest, WorksWithMonomorphicMatcher) {
2582 TEST(ExplainMatchResultTest, WorksInsideMATCHER) {
2591 TEST(AllArgsTest, WorksForNonTuple) {
2606 TEST(AllArgsTest, WorksInWithClause) {
2610 .WillByDefault(
Return(1));
2622 TEST(MatcherAssertionTest, WorksWhenMatcherIsSatisfied) {
2631 TEST(MatcherAssertionTest, WorksWhenMatcherIsNotSatisfied) {
2634 static unsigned short n;
2644 "Expected: is > 10\n" 2645 " Actual: 5" +
OfType(
"unsigned short"));
2650 "Expected: (is <= 7) and (is >= 5)\n" 2651 " Actual: 0" +
OfType(
"unsigned short"));
2656 TEST(MatcherAssertionTest, WorksForByRefArguments) {
2664 "Expected: does not reference the variable @");
2667 "Actual: 0" +
OfType(
"int") +
", which is located @");
2670 #if !GTEST_OS_SYMBIAN 2684 TEST(MatcherAssertionTest, WorksForMonomorphicMatcher) {
2690 const string bad =
"bad";
2693 "Expected: ends with \"ok\"\n" 2694 " Actual: \"bad\"");
2698 "Expected: is > 5\n" 2699 " Actual: 5" +
OfType(
"int"));
2701 #endif // !GTEST_OS_SYMBIAN 2704 template <
typename RawType>
2711 : max_ulps_(Floating::kMaxUlps),
2712 zero_bits_(Floating(0).bits()),
2713 one_bits_(Floating(1).bits()),
2714 infinity_bits_(Floating(Floating::Infinity()).bits()),
2715 close_to_positive_zero_(AsBits(zero_bits_ + max_ulps_/2)),
2716 close_to_negative_zero_(AsBits(zero_bits_ + max_ulps_ - max_ulps_/2)),
2717 further_from_negative_zero_(-AsBits(
2718 zero_bits_ + max_ulps_ + 1 - max_ulps_/2)),
2719 close_to_one_(AsBits(one_bits_ + max_ulps_)),
2720 further_from_one_(AsBits(one_bits_ + max_ulps_ + 1)),
2721 infinity_(Floating::Infinity()),
2722 close_to_infinity_(AsBits(infinity_bits_ - max_ulps_)),
2723 further_from_infinity_(AsBits(infinity_bits_ - max_ulps_ - 1)),
2724 max_(Floating::Max()),
2725 nan1_(AsBits(Floating::kExponentBitMask | 1)),
2726 nan2_(AsBits(Floating::kExponentBitMask | 200)) {
2730 EXPECT_EQ(
sizeof(RawType),
sizeof(Bits));
2809 template <
typename T>
2811 return Floating::ReinterpretBits(static_cast<Bits>(value));
2816 template <
typename RawType>
2825 (*matcher_maker)(RawType, RawType)) {
2845 EXPECT_FALSE(m3.Matches(ParentType::close_to_infinity_));
2850 EXPECT_FALSE(m4.Matches(-ParentType::close_to_infinity_));
2880 EXPECT_TRUE(m10.Matches(ParentType::close_to_positive_zero_));
2902 TEST_F(FloatTest, FloatEqApproximatelyMatchesFloats) {
2906 TEST_F(FloatTest, NanSensitiveFloatEqApproximatelyMatchesFloats) {
2918 TEST_F(FloatTest, NanSensitiveFloatEqCanMatchNaN) {
2940 TEST_F(FloatTest, NanSensitiveFloatEqCanDescribeSelf) {
2962 TEST_F(FloatNearTest, NanSensitiveFloatNearApproximatelyMatchesFloats) {
2966 TEST_F(FloatNearTest, FloatNearCanDescribeSelf) {
2982 TEST_F(FloatNearTest, NanSensitiveFloatNearCanDescribeSelf) {
2998 TEST_F(FloatNearTest, FloatNearCannotMatchNaN) {
3006 TEST_F(FloatNearTest, NanSensitiveFloatNearCanMatchNaN) {
3017 TEST_F(DoubleTest, DoubleEqApproximatelyMatchesDoubles) {
3021 TEST_F(DoubleTest, NanSensitiveDoubleEqApproximatelyMatchesDoubles) {
3033 TEST_F(DoubleTest, NanSensitiveDoubleEqCanMatchNaN) {
3041 TEST_F(DoubleTest, DoubleEqCanDescribeSelf) {
3055 TEST_F(DoubleTest, NanSensitiveDoubleEqCanDescribeSelf) {
3077 TEST_F(DoubleNearTest, NanSensitiveDoubleNearApproximatelyMatchesDoubles) {
3081 TEST_F(DoubleNearTest, DoubleNearCanDescribeSelf) {
3097 TEST_F(DoubleNearTest, ExplainsResultWhenMatchFails) {
3105 EXPECT_TRUE(explanation ==
"which is 1.2e-10 from 2.1" ||
3106 explanation ==
"which is 1.2e-010 from 2.1")
3107 <<
" where explanation is \"" << explanation <<
"\".";
3110 TEST_F(DoubleNearTest, NanSensitiveDoubleNearCanDescribeSelf) {
3126 TEST_F(DoubleNearTest, DoubleNearCannotMatchNaN) {
3134 TEST_F(DoubleNearTest, NanSensitiveDoubleNearCanMatchNaN) {
3152 TEST(PointeeTest, RawPointerToConst) {
3162 TEST(PointeeTest, ReferenceToConstRawPointer) {
3172 TEST(PointeeTest, ReferenceToNonConstRawPointer) {
3190 TEST(WhenDynamicCastToTest, SameType) {
3195 Base* as_base_ptr = &derived;
3199 Not(WhenDynamicCastTo<Derived*>(
Pointee(FieldIIs(5)))));
3202 TEST(WhenDynamicCastToTest, WrongTypes) {
3210 Base* as_base_ptr = &derived;
3213 as_base_ptr = &other_derived;
3218 TEST(WhenDynamicCastToTest, AlreadyNull) {
3220 Base* as_base_ptr = NULL;
3224 struct AmbiguousCastTypes {
3225 class VirtualDerived :
public virtual Base {};
3226 class DerivedSub1 :
public VirtualDerived {};
3227 class DerivedSub2 :
public VirtualDerived {};
3228 class ManyDerivedInHierarchy :
public DerivedSub1,
public DerivedSub2 {};
3231 TEST(WhenDynamicCastToTest, AmbiguousCast) {
3232 AmbiguousCastTypes::DerivedSub1 sub1;
3233 AmbiguousCastTypes::ManyDerivedInHierarchy many_derived;
3236 static_cast<AmbiguousCastTypes::DerivedSub1*
>(&many_derived);
3238 WhenDynamicCastTo<AmbiguousCastTypes::VirtualDerived*>(
IsNull()));
3239 as_base_ptr = &sub1;
3242 WhenDynamicCastTo<AmbiguousCastTypes::VirtualDerived*>(
Not(
IsNull())));
3248 "when dynamic_cast to " + internal::GetTypeName<Derived*>() +
", ";
3250 EXPECT_EQ(prefix +
"does not point to a value that is anything",
3265 HasSubstr(
"which cannot be dynamic_cast"));
3268 TEST(WhenDynamicCastToTest, GoodReference) {
3271 Base& as_base_ref = derived;
3272 EXPECT_THAT(as_base_ref, WhenDynamicCastTo<const Derived&>(FieldIIs(4)));
3273 EXPECT_THAT(as_base_ref, WhenDynamicCastTo<const Derived&>(
Not(FieldIIs(5))));
3276 TEST(WhenDynamicCastToTest, BadReference) {
3278 Base& as_base_ref = derived;
3279 EXPECT_THAT(as_base_ref,
Not(WhenDynamicCastTo<const OtherDerived&>(
_)));
3282 #endif // GTEST_HAS_RTTI 3285 template <
typename T>
3294 T*
get() {
return val_; }
3297 const T*
get()
const {
return val_; }
3304 TEST(PointeeTest, WorksWithConstPropagatingPointers) {
3316 TEST(PointeeTest, NeverMatchesNull) {
3322 TEST(PointeeTest, MatchesAgainstAValue) {
3332 TEST(PointeeTest, CanDescribeSelf) {
3335 EXPECT_EQ(
"does not point to a value that is > 3",
3339 TEST(PointeeTest, CanExplainMatchResult) {
3346 EXPECT_EQ(
"which points to 3" +
OfType(
"long") +
", which is 2 more than 1",
3350 TEST(PointeeTest, AlwaysExplainsPointee) {
3381 :
x(rhs.
x),
y(rhs.
y),
z(rhs.
z.
value()), p(rhs.p) {}
3401 TEST(FieldTest, WorksForNonConstField) {
3411 TEST(FieldTest, WorksForConstField) {
3416 m =
Field(&AStruct::y,
Le(0.0));
3421 TEST(FieldTest, WorksForUncopyableField) {
3431 TEST(FieldTest, WorksForPointerField) {
3448 TEST(FieldTest, WorksForByRefArgument) {
3459 TEST(FieldTest, WorksForArgumentOfSubType) {
3472 TEST(FieldTest, WorksForCompatibleMatcherType) {
3492 TEST(FieldTest, CanExplainMatchResult) {
3501 "whose given field is 1" +
OfType(
"int") +
", which is 1 more than 0",
3506 TEST(FieldForPointerTest, WorksForPointerToConst) {
3516 TEST(FieldForPointerTest, WorksForPointerToNonConst) {
3526 TEST(FieldForPointerTest, WorksForReferenceToConstPointer) {
3536 TEST(FieldForPointerTest, DoesNotMatchNull) {
3543 TEST(FieldForPointerTest, WorksForArgumentOfSubType) {
3555 TEST(FieldForPointerTest, CanDescribeSelf) {
3563 TEST(FieldForPointerTest, CanExplainMatchResult) {
3569 EXPECT_EQ(
"which points to an object whose given field is 1" +
OfType(
"int"),
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));
3583 int n()
const {
return n_; }
3588 const string&
s()
const {
return s_; }
3593 double&
x()
const {
return x_; }
3606 int k()
const {
return k_; }
3613 TEST(PropertyTest, WorksForNonReferenceProperty) {
3626 TEST(PropertyTest, WorksForReferenceToConstProperty) {
3639 TEST(PropertyTest, WorksForReferenceToNonConstProperty) {
3652 TEST(PropertyTest, WorksForByValueArgument) {
3665 TEST(PropertyTest, WorksForArgumentOfSubType) {
3680 TEST(PropertyTest, WorksForCompatibleMatcherType) {
3692 TEST(PropertyTest, CanDescribeSelf) {
3696 EXPECT_EQ(
"is an object whose given property isn't >= 0",
3701 TEST(PropertyTest, CanExplainMatchResult) {
3710 "whose given property is 1" +
OfType(
"int") +
", which is 1 more than 0",
3715 TEST(PropertyForPointerTest, WorksForPointerToConst) {
3727 TEST(PropertyForPointerTest, WorksForPointerToNonConst) {
3740 TEST(PropertyForPointerTest, WorksForReferenceToConstPointer) {
3752 TEST(PropertyForPointerTest, WorksForReferenceToNonConstProperty) {
3759 TEST(PropertyForPointerTest, WorksForArgumentOfSubType) {
3773 TEST(PropertyForPointerTest, CanDescribeSelf) {
3777 EXPECT_EQ(
"is an object whose given property isn't >= 0",
3782 TEST(PropertyForPointerTest, CanExplainMatchResult) {
3789 "which points to an object whose given property is 1" +
OfType(
"int"),
3793 EXPECT_EQ(
"which points to an object whose given property is 1" +
3794 OfType(
"int") +
", which is 1 more than 0",
3804 TEST(ResultOfTest, WorksForFunctionPointers) {
3812 TEST(ResultOfTest, CanDescribeItself) {
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 " 3824 TEST(ResultOfTest, CanExplainMatchResult) {
3826 EXPECT_EQ(
"which is mapped by the given callable to 90" +
OfType(
"int"),
3830 EXPECT_EQ(
"which is mapped by the given callable to 90" +
OfType(
"int") +
3831 ", which is 5 more than 85",
Explain(matcher, 36));
3836 TEST(ResultOfTest, WorksForNonReferenceResults) {
3851 TEST(ResultOfTest, WorksForReferenceToNonConstResults) {
3873 TEST(ResultOfTest, WorksForReferenceToConstResults) {
3884 TEST(ResultOfTest, WorksForCompatibleMatcherTypes) {
3894 TEST(ResultOfDeathTest, DiesOnNullFunctionPointers) {
3897 "NULL function pointer is passed into ResultOf\\(\\)\\.");
3902 TEST(ResultOfTest, WorksForFunctionReferences) {
3910 struct Functor :
public ::std::unary_function<int, string> {
3916 TEST(ResultOfTest, WorksForFunctors) {
3932 TEST(ResultOfTest, WorksForPolymorphicFunctors) {
3940 EXPECT_TRUE(matcher_string.Matches(
"long string"));
3951 TEST(ResultOfTest, WorksForReferencingCallables) {
3968 template <
typename T>
3970 *listener <<
"which is " << (n % divider_) <<
" modulo " 3972 return (n % divider_) == 0;
3976 *os <<
"is divisible by " << divider_;
3980 *os <<
"is not divisible by " << divider_;
3996 TEST(ExplainMatchResultTest, AllOf_False_False) {
4003 TEST(ExplainMatchResultTest, AllOf_False_True) {
4010 TEST(ExplainMatchResultTest, AllOf_True_False) {
4017 TEST(ExplainMatchResultTest, AllOf_True_True) {
4022 TEST(ExplainMatchResultTest, AllOf_True_True_2) {
4027 TEST(ExplainmatcherResultTest, MonomorphicMatcher) {
4055 TEST(ByRefTest, AllowsNotCopyableConstValueInMatchers) {
4064 TEST(ByRefTest, AllowsNotCopyableValueInMatchers) {
4073 TEST(IsEmptyTest, ImplementsIsEmpty) {
4074 vector<int> container;
4076 container.push_back(0);
4078 container.push_back(1);
4082 TEST(IsEmptyTest, WorksWithString) {
4091 TEST(IsEmptyTest, CanDescribeSelf) {
4097 TEST(IsEmptyTest, ExplainsResult) {
4099 vector<int> container;
4101 container.push_back(0);
4105 TEST(SizeIsTest, ImplementsSizeIs) {
4106 vector<int> container;
4109 container.push_back(0);
4112 container.push_back(0);
4118 map<string, int> container;
4121 container.insert(make_pair(
"foo", 1));
4124 container.insert(make_pair(
"bar", 2));
4129 TEST(SizeIsTest, WorksWithReferences) {
4130 vector<int> container;
4133 container.push_back(0);
4137 TEST(SizeIsTest, CanDescribeSelf) {
4148 vector<int> container;
4152 EXPECT_EQ(
"whose size 0 doesn't match, which is 1 less than 1",
4154 container.push_back(0);
4155 container.push_back(0);
4159 EXPECT_EQ(
"whose size 2 matches, which is 1 more than 1",
4163 #if GTEST_HAS_TYPED_TEST 4167 template <
typename T>
4170 typedef testing::Types<
4175 ContainerEqTestTypes;
4181 static const int vals[] = {1, 1, 2, 3, 5, 8};
4182 TypeParam my_set(vals, vals + 6);
4190 static const int vals[] = {1, 1, 2, 3, 5, 8};
4191 static const int test_vals[] = {2, 1, 8, 5};
4192 TypeParam my_set(vals, vals + 6);
4193 TypeParam test_set(test_vals, test_vals + 4);
4196 EXPECT_EQ(
"which doesn't have these expected elements: 3",
4202 static const int vals[] = {1, 1, 2, 3, 5, 8};
4203 static const int test_vals[] = {1, 2, 3, 5, 8, 46};
4204 TypeParam my_set(vals, vals + 6);
4205 TypeParam test_set(test_vals, test_vals + 6);
4208 EXPECT_EQ(
"which has these unexpected elements: 46",
Explain(m, test_set));
4212 TYPED_TEST(ContainerEqTest, ValueAddedAndRemoved) {
4213 static const int vals[] = {1, 1, 2, 3, 5, 8};
4214 static const int test_vals[] = {1, 2, 3, 8, 46};
4215 TypeParam my_set(vals, vals + 6);
4216 TypeParam test_set(test_vals, test_vals + 5);
4219 EXPECT_EQ(
"which has these unexpected elements: 46,\n" 4220 "and doesn't have these expected elements: 5",
4225 TYPED_TEST(ContainerEqTest, DuplicateDifference) {
4226 static const int vals[] = {1, 1, 2, 3, 5, 8};
4227 static const int test_vals[] = {1, 2, 3, 5, 8};
4228 TypeParam my_set(vals, vals + 6);
4229 TypeParam test_set(test_vals, test_vals + 5);
4235 #endif // GTEST_HAS_TYPED_TEST 4239 TEST(ContainerEqExtraTest, MultipleValuesMissing) {
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);
4246 EXPECT_EQ(
"which doesn't have these expected elements: 3, 8",
4252 TEST(ContainerEqExtraTest, MultipleValuesAdded) {
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);
4259 EXPECT_EQ(
"which has these unexpected elements: 92, 46",
4264 TEST(ContainerEqExtraTest, MultipleValuesAddedAndRemoved) {
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);
4271 EXPECT_EQ(
"which has these unexpected elements: 92, 46,\n" 4272 "and doesn't have these expected elements: 5, 8",
4278 TEST(ContainerEqExtraTest, MultiSetOfIntDuplicateDifference) {
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);
4292 TEST(ContainerEqExtraTest, WorksForMaps) {
4293 map<int, std::string> my_map;
4297 map<int, std::string> test_map;
4305 EXPECT_EQ(
"which has these unexpected elements: (0, \"aa\"),\n" 4306 "and doesn't have these expected elements: (0, \"a\")",
4310 TEST(ContainerEqExtraTest, WorksForNativeArray) {
4311 int a1[] = {1, 2, 3};
4312 int a2[] = {1, 2, 3};
4313 int b[] = {1, 2, 4};
4319 TEST(ContainerEqExtraTest, WorksForTwoDimensionalNativeArray) {
4320 const char a1[][3] = {
"hi",
"lo"};
4321 const char a2[][3] = {
"hi",
"lo"};
4322 const char b[][3] = {
"lo",
"hi"};
4333 TEST(ContainerEqExtraTest, WorksForNativeArrayAsTuple) {
4334 const int a1[] = {1, 2, 3};
4335 const int a2[] = {1, 2, 3};
4336 const int b[] = {1, 2, 3, 4};
4338 const int*
const p1 = a1;
4342 const int c[] = {1, 3, 2};
4346 TEST(ContainerEqExtraTest, CopiesNativeArrayParameter) {
4348 {
"hi",
"hello",
"ciao"},
4349 {
"bye",
"see you",
"ciao"}
4353 {
"hi",
"hello",
"ciao"},
4354 {
"bye",
"see you",
"ciao"}
4364 TEST(WhenSortedByTest, WorksForEmptyContainer) {
4365 const vector<int> numbers;
4370 TEST(WhenSortedByTest, WorksForNonEmptyContainer) {
4371 vector<unsigned> numbers;
4372 numbers.push_back(3);
4373 numbers.push_back(1);
4374 numbers.push_back(2);
4375 numbers.push_back(2);
4382 TEST(WhenSortedByTest, WorksForNonVectorContainer) {
4384 words.push_back(
"say");
4385 words.push_back(
"hello");
4386 words.push_back(
"world");
4393 TEST(WhenSortedByTest, WorksForNativeArray) {
4394 const int numbers[] = {1, 3, 2, 4};
4395 const int sorted_numbers[] = {1, 2, 3, 4};
4402 TEST(WhenSortedByTest, CanDescribeSelf) {
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",
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",
4414 TEST(WhenSortedByTest, ExplainsMatchResult) {
4415 const int a[] = {2, 1};
4416 EXPECT_EQ(
"which is { 1, 2 } when sorted, whose element #0 doesn't match",
4418 EXPECT_EQ(
"which is { 1, 2 } when sorted",
4425 TEST(WhenSortedTest, WorksForEmptyContainer) {
4426 const vector<int> numbers;
4431 TEST(WhenSortedTest, WorksForNonEmptyContainer) {
4433 words.push_back(
"3");
4434 words.push_back(
"1");
4435 words.push_back(
"2");
4436 words.push_back(
"2");
4441 TEST(WhenSortedTest, WorksForMapTypes) {
4442 map<string, int> word_counts;
4443 word_counts[
"and"] = 1;
4444 word_counts[
"the"] = 1;
4445 word_counts[
"buffalo"] = 2;
4449 Pair(
"and", 1),
Pair(
"the", 1),
Pair(
"buffalo", 2)))));
4452 TEST(WhenSortedTest, WorksForMultiMapTypes) {
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));
4474 TEST(WhenSortedTest, WorksForPolymorphicMatcher) {
4482 TEST(WhenSortedTest, WorksForVectorConstRefMatcher) {
4494 template <
typename T>
4502 template <
typename InIter>
4506 return const_iterator(
this, remainder_.begin());
4509 return const_iterator(
this, remainder_.end());
4513 class ConstIter :
public std::iterator<std::input_iterator_tag,
4517 const value_type&> {
4520 typename std::list<value_type>::iterator pos)
4521 :
s_(s), pos_(pos) {}
4526 s_->remainder_.erase(pos_++);
4554 typename std::list<value_type>::iterator
pos_;
4559 typedef typename std::list<value_type>::const_iterator
Iter;
4560 const char* sep =
"";
4573 const int a[5] = {2, 1, 4, 5, 3};
4577 while (it != s.
end()) {
4583 #if GTEST_HAS_STD_FORWARD_LIST_ 4584 TEST(BeginEndDistanceIsTest, WorksWithForwardList) {
4585 std::forward_list<int> container;
4588 container.push_front(0);
4591 container.push_front(0);
4595 #endif // GTEST_HAS_STD_FORWARD_LIST_ 4597 TEST(BeginEndDistanceIsTest, WorksWithNonStdList) {
4598 const int a[5] = {1, 2, 3, 4, 5};
4603 TEST(BeginEndDistanceIsTest, CanDescribeSelf) {
4606 EXPECT_EQ(
"distance between begin() and end() isn't equal to 2",
4610 TEST(BeginEndDistanceIsTest, ExplainsResult) {
4615 vector<int> container;
4616 EXPECT_EQ(
"whose distance between begin() and end() 0 doesn't match",
4618 EXPECT_EQ(
"whose distance between begin() and end() 0 matches",
4620 EXPECT_EQ(
"whose distance between begin() and end() 0 matches",
4623 "whose distance between begin() and end() 0 doesn't match, which is 1 " 4626 container.push_back(0);
4627 container.push_back(0);
4628 EXPECT_EQ(
"whose distance between begin() and end() 2 matches",
4630 EXPECT_EQ(
"whose distance between begin() and end() 2 doesn't match",
4632 EXPECT_EQ(
"whose distance between begin() and end() 2 doesn't match",
4635 "whose distance between begin() and end() 2 matches, which is 1 more " 4640 TEST(WhenSortedTest, WorksForStreamlike) {
4643 const int a[5] = {2, 1, 4, 5, 3};
4649 TEST(WhenSortedTest, WorksForVectorConstRefMatcherOnStreamlike) {
4650 const int a[] = {2, 1, 4, 5, 3};
4660 TEST(ElemensAreStreamTest, WorksForStreamlike) {
4661 const int a[5] = {1, 2, 3, 4, 5};
4667 TEST(ElemensAreArrayStreamTest, WorksForStreamlike) {
4668 const int a[5] = {1, 2, 3, 4, 5};
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);
4683 TEST(ElementsAreTest, WorksWithUncopyable) {
4690 TEST(ElementsAreTest, TakesStlContainer) {
4691 const int actual[] = {3, 1, 2};
4693 ::std::list<int> expected;
4694 expected.push_back(3);
4695 expected.push_back(1);
4696 expected.push_back(2);
4699 expected.push_back(4);
4705 TEST(UnorderedElementsAreArrayTest, SucceedsWhenExpected) {
4706 const int a[] = {0, 1, 2, 3, 4};
4711 s, &listener)) << listener.
str();
4712 }
while (std::next_permutation(s.begin(), s.end()));
4715 TEST(UnorderedElementsAreArrayTest, VectorBool) {
4716 const bool a[] = {0, 1, 0, 1, 1};
4717 const bool b[] = {1, 0, 1, 1, 0};
4722 actual, &listener)) << listener.
str();
4725 TEST(UnorderedElementsAreArrayTest, WorksForStreamlike) {
4729 const int a[5] = {2, 1, 4, 5, 3};
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);
4740 expected.push_back(6);
4744 TEST(UnorderedElementsAreArrayTest, TakesStlContainer) {
4745 const int actual[] = {3, 1, 2};
4747 ::std::list<int> expected;
4748 expected.push_back(1);
4749 expected.push_back(2);
4750 expected.push_back(3);
4753 expected.push_back(4);
4757 #if GTEST_HAS_STD_INITIALIZER_LIST_ 4759 TEST(UnorderedElementsAreArrayTest, TakesInitializerList) {
4760 const int a[5] = {2, 1, 4, 5, 3};
4765 TEST(UnorderedElementsAreArrayTest, TakesInitializerListOfCStrings) {
4766 const string a[5] = {
"a",
"b",
"c",
"d",
"e"};
4771 TEST(UnorderedElementsAreArrayTest, TakesInitializerListOfSameTypedMatchers) {
4772 const int a[5] = {2, 1, 4, 5, 3};
4779 TEST(UnorderedElementsAreArrayTest,
4780 TakesInitializerListOfDifferentTypedMatchers) {
4781 const int a[5] = {2, 1, 4, 5, 3};
4791 #endif // GTEST_HAS_STD_INITIALIZER_LIST_ 4807 const int a[] = {1, 2, 3};
4812 s, &listener)) << listener.
str();
4813 }
while (std::next_permutation(s.begin(), s.end()));
4817 const int a[] = {1, 2, 3};
4819 std::vector<Matcher<int> > mv;
4826 s, &listener)) << listener.
str();
4833 const int a[5] = {2, 1, 4, 5, 3};
4848 std::vector<Matcher<int> > mv;
4849 for (
int i = 0;
i < 100; ++
i) {
4856 s, &listener)) << listener.
str();
4864 std::vector<Matcher<int> > mv;
4865 for (
int i = 0;
i < 100; ++
i) {
4875 s, &listener)) << listener.
str();
4883 v, &listener)) << listener.
str();
4891 v, &listener)) << listener.
str();
4901 v, &listener)) << listener.
str();
4904 Eq(
"where the following matchers don't match any elements:\n" 4905 "matcher #1: is equal to 2"));
4914 v, &listener)) << listener.
str();
4917 Eq(
"where the following elements don't match any matchers:\n" 4927 v, &listener)) << listener.
str();
4931 " the following matchers don't match any elements:\n" 4932 "matcher #0: is equal to 1\n" 4935 " the following elements don't match any matchers:\n" 4942 ss <<
"(element #" << element <<
", matcher #" << matcher <<
")";
4949 std::vector<string>
v;
4959 "where no permutation of the elements can satisfy all matchers, " 4960 "and the closest match is 2 of 3 matchers with the " 4981 Eq(
"has 1 element and that element is equal to 345"));
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"));
4996 Eq(
"doesn't have 1 element, or has 1 element that isn't equal to 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"));
5012 template <
typename Graph>
5013 class BacktrackingMaxBPMState {
5016 explicit BacktrackingMaxBPMState(
const Graph*
g) :
graph_(g) { }
5019 if (
graph_->LhsSize() == 0 ||
graph_->RhsSize() == 0) {
5024 for (
size_t irhs = 0; irhs <
graph_->RhsSize(); ++irhs) {
5034 static const size_t kUnused =
static_cast<size_t>(-1);
5036 void PushMatch(
size_t lhs,
size_t rhs) {
5052 bool RecurseInto(
size_t irhs) {
5056 for (
size_t ilhs = 0; ilhs <
graph_->LhsSize(); ++ilhs) {
5060 if (!
graph_->HasEdge(ilhs, irhs)) {
5063 PushMatch(ilhs, irhs);
5067 for (
size_t mi = irhs + 1;
mi <
graph_->RhsSize(); ++
mi) {
5068 if (!RecurseInto(
mi))
return false;
5082 template <
typename Graph>
5089 template <
typename Graph>
5092 return BacktrackingMaxBPMState<Graph>(&
g).Compute();
5103 int nodes = GetParam();
5112 std::vector<bool> seen_element(graph.
LhsSize());
5113 std::vector<bool> seen_matcher(graph.
RhsSize());
5115 for (
size_t i = 0;
i < matches.size(); ++
i) {
5116 size_t ilhs = matches[
i].first;
5117 size_t irhs = matches[
i].second;
5121 seen_element[ilhs] =
true;
5122 seen_matcher[irhs] =
true;
5128 ::testing::Range(0, 5));
5132 :
public ::testing::TestWithParam<std::pair<size_t, size_t> > {
5144 static const int kEdges[][2] = {{0, 2}, {1, 1}, {2, 1}, {3, 0}};
5146 g.
SetEdge(kEdges[
i][0], kEdges[i][1],
true);
5156 size_t nlhs = GetParam().first;
5157 size_t nrhs = GetParam().second;
5163 <<
"\nbacktracking: " 5172 std::make_pair(1, 2),
5173 std::make_pair(2, 1),
5174 std::make_pair(3, 2),
5175 std::make_pair(2, 3),
5176 std::make_pair(4, 1),
5177 std::make_pair(1, 4),
5178 std::make_pair(4, 3),
5179 std::make_pair(3, 4)));
5182 :
public ::testing::TestWithParam<std::pair<int, int> > {
5187 int nodes = GetParam().first;
5188 int iters = GetParam().second;
5196 for (; iters > 0; --iters, ++
seed) {
5197 srand(static_cast<int>(seed));
5202 <<
"\nTo reproduce the failure, rerun the test with the flag" 5210 std::make_pair(5, 10000),
5211 std::make_pair(6, 5000),
5212 std::make_pair(7, 2000),
5213 std::make_pair(8, 500),
5214 std::make_pair(9, 100)));
5218 TEST(IsReadableTypeNameTest, ReturnsTrueForShortNames) {
5225 TEST(IsReadableTypeNameTest, ReturnsTrueForLongNonTemplateNonFunctionNames) {
5231 TEST(IsReadableTypeNameTest, ReturnsFalseForLongTemplateNames) {
5237 TEST(IsReadableTypeNameTest, ReturnsFalseForLongFunctionTypeNames) {
5243 TEST(JoinAsTupleTest, JoinsEmptyTuple) {
5247 TEST(JoinAsTupleTest, JoinsOneTuple) {
5248 const char* fields[] = {
"1"};
5252 TEST(JoinAsTupleTest, JoinsTwoTuple) {
5253 const char* fields[] = {
"1",
"a"};
5257 TEST(JoinAsTupleTest, JoinsTenTuple) {
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)",
5265 TEST(FormatMatcherDescriptionTest, WorksForEmptyDescription) {
5271 const char*
params[] = {
"5"};
5274 Strings(params, params + 1)));
5276 const char* params2[] = {
"5",
"8"};
5279 Strings(params2, params2 + 2)));
5283 TEST(PolymorphicMatcherTest, CanAccessMutableImpl) {
5293 TEST(PolymorphicMatcherTest, CanAccessImpl) {
5299 TEST(MatcherTupleTest, ExplainsMatchFailure) {
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",
5318 " Actual: 2, which is 3 less than 5\n",
5325 TEST(EachTest, ExplainsMatchResultCorrectly) {
5333 const int b[1] = {1};
5346 EXPECT_EQ(
"whose element #0 doesn't match, which is 9 less than 10",
5350 TEST(EachTest, DescribesItselfCorrectly) {
5358 TEST(EachTest, MatchesVectorWhenAllElementsMatch) {
5359 vector<int> some_vector;
5361 some_vector.push_back(3);
5364 some_vector.push_back(1);
5365 some_vector.push_back(2);
5369 vector<string> another_vector;
5370 another_vector.push_back(
"fee");
5372 another_vector.push_back(
"fie");
5373 another_vector.push_back(
"foe");
5374 another_vector.push_back(
"fum");
5378 TEST(EachTest, MatchesMapWhenAllElementsMatch) {
5379 map<const char*, int> my_map;
5380 const char*
bar =
"a string";
5384 map<string, int> another_map;
5386 another_map[
"fee"] = 1;
5388 another_map[
"fie"] = 2;
5389 another_map[
"foe"] = 3;
5390 another_map[
"fum"] = 4;
5397 const int a[] = {1, 2, 3};
5402 TEST(EachTest, WorksForNativeArrayAsTuple) {
5403 const int a[] = {1, 2};
5404 const int*
const pointer =
a;
5412 template <
typename T1,
typename T2>
5415 if (get<0>(a_pair) == get<1>(a_pair)/2) {
5416 *listener <<
"where the second is " << get<1>(a_pair);
5419 *listener <<
"where the second/2 is " << get<1>(a_pair)/2;
5425 *os <<
"are a pair where the first is half of the second";
5429 *os <<
"are a pair where the first isn't half of the second";
5437 TEST(PointwiseTest, DescribesSelf) {
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",
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",
5452 TEST(PointwiseTest, MakesCopyOfRhs) {
5453 list<signed char>
rhs;
5466 TEST(PointwiseTest, WorksForLhsNativeArray) {
5467 const int lhs[] = {1, 2, 3};
5476 TEST(PointwiseTest, WorksForRhsNativeArray) {
5477 const int rhs[] = {1, 2, 3};
5486 #if GTEST_HAS_STD_INITIALIZER_LIST_ 5488 TEST(PointwiseTest, WorksForRhsInitializerList) {
5489 const vector<int> lhs{2, 4, 6};
5494 #endif // GTEST_HAS_STD_INITIALIZER_LIST_ 5496 TEST(PointwiseTest, RejectsWrongSize) {
5497 const double lhs[2] = {1, 2};
5498 const int rhs[1] = {0};
5503 const int rhs2[3] = {0, 1, 2};
5507 TEST(PointwiseTest, RejectsWrongContent) {
5508 const double lhs[3] = {1, 2, 3};
5509 const int rhs[3] = {2, 6, 4};
5511 EXPECT_EQ(
"where the value pair (2, 6) at index #1 don't match, " 5512 "where the second/2 is 3",
5516 TEST(PointwiseTest, AcceptsCorrectContent) {
5517 const double lhs[3] = {1, 2, 3};
5518 const int rhs[3] = {2, 4, 6};
5523 TEST(PointwiseTest, AllowsMonomorphicInnerMatcher) {
5524 const double lhs[3] = {1, 2, 3};
5525 const int rhs[3] = {2, 4, 6};
5537 TEST(UnorderedPointwiseTest, DescribesSelf) {
5544 "has 3 elements and there exists some permutation of elements such " 5546 " - element #0 and 1 are a pair where the first is half of the second, " 5548 " - element #1 and 2 are a pair where the first is half of the second, " 5550 " - element #2 and 3 are a pair where the first is half of the second",
5553 "doesn't have 3 elements, or there exists no permutation of elements " 5555 " - element #0 and 1 are a pair where the first is half of the second, " 5557 " - element #1 and 2 are a pair where the first is half of the second, " 5559 " - element #2 and 3 are a pair where the first is half of the second",
5563 TEST(UnorderedPointwiseTest, MakesCopyOfRhs) {
5564 list<signed char>
rhs;
5577 TEST(UnorderedPointwiseTest, WorksForLhsNativeArray) {
5578 const int lhs[] = {1, 2, 3};
5587 TEST(UnorderedPointwiseTest, WorksForRhsNativeArray) {
5588 const int rhs[] = {1, 2, 3};
5597 #if GTEST_HAS_STD_INITIALIZER_LIST_ 5599 TEST(UnorderedPointwiseTest, WorksForRhsInitializerList) {
5600 const vector<int> lhs{2, 4, 6};
5605 #endif // GTEST_HAS_STD_INITIALIZER_LIST_ 5607 TEST(UnorderedPointwiseTest, RejectsWrongSize) {
5608 const double lhs[2] = {1, 2};
5609 const int rhs[1] = {0};
5614 const int rhs2[3] = {0, 1, 2};
5618 TEST(UnorderedPointwiseTest, RejectsWrongContent) {
5619 const double lhs[3] = {1, 2, 3};
5620 const int rhs[3] = {2, 6, 6};
5622 EXPECT_EQ(
"where the following elements don't match any matchers:\n" 5627 TEST(UnorderedPointwiseTest, AcceptsCorrectContentInSameOrder) {
5628 const double lhs[3] = {1, 2, 3};
5629 const int rhs[3] = {2, 4, 6};
5633 TEST(UnorderedPointwiseTest, AcceptsCorrectContentInDifferentOrder) {
5634 const double lhs[3] = {1, 2, 3};
5635 const int rhs[3] = {6, 4, 2};
5639 TEST(UnorderedPointwiseTest, AllowsMonomorphicInnerMatcher) {
5640 const double lhs[3] = {1, 2, 3};
5641 const int rhs[3] = {4, 6, 2};
const RawType further_from_negative_zero_
INSTANTIATE_TEST_CASE_P(, CodeLocationForTESTP, Values(0))
PolymorphicMatcher< internal::IsNullMatcher > IsNull()
string Describe(const Matcher< T > &m)
#define GTEST_FLAG_PREFIX_
void DescribeTo(ostream *os) const
Matcher< int > GreaterThan(int n)
Matcher< T > MatcherCast(const M &matcher)
internal::GtMatcher< Rhs > Gt(Rhs x)
bool MatchAndExplain(const tuple< T1, T2 > &a_pair, MatchResultListener *listener) const
TYPED_TEST(CodeLocationForTYPEDTEST, Verify)
PolymorphicMatcher< internal::MatchesRegexMatcher > MatchesRegex(const internal::RE *regex)
const_iterator begin() const
static bool IsTypeOf(const T &)
internal::NeMatcher< Rhs > Ne(Rhs x)
PostIncrProxy(const value_type &value)
std::list< value_type > remainder_
PolymorphicMatcher< internal::NotNullMatcher > NotNull()
TYPED_TEST_CASE(CodeLocationForTYPEDTEST, int)
virtual bool MatchAndExplain(int x, MatchResultListener *) const
PolymorphicMatcher< internal::StartsWithMatcher< internal::string > > StartsWith(const internal::string &prefix)
void TestMatches(testing::internal::FloatingEqMatcher< RawType >(*matcher_maker)(RawType))
void TestNearMatches(testing::internal::FloatingEqMatcher< RawType >(*matcher_maker)(RawType, RawType))
bool MatchAndExplain(const T &x, MatchResultListener *listener) const
bool MatchAndExplain(const T &n, MatchResultListener *listener) const
internal::EqMatcher< T > Eq(T x)
::std::string PrintToString(const T &value)
::std::ostream * stream()
TypeWithSize< 4 >::Int Int32
std::vector< size_t > lhs_used_
const_iterator end() const
StreamCodecFactory stream
internal::SizeIsMatcher< SizeMatcher > SizeIs(const SizeMatcher &size_matcher)
MATCHER_P(UncopyableIs, inner_matcher,"")
#define GTEST_ARRAY_SIZE_(array)
bool IsPositiveIntValue(const IntValue &foo)
#define EXPECT_EQ(val1, val2)
FloatingPointNearTest< float > FloatNearTest
PolymorphicMatcher< internal::MatchesRegexMatcher > ContainsRegex(const internal::RE *regex)
internal::KeyMatcher< M > Key(M inner_matcher)
bool operator==(T *ptr, const linked_ptr< T > &x)
bool HasEdge(size_t ilhs, size_t irhs) const
internal::BeginEndDistanceIsMatcher< DistanceMatcher > BeginEndDistanceIs(const DistanceMatcher &distance_matcher)
internal::string str() const
const RawType further_from_infinity_
ConvertibleToBool(int number)
std::ostream & operator<<(std::ostream &os, const Message &sb)
InnerMatcher AllArgs(const InnerMatcher &matcher)
#define SCOPED_TRACE(message)
internal::PointwiseMatcher< TupleMatcher, GTEST_REMOVE_CONST_(Container)> Pointwise(const TupleMatcher &tuple_matcher, const Container &rhs)
string Explain(const MatcherType &m, const Value &x)
ConvertibleFromAny(int a_value)
ElementMatcherPairs FindBacktrackingMaxBPM(const Graph &g)
internal::FloatingEqMatcher< double > NanSensitiveDoubleEq(double rhs)
PolymorphicMatcher< internal::EndsWithMatcher< internal::string > > EndsWith(const internal::string &suffix)
internal::UnorderedElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > UnorderedElementsAreArray(Iter first, Iter last)
void set_divider(int a_divider)
const RawType close_to_one_
const value_type * operator->() const
void DescribeNegationTo(ostream *os) const
const Impl & impl() const
ConstPropagatingPtr(T *t)
bool prefix(Cursor &c, uint32_t expected)
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
virtual bool MatchAndExplain(int lhs, MatchResultListener *listener) const
void DescribeNegationTo(ostream *os) const
virtual void DescribeTo(ostream *os) const
void DescribeNegationTo(ostream *os) const
static const size_t kUnused
ConstIter(const Streamlike *s, typename std::list< value_type >::iterator pos)
double & DoubleFunction(double &input)
PostIncrProxy operator++(int)
std::list< value_type >::iterator pos_
string DescribeNegation(const Matcher< T > &m)
PolymorphicMatcher< IsHalfOfMatcher > IsHalfOf()
internal::AllOfResult2< M1, M2 >::type AllOf(M1 m1, M2 m2)
internal::RefMatcher< T & > Ref(T &x)
virtual void DescribeTo(ostream *os) const
void AllOfMatches(int num, const Matcher< int > &m)
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrEq(const internal::string &str)
TEST_P(CodeLocationForTESTP, Verify)
GTEST_API_ string JoinAsTuple(const Strings &fields)
::testing::tuple< long, int > Tuple2
::std::vector< ElementMatcherPair > ElementMatcherPairs
#define GTEST_DISALLOW_ASSIGN_(type)
void DescribeTo(ostream *os) const
FOLLY_PUSH_WARNING RHS rhs
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::FloatingEqMatcher< double > DoubleNear(double rhs, double max_abs_error)
bool MatchAndExplain(T x, MatchResultListener *listener) const
PolymorphicMatcher< ReferencesBarOrIsZeroImpl > ReferencesBarOrIsZero()
ElementMatcherPairs best_so_far_
TEST_F(ListenerTest, DoesFoo)
internal::FloatingEqMatcher< double > DoubleEq(double rhs)
std::vector< size_t > rhs_used_
GreaterThanMatcher(int rhs)
constexpr auto size(C const &c) -> decltype(c.size())
internal::LeMatcher< Rhs > Le(Rhs x)
PolymorphicMatcher< Impl > MakePolymorphicMatcher(const Impl &impl)
testing::internal::FloatingPoint< RawType > Floating
constexpr Params params[]
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrCaseNe(const internal::string &str)
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
def Iter(n, format, sep='')
void DescribeTo(::std::ostream *os) const
internal::ElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > ElementsAreArray(Iter first, Iter last)
const RawType close_to_negative_zero_
int operator()(const char *s)
PolymorphicMatcher< internal::HasSubstrMatcher< internal::string > > HasSubstr(const internal::string &substring)
FloatingPointNearTest< double > DoubleNearTest
bool MatchAndExplain(const T &x, MatchResultListener *) const
bool Value(const T &value, M matcher)
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
const RawType further_from_one_
void DescribeTo(ostream *os) const
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)
ConstPropagatingPtr(const ConstPropagatingPtr &other)
internal::AnyOfResult2< M1, M2 >::type AnyOf(M1 m1, M2 m2)
internal::MatcherAsPredicate< M > Matches(M matcher)
Matcher< T > MakeMatcher(const MatcherInterface< T > *impl)
ConvertibleToBool IsNotZero(int number)
int IntFunction(int input)
Streamlike(InIter first, InIter last)
::std::pair< size_t, size_t > ElementMatcherPair
internal::FloatingEqMatcher< float > NanSensitiveFloatEq(float rhs)
Encoder::MutableCompressedList list
virtual bool MatchAndExplain(int x, MatchResultListener *listener) const
bool ValueIsPositive(const Uncopyable &x)
value_type operator*() const
std::vector< int > IntVec
GTEST_API_ string FormatMatcherDescription(bool negation, const char *matcher_name, const Strings ¶m_values)
static map< string, int > m
constexpr bool is_positive(T x)
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
result_type operator()(argument_type input) const
static RawType AsBits(T value)
const RawType close_to_infinity_
PolymorphicMatcher< internal::FieldMatcher< Class, FieldType > > Field(FieldType Class::*field, const FieldMatcher &matcher)
friend std::ostream & operator<<(std::ostream &os, const Streamlike &s)
FloatingPointTest< RawType > ParentType
#define EXPECT_FATAL_FAILURE(statement, substr)
static const char *const value
const RawType close_to_positive_zero_
string IntToStringFunction(int input)
internal::FloatingEqMatcher< float > NanSensitiveFloatNear(float rhs, float max_abs_error)
PolymorphicMatcher< PolymorphicIsEvenImpl > PolymorphicIsEven()
folly::Singleton< int > bar
const int * ReferencingFunction(const int &n)
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrNe(const internal::string &str)
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
bool operator()(int n) const
void ExplainMatchFailureTupleTo(const MatcherTuple &matchers, const ValueTuple &values,::std::ostream *os)
void DescribeNegationTo(ostream *os) const
void SetEdge(size_t ilhs, size_t irhs, bool b)
Matcher< Lhs > TypedEq(const Rhs &rhs)
StrictConjunction< T< As >... > AllOf
friend bool operator==(const ConstIter &a, const ConstIter &b)
#define EXPECT_TRUE(condition)
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex)
friend bool operator!=(const ConstIter &a, const ConstIter &b)
const T & operator*() const
internal::WhenSortedByMatcher< internal::LessComparator, ContainerMatcher > WhenSorted(const ContainerMatcher &container_matcher)
internal::FloatingEqMatcher< double > NanSensitiveDoubleNear(double rhs, double max_abs_error)
#define EXPECT_THAT(value, matcher)
uint64_t diff(uint64_t a, uint64_t b)
bool ExplainMatchResult(M matcher, const T &value, MatchResultListener *listener)
string DebugString() const
#define ON_CALL(obj, call)
#define ASSERT_THAT(value, matcher)
string OfType(const string &type_name)
bool ReferencesFooAndIsZero(const int &n)
FloatingPointTest< double > DoubleTest
constexpr bool is_negative(T x)
Uncopyable & RefUncopyableFunction(Uncopyable &obj)
IsGreaterThan(int threshold)
result_type operator()(const int &n)
GTEST_API_ ElementMatcherPairs FindMaxBipartiteMatching(const MatchMatrix &g)
internal::EachMatcher< M > Each(M matcher)
bool IsReadableTypeName(const string &type_name)
::std::vector< string > Strings
TypeWithSize< sizeof(RawType)>::UInt Bits
internal::ReferenceWrapper< T > ByRef(T &l_value)
StrictConjunction< std::is_copy_constructible< T >, std::is_copy_assignable< T >> IsCopyable
bool operator==(const NotCopyable &rhs) const
internal::FloatingEqMatcher< float > FloatEq(float rhs)
ConvertibleFromAny(const T &)
#define EXPECT_NONFATAL_FAILURE(statement, substr)
FloatingPointTest< float > FloatTest
const Bits infinity_bits_
#define EXPECT_CALL(obj, call)
void DescribeNegationTo(::std::ostream *os) const
const internal::AnythingMatcher _
IntReferenceWrapper(const int &a_value)
DivisibleByImpl(int a_divider)
#define EXPECT_FALSE(condition)
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
internal::GeMatcher< Rhs > Ge(Rhs x)
PolymorphicMatcher< internal::StrEqualityMatcher< internal::string > > StrCaseEq(const internal::string &str)
void AnyOfMatches(int num, const Matcher< int > &m)
Range< const char * > StringPiece
ElementMatcherPairs matches_
internal::ContainsMatcher< M > Contains(M matcher)
bool operator>=(const NotCopyable &rhs) const
#define MOCK_METHOD2(m,...)
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
AStruct(const AStruct &rhs)
void DescribeTo(ostream *os) const
AssertionResult IsNull(const char *str)
const string & StringFunction(const string &input)
virtual void DescribeTo(ostream *os) const
internal::ResultOfMatcher< Callable > ResultOf(Callable callable, const ResultOfMatcher &matcher)
PolymorphicMatcher< internal::TrulyMatcher< Predicate > > Truly(Predicate pred)
std::chrono::nanoseconds time()
void set_s(const string &new_s)
internal::ReturnAction< R > Return(R value)
internal::WhenSortedByMatcher< Comparator, ContainerMatcher > WhenSortedBy(const Comparator &comparator, const ContainerMatcher &container_matcher)
static string EMString(int element, int matcher)
TEST(IsXDigitTest, WorksForNarrowAscii)
constexpr detail::First first
PolymorphicMatcher< DivisibleByImpl > DivisibleBy(int n)
const value_type & operator*() const
internal::FloatingEqMatcher< float > FloatNear(float rhs, float max_abs_error)