@@ -65,6 +65,8 @@ TEST(ContainsTest, WorksWithMoveOnly) {
65
65
helper.Call (MakeUniquePtrs ({1 , 2 }));
66
66
}
67
67
68
+ INSTANTIATE_GTEST_MATCHER_TEST_P (ElementsAreTest);
69
+
68
70
// Tests the variadic version of the ElementsAreMatcher
69
71
TEST (ElementsAreTest, HugeMatcher) {
70
72
vector<int > test_vector{1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 };
@@ -280,6 +282,8 @@ class ConstPropagatingPtr {
280
282
T* val_;
281
283
};
282
284
285
+ INSTANTIATE_GTEST_MATCHER_TEST_P (PointeeTest);
286
+
283
287
TEST (PointeeTest, WorksWithConstPropagatingPointers) {
284
288
const Matcher<ConstPropagatingPtr<int >> m = Pointee (Lt (5 ));
285
289
int three = 3 ;
@@ -314,7 +318,7 @@ TEST(PointeeTest, CanDescribeSelf) {
314
318
EXPECT_EQ (" does not point to a value that is > 3" , DescribeNegation (m));
315
319
}
316
320
317
- TEST (PointeeTest , CanExplainMatchResult) {
321
+ TEST_P (PointeeTestP , CanExplainMatchResult) {
318
322
const Matcher<const std::string*> m = Pointee (StartsWith (" Hi" ));
319
323
320
324
EXPECT_EQ (" " , Explain (m, static_cast <const std::string*>(nullptr )));
@@ -370,6 +374,8 @@ struct DerivedStruct : public AStruct {
370
374
char ch;
371
375
};
372
376
377
+ INSTANTIATE_GTEST_MATCHER_TEST_P (FieldTest);
378
+
373
379
// Tests that Field(&Foo::field, ...) works when field is non-const.
374
380
TEST (FieldTest, WorksForNonConstField) {
375
381
Matcher<AStruct> m = Field (&AStruct::x, Ge (0 ));
@@ -476,7 +482,7 @@ TEST(FieldTest, CanDescribeSelfWithFieldName) {
476
482
}
477
483
478
484
// Tests that Field() can explain the match result.
479
- TEST (FieldTest , CanExplainMatchResult) {
485
+ TEST_P (FieldTestP , CanExplainMatchResult) {
480
486
Matcher<const AStruct&> m = Field (&AStruct::x, Ge (0 ));
481
487
482
488
AStruct a;
@@ -489,7 +495,7 @@ TEST(FieldTest, CanExplainMatchResult) {
489
495
Explain (m, a));
490
496
}
491
497
492
- TEST (FieldTest , CanExplainMatchResultWithFieldName) {
498
+ TEST_P (FieldTestP , CanExplainMatchResultWithFieldName) {
493
499
Matcher<const AStruct&> m = Field (" field_name" , &AStruct::x, Ge (0 ));
494
500
495
501
AStruct a;
@@ -502,6 +508,8 @@ TEST(FieldTest, CanExplainMatchResultWithFieldName) {
502
508
Explain (m, a));
503
509
}
504
510
511
+ INSTANTIATE_GTEST_MATCHER_TEST_P (FieldForPointerTest);
512
+
505
513
// Tests that Field() works when the argument is a pointer to const.
506
514
TEST (FieldForPointerTest, WorksForPointerToConst) {
507
515
Matcher<const AStruct*> m = Field (&AStruct::x, Ge (0 ));
@@ -568,7 +576,7 @@ TEST(FieldForPointerTest, CanDescribeSelfWithFieldName) {
568
576
}
569
577
570
578
// Tests that Field() can explain the result of matching a pointer.
571
- TEST (FieldForPointerTest , CanExplainMatchResult) {
579
+ TEST_P (FieldForPointerTestP , CanExplainMatchResult) {
572
580
Matcher<const AStruct*> m = Field (&AStruct::x, Ge (0 ));
573
581
574
582
AStruct a;
@@ -583,7 +591,7 @@ TEST(FieldForPointerTest, CanExplainMatchResult) {
583
591
Explain (m, &a));
584
592
}
585
593
586
- TEST (FieldForPointerTest , CanExplainMatchResultWithFieldName) {
594
+ TEST_P (FieldForPointerTestP , CanExplainMatchResultWithFieldName) {
587
595
Matcher<const AStruct*> m = Field (" field_name" , &AStruct::x, Ge (0 ));
588
596
589
597
AStruct a;
@@ -637,6 +645,8 @@ class DerivedClass : public AClass {
637
645
int k_;
638
646
};
639
647
648
+ INSTANTIATE_GTEST_MATCHER_TEST_P (PropertyTest);
649
+
640
650
// Tests that Property(&Foo::property, ...) works when property()
641
651
// returns a non-reference.
642
652
TEST (PropertyTest, WorksForNonReferenceProperty) {
@@ -763,7 +773,7 @@ TEST(PropertyTest, CanDescribeSelfWithPropertyName) {
763
773
}
764
774
765
775
// Tests that Property() can explain the match result.
766
- TEST (PropertyTest , CanExplainMatchResult) {
776
+ TEST_P (PropertyTestP , CanExplainMatchResult) {
767
777
Matcher<const AClass&> m = Property (&AClass::n, Ge (0 ));
768
778
769
779
AClass a;
@@ -776,7 +786,7 @@ TEST(PropertyTest, CanExplainMatchResult) {
776
786
Explain (m, a));
777
787
}
778
788
779
- TEST (PropertyTest , CanExplainMatchResultWithPropertyName) {
789
+ TEST_P (PropertyTestP , CanExplainMatchResultWithPropertyName) {
780
790
Matcher<const AClass&> m = Property (" fancy_name" , &AClass::n, Ge (0 ));
781
791
782
792
AClass a;
@@ -789,6 +799,8 @@ TEST(PropertyTest, CanExplainMatchResultWithPropertyName) {
789
799
Explain (m, a));
790
800
}
791
801
802
+ INSTANTIATE_GTEST_MATCHER_TEST_P (PropertyForPointerTest);
803
+
792
804
// Tests that Property() works when the argument is a pointer to const.
793
805
TEST (PropertyForPointerTest, WorksForPointerToConst) {
794
806
Matcher<const AClass*> m = Property (&AClass::n, Ge (0 ));
@@ -865,7 +877,7 @@ TEST(PropertyForPointerTest, CanDescribeSelfWithPropertyDescription) {
865
877
}
866
878
867
879
// Tests that Property() can explain the result of matching a pointer.
868
- TEST (PropertyForPointerTest , CanExplainMatchResult) {
880
+ TEST_P (PropertyForPointerTestP , CanExplainMatchResult) {
869
881
Matcher<const AClass*> m = Property (&AClass::n, Ge (0 ));
870
882
871
883
AClass a;
@@ -881,7 +893,7 @@ TEST(PropertyForPointerTest, CanExplainMatchResult) {
881
893
Explain (m, &a));
882
894
}
883
895
884
- TEST (PropertyForPointerTest , CanExplainMatchResultWithPropertyName) {
896
+ TEST_P (PropertyForPointerTestP , CanExplainMatchResultWithPropertyName) {
885
897
Matcher<const AClass*> m = Property (" fancy_name" , &AClass::n, Ge (0 ));
886
898
887
899
AClass a;
@@ -905,6 +917,8 @@ std::string IntToStringFunction(int input) {
905
917
return input == 1 ? " foo" : " bar" ;
906
918
}
907
919
920
+ INSTANTIATE_GTEST_MATCHER_TEST_P (ResultOfTest);
921
+
908
922
TEST (ResultOfTest, WorksForFunctionPointers) {
909
923
Matcher<int > matcher = ResultOf (&IntToStringFunction, Eq (std::string (" foo" )));
910
924
@@ -939,7 +953,7 @@ TEST(ResultOfTest, CanDescribeItselfWithResultDescription) {
939
953
// Tests that ResultOf() can explain the match result.
940
954
int IntFunction (int input) { return input == 42 ? 80 : 90 ; }
941
955
942
- TEST (ResultOfTest , CanExplainMatchResult) {
956
+ TEST_P (ResultOfTestP , CanExplainMatchResult) {
943
957
Matcher<int > matcher = ResultOf (&IntFunction, Ge (85 ));
944
958
EXPECT_EQ (" which is mapped by the given callable to 90" + OfType (" int" ),
945
959
Explain (matcher, 36 ));
@@ -950,7 +964,7 @@ TEST(ResultOfTest, CanExplainMatchResult) {
950
964
Explain (matcher, 36 ));
951
965
}
952
966
953
- TEST (ResultOfTest , CanExplainMatchResultWithResultDescription) {
967
+ TEST_P (ResultOfTestP , CanExplainMatchResultWithResultDescription) {
954
968
Matcher<int > matcher = ResultOf (" magic int conversion" , &IntFunction, Ge (85 ));
955
969
EXPECT_EQ (" whose magic int conversion is 90" + OfType (" int" ),
956
970
Explain (matcher, 36 ));
@@ -1408,6 +1422,8 @@ TEST(StreamlikeTest, Iteration) {
1408
1422
}
1409
1423
}
1410
1424
1425
+ INSTANTIATE_GTEST_MATCHER_TEST_P (BeginEndDistanceIsTest);
1426
+
1411
1427
TEST (BeginEndDistanceIsTest, WorksWithForwardList) {
1412
1428
std::forward_list<int > container;
1413
1429
EXPECT_THAT (container, BeginEndDistanceIs (0 ));
@@ -1439,7 +1455,7 @@ TEST(BeginEndDistanceIsTest, WorksWithMoveOnly) {
1439
1455
helper.Call (MakeUniquePtrs ({1 , 2 }));
1440
1456
}
1441
1457
1442
- TEST (BeginEndDistanceIsTest , ExplainsResult) {
1458
+ TEST_P (BeginEndDistanceIsTestP , ExplainsResult) {
1443
1459
Matcher<vector<int >> m1 = BeginEndDistanceIs (2 );
1444
1460
Matcher<vector<int >> m2 = BeginEndDistanceIs (Lt (2 ));
1445
1461
Matcher<vector<int >> m3 = BeginEndDistanceIs (AnyOf (0 , 3 ));
@@ -2103,7 +2119,9 @@ TEST_F(UnorderedElementsAreTest, DescribeNegation) {
2103
2119
2104
2120
// Tests Each().
2105
2121
2106
- TEST (EachTest, ExplainsMatchResultCorrectly) {
2122
+ INSTANTIATE_GTEST_MATCHER_TEST_P (EachTest);
2123
+
2124
+ TEST_P (EachTestP, ExplainsMatchResultCorrectly) {
2107
2125
set<int > a; // empty
2108
2126
2109
2127
Matcher<set<int >> m = Each (2 );
@@ -2594,7 +2612,7 @@ TEST(ElementsAreTest, DoesNotExplainTrivialMatch) {
2594
2612
EXPECT_EQ (" " , Explain (m, test_list)); // No need to explain anything.
2595
2613
}
2596
2614
2597
- TEST (ElementsAreTest , ExplainsNonTrivialMatch) {
2615
+ TEST_P (ElementsAreTestP , ExplainsNonTrivialMatch) {
2598
2616
Matcher<const vector<int >&> m =
2599
2617
ElementsAre (GreaterThan (1 ), 0 , GreaterThan (2 ));
2600
2618
@@ -2617,7 +2635,7 @@ TEST(ElementsAreTest, CanExplainMismatchWrongSize) {
2617
2635
EXPECT_EQ (" which has 1 element" , Explain (m, test_list));
2618
2636
}
2619
2637
2620
- TEST (ElementsAreTest , CanExplainMismatchRightSize) {
2638
+ TEST_P (ElementsAreTestP , CanExplainMismatchRightSize) {
2621
2639
Matcher<const vector<int >&> m = ElementsAre (1 , GreaterThan (5 ));
2622
2640
2623
2641
vector<int > v;
@@ -2970,6 +2988,8 @@ TEST(ElementsAreArrayTest, SourceLifeSpan) {
2970
2988
2971
2989
// Tests Contains().
2972
2990
2991
+ INSTANTIATE_GTEST_MATCHER_TEST_P (ContainsTest);
2992
+
2973
2993
TEST (ContainsTest, ListMatchesWhenElementIsInContainer) {
2974
2994
list<int > some_list;
2975
2995
some_list.push_back (3 );
@@ -3023,7 +3043,7 @@ TEST(ContainsTest, SetDoesNotMatchWhenElementIsNotInContainer) {
3023
3043
EXPECT_THAT (c_string_set, Not (Contains (std::string (" goodbye" ))));
3024
3044
}
3025
3045
3026
- TEST (ContainsTest , ExplainsMatchResultCorrectly) {
3046
+ TEST_P (ContainsTestP , ExplainsMatchResultCorrectly) {
3027
3047
const int a[2 ] = {1 , 2 };
3028
3048
Matcher<const int (&)[2 ]> m = Contains (2 );
3029
3049
EXPECT_EQ (" whose element #1 matches" , Explain (m, a));
0 commit comments