48#include "test/gmock-matchers_test.h"
51namespace gmock_matchers_test {
54TEST(AddressTest, NonConst) {
56 const Matcher<int> m = Address(Eq(&n));
69TEST(AddressTest, Const) {
71 const Matcher<int> m = Address(Eq(&n));
80TEST(AddressTest, MatcherDoesntCopy) {
81 std::unique_ptr<int> n(
new int(1));
82 const Matcher<std::unique_ptr<int>> m = Address(Eq(&n));
88 Matcher<int> matcher = Address(_);
90 EXPECT_EQ(
"does not have address that is anything",
100 explicit NotCopyable(
int a_value) : value_(a_value) {}
102 int value()
const {
return value_; }
104 bool operator==(
const NotCopyable& rhs)
const {
105 return value() == rhs.value();
108 bool operator>=(
const NotCopyable& rhs)
const {
109 return value() >= rhs.value();
115 NotCopyable(
const NotCopyable&) =
delete;
116 NotCopyable& operator=(
const NotCopyable&) =
delete;
119TEST(ByRefTest, AllowsNotCopyableConstValueInMatchers) {
120 const NotCopyable const_value1(1);
121 const Matcher<const NotCopyable&> m = Eq(
ByRef(const_value1));
123 const NotCopyable n1(1), n2(2);
128TEST(ByRefTest, AllowsNotCopyableValueInMatchers) {
129 NotCopyable value2(2);
130 const Matcher<NotCopyable&> m = Ge(
ByRef(value2));
132 NotCopyable n1(1), n2(2);
137TEST(IsEmptyTest, ImplementsIsEmpty) {
138 vector<int> container;
140 container.push_back(0);
142 container.push_back(1);
146TEST(IsEmptyTest, WorksWithString) {
151 text = std::string(
"\0", 1);
155TEST(IsEmptyTest, CanDescribeSelf) {
156 Matcher<vector<int>> m =
IsEmpty();
161TEST(IsEmptyTest, ExplainsResult) {
162 Matcher<vector<int>> m =
IsEmpty();
163 vector<int> container;
165 container.push_back(0);
169TEST(IsEmptyTest, WorksWithMoveOnly) {
170 ContainerHelper helper;
175TEST(IsTrueTest, IsTrueIsFalse) {
203 std::unique_ptr<int> null_unique;
204 std::unique_ptr<int> nonnull_unique(
new int(0));
211#ifdef GTEST_HAS_TYPED_TEST
219 ContainerEqTestTypes;
225 static const int vals[] = {1, 1, 2, 3, 5, 8};
226 TypeParam my_set(vals, vals + 6);
227 const Matcher<TypeParam> m = ContainerEq(my_set);
234 static const int vals[] = {1, 1, 2, 3, 5, 8};
235 static const int test_vals[] = {2, 1, 8, 5};
236 TypeParam my_set(vals, vals + 6);
237 TypeParam test_set(test_vals, test_vals + 4);
238 const Matcher<TypeParam> m = ContainerEq(my_set);
240 EXPECT_EQ(
"which doesn't have these expected elements: 3",
246 static const int vals[] = {1, 1, 2, 3, 5, 8};
247 static const int test_vals[] = {1, 2, 3, 5, 8, 46};
248 TypeParam my_set(vals, vals + 6);
249 TypeParam test_set(test_vals, test_vals + 6);
250 const Matcher<const TypeParam&> m = ContainerEq(my_set);
256TYPED_TEST(ContainerEqTest, ValueAddedAndRemoved) {
257 static const int vals[] = {1, 1, 2, 3, 5, 8};
258 static const int test_vals[] = {1, 2, 3, 8, 46};
259 TypeParam my_set(vals, vals + 6);
260 TypeParam test_set(test_vals, test_vals + 5);
261 const Matcher<TypeParam> m = ContainerEq(my_set);
264 "which has these unexpected elements: 46,\n"
265 "and doesn't have these expected elements: 5",
270TYPED_TEST(ContainerEqTest, DuplicateDifference) {
271 static const int vals[] = {1, 1, 2, 3, 5, 8};
272 static const int test_vals[] = {1, 2, 3, 5, 8};
273 TypeParam my_set(vals, vals + 6);
274 TypeParam test_set(test_vals, test_vals + 5);
275 const Matcher<const TypeParam&> m = ContainerEq(my_set);
284TEST(ContainerEqExtraTest, MultipleValuesMissing) {
285 static const int vals[] = {1, 1, 2, 3, 5, 8};
286 static const int test_vals[] = {2, 1, 5};
287 vector<int> my_set(vals, vals + 6);
288 vector<int> test_set(test_vals, test_vals + 3);
289 const Matcher<vector<int>> m = ContainerEq(my_set);
291 EXPECT_EQ(
"which doesn't have these expected elements: 3, 8",
297TEST(ContainerEqExtraTest, MultipleValuesAdded) {
298 static const int vals[] = {1, 1, 2, 3, 5, 8};
299 static const int test_vals[] = {1, 2, 92, 3, 5, 8, 46};
300 list<size_t> my_set(vals, vals + 6);
301 list<size_t> test_set(test_vals, test_vals + 7);
302 const Matcher<const list<size_t>&> m = ContainerEq(my_set);
304 EXPECT_EQ(
"which has these unexpected elements: 92, 46",
309TEST(ContainerEqExtraTest, MultipleValuesAddedAndRemoved) {
310 static const int vals[] = {1, 1, 2, 3, 5, 8};
311 static const int test_vals[] = {1, 2, 3, 92, 46};
312 list<size_t> my_set(vals, vals + 6);
313 list<size_t> test_set(test_vals, test_vals + 5);
314 const Matcher<const list<size_t>> m = ContainerEq(my_set);
317 "which has these unexpected elements: 92, 46,\n"
318 "and doesn't have these expected elements: 5, 8",
324TEST(ContainerEqExtraTest, MultiSetOfIntDuplicateDifference) {
325 static const int vals[] = {1, 1, 2, 3, 5, 8};
326 static const int test_vals[] = {1, 2, 3, 5, 8};
327 vector<int> my_set(vals, vals + 6);
328 vector<int> test_set(test_vals, test_vals + 5);
329 const Matcher<vector<int>> m = ContainerEq(my_set);
338TEST(ContainerEqExtraTest, WorksForMaps) {
339 map<int, std::string> my_map;
343 map<int, std::string> test_map;
347 const Matcher<const map<int, std::string>&> m = ContainerEq(my_map);
352 "which has these unexpected elements: (0, \"aa\"),\n"
353 "and doesn't have these expected elements: (0, \"a\")",
357TEST(ContainerEqExtraTest, WorksForNativeArray) {
358 int a1[] = {1, 2, 3};
359 int a2[] = {1, 2, 3};
366TEST(ContainerEqExtraTest, WorksForTwoDimensionalNativeArray) {
367 const char a1[][3] = {
"hi",
"lo"};
368 const char a2[][3] = {
"hi",
"lo"};
369 const char b[][3] = {
"lo",
"hi"};
376 EXPECT_THAT(a1, ElementsAre(ContainerEq(a2[0]), ContainerEq(a2[1])));
377 EXPECT_THAT(a1, ElementsAre(Not(ContainerEq(b[0])), ContainerEq(a2[1])));
380TEST(ContainerEqExtraTest, WorksForNativeArrayAsTuple) {
381 const int a1[] = {1, 2, 3};
382 const int a2[] = {1, 2, 3};
383 const int b[] = {1, 2, 3, 4};
385 const int*
const p1 = a1;
386 EXPECT_THAT(std::make_tuple(p1, 3), ContainerEq(a2));
387 EXPECT_THAT(std::make_tuple(p1, 3), Not(ContainerEq(b)));
389 const int c[] = {1, 3, 2};
390 EXPECT_THAT(std::make_tuple(p1, 3), Not(ContainerEq(c)));
393TEST(ContainerEqExtraTest, CopiesNativeArrayParameter) {
394 std::string a1[][3] = {{
"hi",
"hello",
"ciao"}, {
"bye",
"see you",
"ciao"}};
396 std::string a2[][3] = {{
"hi",
"hello",
"ciao"}, {
"bye",
"see you",
"ciao"}};
398 const Matcher<
const std::string(&)[2][3]> m = ContainerEq(a2);
411template <
typename Graph>
412class BacktrackingMaxBPMState {
415 explicit BacktrackingMaxBPMState(
const Graph* g) : graph_(g) {}
417 ElementMatcherPairs Compute() {
418 if (graph_->LhsSize() == 0 || graph_->RhsSize() == 0) {
421 lhs_used_.assign(graph_->LhsSize(), kUnused);
422 rhs_used_.assign(graph_->RhsSize(), kUnused);
423 for (
size_t irhs = 0; irhs < graph_->RhsSize(); ++irhs) {
426 if (best_so_far_.size() == graph_->RhsSize())
break;
432 static const size_t kUnused =
static_cast<size_t>(-1);
434 void PushMatch(
size_t lhs,
size_t rhs) {
435 matches_.push_back(ElementMatcherPair(lhs, rhs));
436 lhs_used_[lhs] = rhs;
437 rhs_used_[rhs] = lhs;
438 if (matches_.size() > best_so_far_.size()) {
439 best_so_far_ = matches_;
444 const ElementMatcherPair& back = matches_.back();
445 lhs_used_[back.first] = kUnused;
446 rhs_used_[back.second] = kUnused;
450 bool RecurseInto(
size_t irhs) {
451 if (rhs_used_[irhs] != kUnused) {
454 for (
size_t ilhs = 0; ilhs < graph_->LhsSize(); ++ilhs) {
455 if (lhs_used_[ilhs] != kUnused) {
458 if (!graph_->HasEdge(ilhs, irhs)) {
461 PushMatch(ilhs, irhs);
462 if (best_so_far_.size() == graph_->RhsSize()) {
465 for (
size_t mi = irhs + 1; mi < graph_->RhsSize(); ++mi) {
466 if (!RecurseInto(mi))
return false;
474 std::vector<size_t> lhs_used_;
475 std::vector<size_t> rhs_used_;
476 ElementMatcherPairs matches_;
477 ElementMatcherPairs best_so_far_;
480template <
typename Graph>
481const size_t BacktrackingMaxBPMState<Graph>::kUnused;
487template <
typename Graph>
488ElementMatcherPairs FindBacktrackingMaxBPM(
const Graph& g) {
489 return BacktrackingMaxBPMState<Graph>(&g).Compute();
499TEST_P(BipartiteTest, Exhaustive) {
500 size_t nodes = GetParam();
501 MatchMatrix graph(nodes, nodes);
504 EXPECT_EQ(FindBacktrackingMaxBPM(graph).size(), matches.size())
505 <<
"graph: " << graph.DebugString();
508 std::vector<bool> seen_element(graph.LhsSize());
509 std::vector<bool> seen_matcher(graph.RhsSize());
511 for (
size_t i = 0;
i < matches.size(); ++
i) {
512 size_t ilhs = matches[
i].first;
513 size_t irhs = matches[
i].second;
517 seen_element[ilhs] =
true;
518 seen_matcher[irhs] =
true;
520 }
while (graph.NextGraph());
527class BipartiteNonSquareTest
530TEST_F(BipartiteNonSquareTest, SimpleBacktracking) {
539 constexpr std::array<std::array<size_t, 2>, 4> kEdges = {
540 {{{0, 2}}, {{1, 1}}, {{2, 1}}, {{3, 0}}}};
541 for (
size_t i = 0;
i < kEdges.size(); ++
i) {
542 g.SetEdge(kEdges[
i][0], kEdges[
i][1],
true);
545 ElementsAre(Pair(3, 0), Pair(AnyOf(1, 2), 1), Pair(0, 2)))
550TEST_P(BipartiteNonSquareTest, Exhaustive) {
551 size_t nlhs = GetParam().first;
552 size_t nrhs = GetParam().second;
553 MatchMatrix graph(nlhs, nrhs);
555 EXPECT_EQ(FindBacktrackingMaxBPM(graph).size(),
557 <<
"graph: " << graph.DebugString()
558 <<
"\nbacktracking: " <<
PrintToString(FindBacktrackingMaxBPM(graph))
561 }
while (graph.NextGraph());
565 AllGraphs, BipartiteNonSquareTest,
567 std::make_pair(3, 2), std::make_pair(2, 3),
568 std::make_pair(4, 1), std::make_pair(1, 4),
569 std::make_pair(4, 3), std::make_pair(3, 4)));
571class BipartiteRandomTest
575TEST_P(BipartiteRandomTest, LargerNets) {
576 int nodes = GetParam().first;
577 int iters = GetParam().second;
578 MatchMatrix graph(
static_cast<size_t>(nodes),
static_cast<size_t>(nodes));
582 seed =
static_cast<uint32_t
>(time(
nullptr));
585 for (; iters > 0; --iters, ++seed) {
586 srand(
static_cast<unsigned int>(seed));
588 EXPECT_EQ(FindBacktrackingMaxBPM(graph).size(),
590 <<
" graph: " << graph.DebugString()
591 <<
"\nTo reproduce the failure, rerun the test with the flag"
600 std::make_pair(6, 5000),
601 std::make_pair(7, 2000),
602 std::make_pair(8, 500),
603 std::make_pair(9, 100)));
607TEST(IsReadableTypeNameTest, ReturnsTrueForShortNames) {
609 EXPECT_TRUE(IsReadableTypeName(
"const unsigned char*"));
610 EXPECT_TRUE(IsReadableTypeName(
"MyMap<int, void*>"));
611 EXPECT_TRUE(IsReadableTypeName(
"void (*)(int, bool)"));
614TEST(IsReadableTypeNameTest, ReturnsTrueForLongNonTemplateNonFunctionNames) {
615 EXPECT_TRUE(IsReadableTypeName(
"my_long_namespace::MyClassName"));
616 EXPECT_TRUE(IsReadableTypeName(
"int [5][6][7][8][9][10][11]"));
617 EXPECT_TRUE(IsReadableTypeName(
"my_namespace::MyOuterClass::MyInnerClass"));
620TEST(IsReadableTypeNameTest, ReturnsFalseForLongTemplateNames) {
622 IsReadableTypeName(
"basic_string<char, std::char_traits<char> >"));
623 EXPECT_FALSE(IsReadableTypeName(
"std::vector<int, std::alloc_traits<int> >"));
626TEST(IsReadableTypeNameTest, ReturnsFalseForLongFunctionTypeNames) {
627 EXPECT_FALSE(IsReadableTypeName(
"void (&)(int, bool, char, float)"));
632TEST(FormatMatcherDescriptionTest, WorksForEmptyDescription) {
634 FormatMatcherDescription(
false,
"IsEven", {}, Strings()));
636 FormatMatcherDescription(
true,
"IsEven", {}, Strings()));
639 FormatMatcherDescription(
false,
"Equals", {
"a"}, {
"5"}));
642 "is in range (a: 5, b: 8)",
643 FormatMatcherDescription(
false,
"IsInRange", {
"a",
"b"}, {
"5",
"8"}));
648TEST_P(MatcherTupleTestP, ExplainsMatchFailure) {
650 ExplainMatchFailureTupleTo(
651 std::make_tuple(Matcher<char>(Eq(
'a')), GreaterThan(5)),
652 std::make_tuple(
'a', 10), &ss1);
656 ExplainMatchFailureTupleTo(
657 std::make_tuple(GreaterThan(5), Matcher<char>(Eq(
'a'))),
658 std::make_tuple(2,
'b'), &ss2);
660 " Expected arg #0: is > 5\n"
661 " Actual: 2, which is 3 less than 5\n"
662 " Expected arg #1: is equal to 'a' (97, 0x61)\n"
663 " Actual: 'b' (98, 0x62)\n",
667 ExplainMatchFailureTupleTo(
668 std::make_tuple(GreaterThan(5), Matcher<char>(Eq(
'a'))),
669 std::make_tuple(2,
'a'), &ss3);
671 " Expected arg #0: is > 5\n"
672 " Actual: 2, which is 3 less than 5\n",
680class SampleOptional {
682 using value_type =
T;
683 explicit SampleOptional(
T value)
684 : value_(
std::move(
value)), has_value_(true) {}
685 SampleOptional() : value_(), has_value_(false) {}
686 operator bool()
const {
return has_value_; }
687 const T& operator*()
const {
return value_; }
694TEST(OptionalTest, DescribesSelf) {
695 const Matcher<SampleOptional<int>> m = Optional(Eq(1));
699TEST(OptionalTest, ExplainsSelf) {
700 const Matcher<SampleOptional<int>> m = Optional(Eq(1));
702 EXPECT_EQ(
"whose value 2 doesn't match",
Explain(m, SampleOptional<int>(2)));
705TEST(OptionalTest, MatchesNonEmptyOptional) {
706 const Matcher<SampleOptional<int>> m1 = Optional(1);
707 const Matcher<SampleOptional<int>> m2 = Optional(Eq(2));
708 const Matcher<SampleOptional<int>> m3 = Optional(Lt(3));
709 SampleOptional<int> opt(1);
715TEST(OptionalTest, DoesNotMatchNullopt) {
716 const Matcher<SampleOptional<int>> m = Optional(1);
717 SampleOptional<int> empty;
721TEST(OptionalTest, WorksWithMoveOnly) {
722 Matcher<SampleOptional<std::unique_ptr<int>>> m = Optional(Eq(
nullptr));
723 EXPECT_TRUE(m.Matches(SampleOptional<std::unique_ptr<int>>(
nullptr)));
726class SampleVariantIntString {
728 SampleVariantIntString(
int i) : i_(
i), has_int_(true) {}
729 SampleVariantIntString(
const std::string& s) : s_(s), has_int_(false) {}
731 template <
typename T>
732 friend bool holds_alternative(
const SampleVariantIntString&
value) {
733 return value.has_int_ == std::is_same<T, int>::value;
736 template <
typename T>
737 friend const T& get(
const SampleVariantIntString&
value) {
738 return value.get_impl(
static_cast<T*
>(
nullptr));
742 const int& get_impl(
int*)
const {
return i_; }
743 const std::string& get_impl(std::string*)
const {
return s_; }
750TEST(VariantTest, DescribesSelf) {
751 const Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
753 "'.*' and the value is equal to 1"));
756TEST(VariantTest, ExplainsSelf) {
757 const Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
759 ContainsRegex(
"whose value 1"));
761 HasSubstr(
"whose value is not of type '"));
763 "whose value 2 doesn't match");
766TEST(VariantTest, FullMatch) {
767 Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
770 m = VariantWith<std::string>(Eq(
"1"));
771 EXPECT_TRUE(m.Matches(SampleVariantIntString(
"1")));
774TEST(VariantTest, TypeDoesNotMatch) {
775 Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
778 m = VariantWith<std::string>(Eq(
"1"));
782TEST(VariantTest, InnerDoesNotMatch) {
783 Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
786 m = VariantWith<std::string>(Eq(
"1"));
792 explicit SampleAnyType(
int i) : index_(0), i_(
i) {}
793 explicit SampleAnyType(
const std::string& s) : index_(1), s_(s) {}
795 template <
typename T>
796 friend const T* any_cast(
const SampleAnyType* any) {
797 return any->get_impl(
static_cast<T*
>(
nullptr));
805 const int* get_impl(
int*)
const {
return index_ == 0 ? &i_ :
nullptr; }
806 const std::string* get_impl(std::string*)
const {
807 return index_ == 1 ? &s_ :
nullptr;
811TEST(AnyWithTest, FullMatch) {
812 Matcher<SampleAnyType> m = AnyWith<int>(Eq(1));
816TEST(AnyWithTest, TestBadCastType) {
817 Matcher<SampleAnyType> m = AnyWith<std::string>(Eq(
"fail"));
821TEST(AnyWithTest, TestUseInContainers) {
822 std::vector<SampleAnyType> a;
827 a, ElementsAreArray({AnyWith<int>(1), AnyWith<int>(2), AnyWith<int>(3)}));
829 std::vector<SampleAnyType> b;
830 b.emplace_back(
"hello");
831 b.emplace_back(
"merhaba");
832 b.emplace_back(
"salut");
833 EXPECT_THAT(b, ElementsAreArray({AnyWith<std::string>(
"hello"),
834 AnyWith<std::string>(
"merhaba"),
835 AnyWith<std::string>(
"salut")}));
837TEST(AnyWithTest, TestCompare) {
838 EXPECT_THAT(SampleAnyType(1), AnyWith<int>(Gt(0)));
841TEST(AnyWithTest, DescribesSelf) {
842 const Matcher<const SampleAnyType&> m = AnyWith<int>(Eq(1));
844 "'.*' and the value is equal to 1"));
847TEST(AnyWithTest, ExplainsSelf) {
848 const Matcher<const SampleAnyType&> m = AnyWith<int>(Eq(1));
852 HasSubstr(
"whose value is not of type '"));
858TEST(ArgsTest, AcceptsZeroTemplateArg) {
859 const std::tuple<int, bool> t(5,
true);
864TEST(ArgsTest, AcceptsOneTemplateArg) {
865 const std::tuple<int, bool> t(5,
true);
867 EXPECT_THAT(t, Args<1>(Eq(std::make_tuple(
true))));
868 EXPECT_THAT(t, Not(Args<1>(Eq(std::make_tuple(
false)))));
871TEST(ArgsTest, AcceptsTwoTemplateArgs) {
872 const std::tuple<short, int, long> t(
short{4}, 5, 6L);
879TEST(ArgsTest, AcceptsRepeatedTemplateArgs) {
880 const std::tuple<short, int, long> t(
short{4}, 5, 6L);
885TEST(ArgsTest, AcceptsDecreasingTemplateArgs) {
886 const std::tuple<short, int, long> t(
short{4}, 5, 6L);
892 return std::get<0>(arg) + std::get<1>(arg) + std::get<2>(arg) == 0;
895TEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) {
896 EXPECT_THAT(std::make_tuple(-1, 2), (Args<0, 0, 1>(SumIsZero())));
897 EXPECT_THAT(std::make_tuple(1, 2), Not(Args<0, 0, 1>(SumIsZero())));
900TEST(ArgsTest, CanBeNested) {
901 const std::tuple<short, int, long, int> t(
short{4}, 5, 6L, 6);
906TEST(ArgsTest, CanMatchTupleByValue) {
907 typedef std::tuple<char, int, int> Tuple3;
908 const Matcher<Tuple3> m = Args<1, 2>(Lt());
913TEST(ArgsTest, CanMatchTupleByReference) {
914 typedef std::tuple<char, char, int> Tuple3;
915 const Matcher<const Tuple3&> m = Args<0, 1>(Lt());
923TEST(ArgsTest, AcceptsTenTemplateArgs) {
924 EXPECT_THAT(std::make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),
925 (Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>(
926 PrintsAs(
"(9, 8, 7, 6, 5, 4, 3, 2, 1, 0)"))));
927 EXPECT_THAT(std::make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),
928 Not(Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>(
929 PrintsAs(
"(0, 8, 7, 6, 5, 4, 3, 2, 1, 0)"))));
932TEST(ArgsTest, DescirbesSelfCorrectly) {
933 const Matcher<std::tuple<int, bool, char>> m = Args<2, 0>(Lt());
935 "are a tuple whose fields (#2, #0) are a pair where "
936 "the first < the second",
940TEST(ArgsTest, DescirbesNestedArgsCorrectly) {
941 const Matcher<const std::tuple<int, bool, char, int>&> m =
942 Args<0, 2, 3>(Args<2, 0>(Lt()));
944 "are a tuple whose fields (#0, #2, #3) are a tuple "
945 "whose fields (#2, #0) are a pair where the first < the second",
949TEST(ArgsTest, DescribesNegationCorrectly) {
950 const Matcher<std::tuple<int, char>> m = Args<1, 0>(Gt());
952 "are a tuple whose fields (#1, #0) aren't a pair "
953 "where the first > the second",
957TEST(ArgsTest, ExplainsMatchResultWithoutInnerExplanation) {
958 const Matcher<std::tuple<bool, int, int>> m = Args<1, 2>(Eq());
959 EXPECT_EQ(
"whose fields (#1, #2) are (42, 42)",
960 Explain(m, std::make_tuple(
false, 42, 42)));
961 EXPECT_EQ(
"whose fields (#1, #2) are (42, 43)",
962 Explain(m, std::make_tuple(
false, 42, 43)));
966class LessThanMatcher :
public MatcherInterface<std::tuple<char, int>> {
968 void DescribeTo(::std::ostream* )
const override {}
970 bool MatchAndExplain(std::tuple<char, int>
value,
971 MatchResultListener* listener)
const override {
972 const int diff = std::get<0>(
value) - std::get<1>(
value);
974 *listener <<
"where the first value is " << diff
975 <<
" more than the second";
981Matcher<std::tuple<char, int>> LessThan() {
982 return MakeMatcher(
new LessThanMatcher);
985TEST(ArgsTest, ExplainsMatchResultWithInnerExplanation) {
986 const Matcher<std::tuple<char, int, int>> m = Args<0, 2>(LessThan());
988 "whose fields (#0, #2) are ('a' (97, 0x61), 42), "
989 "where the first value is 55 more than the second",
990 Explain(m, std::make_tuple(
'a', 42, 42)));
991 EXPECT_EQ(
"whose fields (#0, #2) are ('\\0', 43)",
992 Explain(m, std::make_tuple(
'\0', 42, 43)));
999MATCHER(IsEven,
"") {
return (arg % 2) == 0; }
1001TEST(MatcherMacroTest, Works) {
1002 const Matcher<int> m = IsEven();
1013MATCHER(IsEven2, negation ?
"is odd" :
"is even") {
1014 if ((arg % 2) == 0) {
1017 *result_listener <<
"OK";
1020 *result_listener <<
"% 2 == " << (arg % 2);
1028 std::string(negation ?
"doesn't equal" :
"equals") +
" the sum of " +
1030 if (arg == (
x +
y)) {
1031 *result_listener <<
"OK";
1036 if (result_listener->stream() !=
nullptr) {
1037 *result_listener->stream() <<
"diff == " << (
x +
y - arg);
1045TEST(MatcherMacroTest, DescriptionCanReferenceNegationAndParameters) {
1046 const Matcher<int> m1 = IsEven2();
1050 const Matcher<int> m2 = EqSumOf(5, 9);
1056TEST(MatcherMacroTest, CanExplainMatchResult) {
1057 const Matcher<int> m1 = IsEven2();
1061 const Matcher<int> m2 = EqSumOf(1, 2);
1074MATCHER(IsEmptyStringByRef,
"") {
1079TEST(MatcherMacroTest, CanReferenceArgType) {
1080 const Matcher<::std::string> m1 = IsEmptyString();
1083 const Matcher<const ::std::string&> m2 = IsEmptyStringByRef();
1089namespace matcher_test {
1090MATCHER(IsOdd,
"") {
return (arg % 2) != 0; }
1093TEST(MatcherMacroTest, WorksInNamespace) {
1101 return Value(arg, matcher_test::IsOdd()) && arg > 0;
1104TEST(MatcherMacroTest, CanBeComposedUsingValue) {
1112MATCHER_P(IsGreaterThan32And, n,
"") {
return arg > 32 && arg > n; }
1114TEST(MatcherPMacroTest, Works) {
1115 const Matcher<int> m = IsGreaterThan32And(5);
1126MATCHER_P(_is_Greater_Than32and_, n,
"") {
return arg > 32 && arg > n; }
1128TEST(MatcherPMacroTest, GeneratesCorrectDescription) {
1129 const Matcher<int> m = _is_Greater_Than32and_(5);
1140class UncopyableFoo {
1142 explicit UncopyableFoo(
char value) : value_(
value) { (void)value_; }
1144 UncopyableFoo(
const UncopyableFoo&) =
delete;
1145 void operator=(
const UncopyableFoo&) =
delete;
1151MATCHER_P(ReferencesUncopyable, variable,
"") {
return &arg == &variable; }
1153TEST(MatcherPMacroTest, WorksWhenExplicitlyInstantiatedWithReference) {
1154 UncopyableFoo foo1(
'1'), foo2(
'2');
1155 const Matcher<const UncopyableFoo&> m =
1156 ReferencesUncopyable<const UncopyableFoo&>(foo1);
1165 EXPECT_EQ(
"references uncopyable (variable: 1-byte object <31>)",
1179TEST(MatcherPnMacroTest, CanReferenceParamTypes) {
1180 EXPECT_THAT(0, ParamTypesAreIntLongAndChar(10, 20L,
'a'));
1186MATCHER_P2(ReferencesAnyOf, variable1, variable2,
"") {
1187 return &arg == &variable1 || &arg == &variable2;
1190TEST(MatcherPnMacroTest, WorksWhenExplicitlyInstantiatedWithReferences) {
1191 UncopyableFoo foo1(
'1'), foo2(
'2'), foo3(
'3');
1192 const Matcher<const UncopyableFoo&> const_m =
1193 ReferencesAnyOf<const UncopyableFoo&, const UncopyableFoo&>(foo1, foo2);
1199 const Matcher<UncopyableFoo&> m =
1200 ReferencesAnyOf<UncopyableFoo&, UncopyableFoo&>(foo1, foo2);
1207TEST(MatcherPnMacroTest,
1208 GeneratesCorretDescriptionWhenExplicitlyInstantiatedWithReferences) {
1209 UncopyableFoo foo1(
'1'), foo2(
'2');
1210 const Matcher<const UncopyableFoo&> m =
1211 ReferencesAnyOf<const UncopyableFoo&, const UncopyableFoo&>(foo1, foo2);
1218 "references any of (variable1: 1-byte object <31>, variable2: 1-byte "
1225MATCHER_P2(IsNotInClosedRange, low, hi,
"") {
return arg < low || arg > hi; }
1227TEST(MatcherPnMacroTest, Works) {
1228 const Matcher<const long&> m = IsNotInClosedRange(10, 20);
1233 EXPECT_EQ(
"not (is not in closed range (low: 10, hi: 20))",
1242MATCHER(EqualsSumOf,
"") {
return arg == 0; }
1243MATCHER_P(EqualsSumOf, a,
"") {
return arg == a; }
1244MATCHER_P2(EqualsSumOf, a, b,
"") {
return arg == a + b; }
1245MATCHER_P3(EqualsSumOf, a, b, c,
"") {
return arg == a + b + c; }
1246MATCHER_P4(EqualsSumOf, a, b, c, d,
"") {
return arg == a + b + c + d; }
1247MATCHER_P5(EqualsSumOf, a, b, c, d, e,
"") {
return arg == a + b + c + d + e; }
1248MATCHER_P6(EqualsSumOf, a, b, c, d, e, f,
"") {
1249 return arg == a + b + c + d + e + f;
1251MATCHER_P7(EqualsSumOf, a, b, c, d, e, f, g,
"") {
1252 return arg == a + b + c + d + e + f + g;
1254MATCHER_P8(EqualsSumOf, a, b, c, d, e, f, g, h,
"") {
1255 return arg == a + b + c + d + e + f + g + h;
1257MATCHER_P9(EqualsSumOf, a, b, c, d, e, f, g, h,
i,
"") {
1258 return arg == a + b + c + d + e + f + g + h +
i;
1260MATCHER_P10(EqualsSumOf, a, b, c, d, e, f, g, h,
i, j,
"") {
1261 return arg == a + b + c + d + e + f + g + h +
i + j;
1264TEST(MatcherPnMacroTest, CanBeOverloadedOnNumberOfParameters) {
1270 EXPECT_THAT(12345, EqualsSumOf(10000, 2000, 300, 40, 5));
1272 EqualsSumOf(::std::string(
"a"),
'b',
'c',
"d",
"e",
'f'));
1274 EqualsSumOf(::std::string(
"a"),
'b',
'c',
"d",
"e",
'f',
'g'));
1275 EXPECT_THAT(
"abcdefgh", EqualsSumOf(::std::string(
"a"),
'b',
'c',
"d",
"e",
1277 EXPECT_THAT(
"abcdefghi", EqualsSumOf(::std::string(
"a"),
'b',
'c',
"d",
"e",
1278 'f',
'g',
"h",
'i'));
1280 EqualsSumOf(::std::string(
"a"),
'b',
'c',
"d",
"e",
'f',
'g',
"h",
1281 'i', ::std::string(
"j")));
1287 EXPECT_THAT(-1234, Not(EqualsSumOf(1000, 200, 30, 4)));
1288 EXPECT_THAT(-12345, Not(EqualsSumOf(10000, 2000, 300, 40, 5)));
1290 Not(EqualsSumOf(::std::string(
"a"),
'b',
'c',
"d",
"e",
'f')));
1291 EXPECT_THAT(
"abcdefg ", Not(EqualsSumOf(::std::string(
"a"),
'b',
'c',
"d",
1293 EXPECT_THAT(
"abcdefgh ", Not(EqualsSumOf(::std::string(
"a"),
'b',
'c',
"d",
1294 "e",
'f',
'g',
"h")));
1295 EXPECT_THAT(
"abcdefghi ", Not(EqualsSumOf(::std::string(
"a"),
'b',
'c',
"d",
1296 "e",
'f',
'g',
"h",
'i')));
1298 Not(EqualsSumOf(::std::string(
"a"),
'b',
'c',
"d",
"e",
'f',
'g',
1299 "h",
'i', ::std::string(
"j"))));
1304TEST(MatcherPnMacroTest, WorksForDifferentParameterTypes) {
1305 EXPECT_THAT(123, EqualsSumOf(100L, 20,
static_cast<char>(3)));
1306 EXPECT_THAT(
"abcd", EqualsSumOf(::std::string(
"a"),
"b",
'c',
"d"));
1308 EXPECT_THAT(124, Not(EqualsSumOf(100L, 20,
static_cast<char>(3))));
1309 EXPECT_THAT(
"abcde", Not(EqualsSumOf(::std::string(
"a"),
"b",
'c',
"d")));
1316 std::string prefix_str(prefix);
1317 char suffix_char =
static_cast<char>(suffix);
1318 return arg == prefix_str + suffix_char;
1321TEST(MatcherPnMacroTest, SimpleTypePromotion) {
1322 Matcher<std::string> no_promo = EqConcat(std::string(
"foo"),
't');
1323 Matcher<const std::string&> promo = EqConcat(
"foo",
static_cast<int>(
't'));
1332TEST(MatcherPnMacroTest, TypesAreCorrect) {
1334 EqualsSumOfMatcher a0 = EqualsSumOf();
1337 EqualsSumOfMatcherP<int> a1 = EqualsSumOf(1);
1341 EqualsSumOfMatcherP2<int, char> a2 = EqualsSumOf(1,
'2');
1342 EqualsSumOfMatcherP3<int, int, char> a3 = EqualsSumOf(1, 2,
'3');
1343 EqualsSumOfMatcherP4<int, int, int, char> a4 = EqualsSumOf(1, 2, 3,
'4');
1344 EqualsSumOfMatcherP5<int, int, int, int, char> a5 =
1345 EqualsSumOf(1, 2, 3, 4,
'5');
1346 EqualsSumOfMatcherP6<int, int, int, int, int, char> a6 =
1347 EqualsSumOf(1, 2, 3, 4, 5,
'6');
1348 EqualsSumOfMatcherP7<int, int, int, int, int, int, char> a7 =
1349 EqualsSumOf(1, 2, 3, 4, 5, 6,
'7');
1350 EqualsSumOfMatcherP8<int, int, int, int, int, int, int, char> a8 =
1351 EqualsSumOf(1, 2, 3, 4, 5, 6, 7,
'8');
1352 EqualsSumOfMatcherP9<int, int, int, int, int, int, int, int, char> a9 =
1353 EqualsSumOf(1, 2, 3, 4, 5, 6, 7, 8,
'9');
1354 EqualsSumOfMatcherP10<int, int, int, int, int, int, int, int, int, char> a10 =
1355 EqualsSumOf(1, 2, 3, 4, 5, 6, 7, 8, 9,
'0');
1376 const int count =
static_cast<int>(Value(arg, m1)) +
1377 static_cast<int>(Value(arg, m2)) +
1378 static_cast<int>(Value(arg, m3));
1382TEST(MatcherPnMacroTest, CanUseMatcherTypedParameterInValue) {
1391TEST(ContainsTimes, ListMatchesWhenElementQuantityMatches) {
1392 list<int> some_list;
1393 some_list.push_back(3);
1394 some_list.push_back(1);
1395 some_list.push_back(2);
1396 some_list.push_back(3);
1400 EXPECT_THAT(some_list, Contains(Ge(2)).Times(Gt(2)));
1403 EXPECT_THAT(some_list, Not(Contains(5).Times(1)));
1405 EXPECT_THAT(some_list, Not(Contains(3).Times(1)));
1406 EXPECT_THAT(some_list, Contains(3).Times(Not(1)));
1410TEST_P(ContainsTimesP, ExplainsMatchResultCorrectly) {
1411 const int a[2] = {1, 2};
1412 Matcher<
const int(&)[2]> m = Contains(2).Times(3);
1414 "whose element #1 matches but whose match quantity of 1 does not match",
1417 m = Contains(3).Times(0);
1418 EXPECT_EQ(
"has no element that matches and whose match quantity of 0 matches",
1421 m = Contains(3).Times(4);
1423 "has no element that matches and whose match quantity of 0 does not "
1427 m = Contains(2).Times(4);
1429 "whose element #1 matches but whose match quantity of 1 does not "
1433 m = Contains(GreaterThan(0)).Times(2);
1434 EXPECT_EQ(
"whose elements (0, 1) match and whose match quantity of 2 matches",
1437 m = Contains(GreaterThan(10)).Times(Gt(1));
1439 "has no element that matches and whose match quantity of 0 does not "
1443 m = Contains(GreaterThan(0)).Times(GreaterThan<size_t>(5));
1445 "whose elements (0, 1) match but whose match quantity of 2 does not "
1446 "match, which is 3 less than 5",
1450TEST(ContainsTimes, DescribesItselfCorrectly) {
1451 Matcher<vector<int>> m = Contains(1).Times(2);
1452 EXPECT_EQ(
"quantity of elements that match is equal to 1 is equal to 2",
1455 Matcher<vector<int>> m2 = Not(m);
1456 EXPECT_EQ(
"quantity of elements that match is equal to 1 isn't equal to 2",
1462TEST(AllOfArrayTest, BasicForms) {
1464 std::vector<int> v0{};
1465 std::vector<int> v1{1};
1466 std::vector<int> v2{2, 3};
1467 std::vector<int> v3{4, 4, 4};
1470 EXPECT_THAT(2, Not(AllOfArray(v1.begin(), v1.end())));
1471 EXPECT_THAT(3, Not(AllOfArray(v2.begin(), v2.end())));
1474 int ar[6] = {1, 2, 3, 4, 4, 4};
1483 int ar2[2] = {2, 3};
1484 int ar3[3] = {4, 4, 4};
1504TEST(AllOfArrayTest, Matchers) {
1506 std::vector<Matcher<int>> matchers{Ge(1), Lt(2)};
1517TEST(AnyOfArrayTest, BasicForms) {
1519 std::vector<int> v0{};
1520 std::vector<int> v1{1};
1521 std::vector<int> v2{2, 3};
1522 EXPECT_THAT(0, Not(AnyOfArray(v0.begin(), v0.end())));
1524 EXPECT_THAT(2, Not(AnyOfArray(v1.begin(), v1.end())));
1526 EXPECT_THAT(4, Not(AnyOfArray(v2.begin(), v2.end())));
1528 int ar[3] = {1, 2, 3};
1537 int ar2[2] = {2, 3};
1557TEST(AnyOfArrayTest, Matchers) {
1560 std::vector<Matcher<int>> matchers{Lt(1), Ge(2)};
1569TEST_P(AnyOfArrayTestP, ExplainsMatchResultCorrectly) {
1572 const std::vector<int> v0{};
1573 const std::vector<int> v1{1};
1574 const std::vector<int> v2{2, 3};
1575 const Matcher<int> m0 = AnyOfArray(v0);
1576 const Matcher<int> m1 = AnyOfArray(v1);
1577 const Matcher<int> m2 = AnyOfArray(v2);
1590 const Matcher<int> g1 = AnyOfArray({GreaterThan(1)});
1591 const Matcher<int> g2 = AnyOfArray({GreaterThan(1), GreaterThan(2)});
1596 EXPECT_EQ(
"which is 1 less than 1, and which is 2 less than 2",
1598 EXPECT_EQ(
"which is the same as 1, and which is 1 less than 2",
1604MATCHER(IsNotNull,
"") {
return arg !=
nullptr; }
1608TEST(MatcherMacroTest, WorksOnMoveOnlyType) {
1609 std::unique_ptr<int>
p(
new int(3));
1611 EXPECT_THAT(std::unique_ptr<int>(), Not(IsNotNull()));
1614MATCHER_P(UniquePointee, pointee,
"") {
return *arg == pointee; }
1618TEST(MatcherPMacroTest, WorksOnMoveOnlyType) {
1619 std::unique_ptr<int>
p(
new int(3));
1624MATCHER(EnsureNoUnusedButMarkedUnusedWarning,
"") {
return (arg % 2) == 0; }
1626TEST(MockMethodMockFunctionTest, EnsureNoUnusedButMarkedUnusedWarning) {
1628#pragma clang diagnostic push
1629#pragma clang diagnostic error "-Wused-but-marked-unused"
1632 EXPECT_THAT(0, EnsureNoUnusedButMarkedUnusedWarning());
1634#pragma clang diagnostic pop
1638#if GTEST_HAS_EXCEPTIONS
1644TEST(ThrowsTest, Examples) {
1646 std::function<
void()>([]() {
throw std::runtime_error(
"message"); }),
1647 Throws<std::runtime_error>());
1650 std::function<
void()>([]() {
throw std::runtime_error(
"message"); }),
1651 ThrowsMessage<std::runtime_error>(HasSubstr(
"message")));
1654TEST(ThrowsTest, PrintsExceptionWhat) {
1656 std::function<
void()>([]() {
throw std::runtime_error(
"ABC123XYZ"); }),
1657 ThrowsMessage<std::runtime_error>(HasSubstr(
"ABC123XYZ")));
1660TEST(ThrowsTest, DoesNotGenerateDuplicateCatchClauseWarning) {
1661 EXPECT_THAT(std::function<
void()>([]() {
throw std::exception(); }),
1662 Throws<std::exception>());
1665TEST(ThrowsTest, CallableExecutedExactlyOnce) {
1677 throw std::runtime_error(
"message");
1679 Throws<std::runtime_error>());
1684 throw std::runtime_error(
"message");
1686 ThrowsMessage<std::runtime_error>(HasSubstr(
"message")));
1691 throw std::runtime_error(
"message");
1693 Throws<std::runtime_error>(
1694 Property(&std::runtime_error::what, HasSubstr(
"message"))));
1699 Matcher<std::function<void()>> matcher = Throws<std::runtime_error>();
1700 std::stringstream ss;
1701 matcher.DescribeTo(&ss);
1702 auto explanation = ss.str();
1703 EXPECT_THAT(explanation, HasSubstr(
"std::runtime_error"));
1706TEST(ThrowsTest, Success) {
1707 Matcher<std::function<void()>> matcher = Throws<std::runtime_error>();
1708 StringMatchResultListener listener;
1710 []() { throw std::runtime_error(
"error message"); }, &listener));
1711 EXPECT_THAT(listener.str(), HasSubstr(
"std::runtime_error"));
1714TEST(ThrowsTest, FailWrongType) {
1715 Matcher<std::function<void()>> matcher = Throws<std::runtime_error>();
1716 StringMatchResultListener listener;
1718 []() { throw std::logic_error(
"error message"); }, &listener));
1719 EXPECT_THAT(listener.str(), HasSubstr(
"std::logic_error"));
1720 EXPECT_THAT(listener.str(), HasSubstr(
"\"error message\""));
1723TEST(ThrowsTest, FailWrongTypeNonStd) {
1724 Matcher<std::function<void()>> matcher = Throws<std::runtime_error>();
1725 StringMatchResultListener listener;
1726 EXPECT_FALSE(matcher.MatchAndExplain([]() { throw 10; }, &listener));
1728 HasSubstr(
"throws an exception of an unknown type"));
1731TEST(ThrowsTest, FailNoThrow) {
1732 Matcher<std::function<void()>> matcher = Throws<std::runtime_error>();
1733 StringMatchResultListener listener;
1734 EXPECT_FALSE(matcher.MatchAndExplain([]() { (void)0; }, &listener));
1735 EXPECT_THAT(listener.str(), HasSubstr(
"does not throw any exception"));
1738class ThrowsPredicateTest
1739 :
public TestWithParam<Matcher<std::function<void()>>> {};
1742 Matcher<std::function<void()>> matcher = GetParam();
1743 std::stringstream ss;
1744 matcher.DescribeTo(&ss);
1745 auto explanation = ss.str();
1746 EXPECT_THAT(explanation, HasSubstr(
"std::runtime_error"));
1747 EXPECT_THAT(explanation, HasSubstr(
"error message"));
1750TEST_P(ThrowsPredicateTest, Success) {
1751 Matcher<std::function<void()>> matcher = GetParam();
1752 StringMatchResultListener listener;
1754 []() { throw std::runtime_error(
"error message"); }, &listener));
1755 EXPECT_THAT(listener.str(), HasSubstr(
"std::runtime_error"));
1758TEST_P(ThrowsPredicateTest, FailWrongType) {
1759 Matcher<std::function<void()>> matcher = GetParam();
1760 StringMatchResultListener listener;
1762 []() { throw std::logic_error(
"error message"); }, &listener));
1763 EXPECT_THAT(listener.str(), HasSubstr(
"std::logic_error"));
1764 EXPECT_THAT(listener.str(), HasSubstr(
"\"error message\""));
1767TEST_P(ThrowsPredicateTest, FailWrongTypeNonStd) {
1768 Matcher<std::function<void()>> matcher = GetParam();
1769 StringMatchResultListener listener;
1770 EXPECT_FALSE(matcher.MatchAndExplain([]() { throw 10; }, &listener));
1772 HasSubstr(
"throws an exception of an unknown type"));
1775TEST_P(ThrowsPredicateTest, FailNoThrow) {
1776 Matcher<std::function<void()>> matcher = GetParam();
1777 StringMatchResultListener listener;
1778 EXPECT_FALSE(matcher.MatchAndExplain([]() {}, &listener));
1779 EXPECT_THAT(listener.str(), HasSubstr(
"does not throw any exception"));
1783 AllMessagePredicates, ThrowsPredicateTest,
1784 Values(Matcher<std::function<
void()>>(
1785 ThrowsMessage<std::runtime_error>(HasSubstr(
"error message")))));
1788TEST(ThrowsPredicateCompilesTest, ExceptionMatcherAcceptsBroadType) {
1790 Matcher<std::function<void()>> matcher =
1791 ThrowsMessage<std::runtime_error>(HasSubstr(
"error message"));
1793 matcher.Matches([]() { throw std::runtime_error(
"error message"); }));
1795 matcher.Matches([]() { throw std::runtime_error(
"wrong message"); }));
1799 Matcher<uint64_t> inner = Eq(10);
1800 Matcher<std::function<void()>> matcher = Throws<uint32_t>(inner);
1801 EXPECT_TRUE(matcher.Matches([]() { throw (uint32_t)10; }));
1802 EXPECT_FALSE(matcher.Matches([]() { throw (uint32_t)11; }));
1808TEST(ThrowsPredicateCompilesTest, MessageMatcherAcceptsNonMatcher) {
1809 Matcher<std::function<void()>> matcher =
1810 ThrowsMessage<std::runtime_error>(
"error message");
1812 matcher.Matches([]() { throw std::runtime_error(
"error message"); }));
1814 []() { throw std::runtime_error(
"wrong error message"); }));
Definition gmock-internal-utils.h:55
pRC::Float<> T
Definition externs_nonTT.hpp:1
int value
Definition gmock-actions_test.cc:1714
int i
Definition gmock-matchers-comparisons_test.cc:603
const double y
Definition gmock-matchers-containers_test.cc:377
int x
Definition gmock-matchers-containers_test.cc:376
const char * p
Definition gmock-matchers-containers_test.cc:379
#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)
#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)
#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)
#define MATCHER_P3(name, p0, p1, p2, description)
#define MATCHER_P4(name, p0, p1, p2, p3, description)
#define MATCHER_P2(name, p0, p1, description)
#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)
#define EXPECT_THAT(value, matcher)
#define MATCHER_P(name, p0, description)
#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)
#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)
#define MATCHER(name, description)
#define INSTANTIATE_GTEST_MATCHER_TEST_P(TestSuite)
Definition gmock-matchers_test.h:151
#define EXPECT_CALL(obj, call)
Definition gmock-spec-builders.h:2145
int * count
Definition gmock_stress_test.cc:90
#define TEST_P(test_suite_name, test_name)
Definition gtest-param-test.h:450
#define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name,...)
Definition gtest-param-test.h:496
#define GTEST_FLAG_PREFIX_
Definition gtest-port.h:331
#define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
Definition gtest-port.h:360
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
Definition gtest-port.h:361
#define GTEST_FLAG_GET(name)
Definition gtest-port.h:2293
#define TYPED_TEST(CaseName, TestName)
Definition gtest-typed-test.h:197
#define TYPED_TEST_SUITE(CaseName, Types,...)
Definition gtest-typed-test.h:191
#define TEST_F(test_fixture, test_name)
Definition gtest.h:2208
#define EXPECT_EQ(val1, val2)
Definition gtest.h:1868
#define SCOPED_TRACE(message)
Definition gtest.h:2104
#define TEST(test_suite_name, test_name)
Definition gtest.h:2176
#define EXPECT_TRUE(condition)
Definition gtest.h:1807
#define EXPECT_FALSE(condition)
Definition gtest.h:1811
Definition googletest-output-test_.cc:485
Definition googletest-output-test_.cc:471
constexpr auto operator==(GaussianDistribution< T > const &lhs, GaussianDistribution< T > const &rhs)
Definition gaussian.hpp:96
std::string Explain(const MatcherType &m, const Value &x)
Definition gmock-matchers_test.h:183
std::string Describe(const Matcher< T > &m)
Definition gmock-matchers_test.h:171
std::string DescribeNegation(const Matcher< T > &m)
Definition gmock-matchers_test.h:177
GTEST_API_ bool IsTrue(bool condition)
Definition gtest.cc:6310
GTEST_API_ ElementMatcherPairs FindMaxBipartiteMatching(const MatchMatrix &g)
Definition gmock-matchers.cc:228
Definition gmock-actions.h:151
inline ::std::reference_wrapper< T > ByRef(T &l_value)
Definition gmock-actions.h:1994
internal::ParamGenerator< T > Range(T start, T end, IncrementT step)
Definition gtest-param-test.h:229
constexpr bool StaticAssertTypeEq() noexcept
Definition gtest.h:2139
::std::string PrintToString(const T &value)
Definition gtest-printers.h:1148
PolymorphicMatcher< internal::IsEmptyMatcher > IsEmpty()
Definition gmock-more-matchers.h:93
internal::ValueArray< T... > Values(T... v)
Definition gtest-param-test.h:335
Definition gtest-type-util.h:190