| OLD | NEW |
| 1 // Copyright 2007, Google Inc. | 1 // Copyright 2007, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 string FormatMatcherDescriptionSyntaxError(const char* description, | 53 string FormatMatcherDescriptionSyntaxError(const char* description, |
| 54 const char* error_pos); | 54 const char* error_pos); |
| 55 int GetParamIndex(const char* param_names[], const string& param_name); | 55 int GetParamIndex(const char* param_names[], const string& param_name); |
| 56 string JoinAsTuple(const Strings& fields); | 56 string JoinAsTuple(const Strings& fields); |
| 57 bool SkipPrefix(const char* prefix, const char** pstr); | 57 bool SkipPrefix(const char* prefix, const char** pstr); |
| 58 } // namespace internal | 58 } // namespace internal |
| 59 | 59 |
| 60 namespace gmock_matchers_test { | 60 namespace gmock_matchers_test { |
| 61 | 61 |
| 62 using std::stringstream; | 62 using std::stringstream; |
| 63 using std::tr1::make_tuple; |
| 63 using testing::A; | 64 using testing::A; |
| 65 using testing::AllArgs; |
| 64 using testing::AllOf; | 66 using testing::AllOf; |
| 65 using testing::An; | 67 using testing::An; |
| 66 using testing::AnyOf; | 68 using testing::AnyOf; |
| 67 using testing::ByRef; | 69 using testing::ByRef; |
| 68 using testing::DoubleEq; | 70 using testing::DoubleEq; |
| 69 using testing::EndsWith; | 71 using testing::EndsWith; |
| 70 using testing::Eq; | 72 using testing::Eq; |
| 71 using testing::Field; | 73 using testing::Field; |
| 72 using testing::FloatEq; | 74 using testing::FloatEq; |
| 73 using testing::Ge; | 75 using testing::Ge; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 91 using testing::Property; | 93 using testing::Property; |
| 92 using testing::Ref; | 94 using testing::Ref; |
| 93 using testing::ResultOf; | 95 using testing::ResultOf; |
| 94 using testing::StartsWith; | 96 using testing::StartsWith; |
| 95 using testing::StrCaseEq; | 97 using testing::StrCaseEq; |
| 96 using testing::StrCaseNe; | 98 using testing::StrCaseNe; |
| 97 using testing::StrEq; | 99 using testing::StrEq; |
| 98 using testing::StrNe; | 100 using testing::StrNe; |
| 99 using testing::Truly; | 101 using testing::Truly; |
| 100 using testing::TypedEq; | 102 using testing::TypedEq; |
| 103 using testing::Value; |
| 101 using testing::_; | 104 using testing::_; |
| 102 using testing::internal::FloatingEqMatcher; | 105 using testing::internal::FloatingEqMatcher; |
| 103 using testing::internal::FormatMatcherDescriptionSyntaxError; | 106 using testing::internal::FormatMatcherDescriptionSyntaxError; |
| 104 using testing::internal::GetParamIndex; | 107 using testing::internal::GetParamIndex; |
| 105 using testing::internal::Interpolation; | 108 using testing::internal::Interpolation; |
| 106 using testing::internal::Interpolations; | 109 using testing::internal::Interpolations; |
| 107 using testing::internal::JoinAsTuple; | 110 using testing::internal::JoinAsTuple; |
| 108 using testing::internal::SkipPrefix; | 111 using testing::internal::SkipPrefix; |
| 109 using testing::internal::String; | 112 using testing::internal::String; |
| 110 using testing::internal::Strings; | 113 using testing::internal::Strings; |
| (...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 // second field. | 1329 // second field. |
| 1327 TEST(Eq2Test, MatchesEqualArguments) { | 1330 TEST(Eq2Test, MatchesEqualArguments) { |
| 1328 Matcher<const Tuple2&> m = Eq(); | 1331 Matcher<const Tuple2&> m = Eq(); |
| 1329 EXPECT_TRUE(m.Matches(Tuple2(5L, 5))); | 1332 EXPECT_TRUE(m.Matches(Tuple2(5L, 5))); |
| 1330 EXPECT_FALSE(m.Matches(Tuple2(5L, 6))); | 1333 EXPECT_FALSE(m.Matches(Tuple2(5L, 6))); |
| 1331 } | 1334 } |
| 1332 | 1335 |
| 1333 // Tests that Eq() describes itself properly. | 1336 // Tests that Eq() describes itself properly. |
| 1334 TEST(Eq2Test, CanDescribeSelf) { | 1337 TEST(Eq2Test, CanDescribeSelf) { |
| 1335 Matcher<const Tuple2&> m = Eq(); | 1338 Matcher<const Tuple2&> m = Eq(); |
| 1336 EXPECT_EQ("argument #0 is equal to argument #1", Describe(m)); | 1339 EXPECT_EQ("are a pair (x, y) where x == y", Describe(m)); |
| 1337 } | 1340 } |
| 1338 | 1341 |
| 1339 // Tests that Ge() matches a 2-tuple where the first field >= the | 1342 // Tests that Ge() matches a 2-tuple where the first field >= the |
| 1340 // second field. | 1343 // second field. |
| 1341 TEST(Ge2Test, MatchesGreaterThanOrEqualArguments) { | 1344 TEST(Ge2Test, MatchesGreaterThanOrEqualArguments) { |
| 1342 Matcher<const Tuple2&> m = Ge(); | 1345 Matcher<const Tuple2&> m = Ge(); |
| 1343 EXPECT_TRUE(m.Matches(Tuple2(5L, 4))); | 1346 EXPECT_TRUE(m.Matches(Tuple2(5L, 4))); |
| 1344 EXPECT_TRUE(m.Matches(Tuple2(5L, 5))); | 1347 EXPECT_TRUE(m.Matches(Tuple2(5L, 5))); |
| 1345 EXPECT_FALSE(m.Matches(Tuple2(5L, 6))); | 1348 EXPECT_FALSE(m.Matches(Tuple2(5L, 6))); |
| 1346 } | 1349 } |
| 1347 | 1350 |
| 1348 // Tests that Ge() describes itself properly. | 1351 // Tests that Ge() describes itself properly. |
| 1349 TEST(Ge2Test, CanDescribeSelf) { | 1352 TEST(Ge2Test, CanDescribeSelf) { |
| 1350 Matcher<const Tuple2&> m = Ge(); | 1353 Matcher<const Tuple2&> m = Ge(); |
| 1351 EXPECT_EQ("argument #0 is greater than or equal to argument #1", | 1354 EXPECT_EQ("are a pair (x, y) where x >= y", Describe(m)); |
| 1352 Describe(m)); | |
| 1353 } | 1355 } |
| 1354 | 1356 |
| 1355 // Tests that Gt() matches a 2-tuple where the first field > the | 1357 // Tests that Gt() matches a 2-tuple where the first field > the |
| 1356 // second field. | 1358 // second field. |
| 1357 TEST(Gt2Test, MatchesGreaterThanArguments) { | 1359 TEST(Gt2Test, MatchesGreaterThanArguments) { |
| 1358 Matcher<const Tuple2&> m = Gt(); | 1360 Matcher<const Tuple2&> m = Gt(); |
| 1359 EXPECT_TRUE(m.Matches(Tuple2(5L, 4))); | 1361 EXPECT_TRUE(m.Matches(Tuple2(5L, 4))); |
| 1360 EXPECT_FALSE(m.Matches(Tuple2(5L, 5))); | 1362 EXPECT_FALSE(m.Matches(Tuple2(5L, 5))); |
| 1361 EXPECT_FALSE(m.Matches(Tuple2(5L, 6))); | 1363 EXPECT_FALSE(m.Matches(Tuple2(5L, 6))); |
| 1362 } | 1364 } |
| 1363 | 1365 |
| 1364 // Tests that Gt() describes itself properly. | 1366 // Tests that Gt() describes itself properly. |
| 1365 TEST(Gt2Test, CanDescribeSelf) { | 1367 TEST(Gt2Test, CanDescribeSelf) { |
| 1366 Matcher<const Tuple2&> m = Gt(); | 1368 Matcher<const Tuple2&> m = Gt(); |
| 1367 EXPECT_EQ("argument #0 is greater than argument #1", Describe(m)); | 1369 EXPECT_EQ("are a pair (x, y) where x > y", Describe(m)); |
| 1368 } | 1370 } |
| 1369 | 1371 |
| 1370 // Tests that Le() matches a 2-tuple where the first field <= the | 1372 // Tests that Le() matches a 2-tuple where the first field <= the |
| 1371 // second field. | 1373 // second field. |
| 1372 TEST(Le2Test, MatchesLessThanOrEqualArguments) { | 1374 TEST(Le2Test, MatchesLessThanOrEqualArguments) { |
| 1373 Matcher<const Tuple2&> m = Le(); | 1375 Matcher<const Tuple2&> m = Le(); |
| 1374 EXPECT_TRUE(m.Matches(Tuple2(5L, 6))); | 1376 EXPECT_TRUE(m.Matches(Tuple2(5L, 6))); |
| 1375 EXPECT_TRUE(m.Matches(Tuple2(5L, 5))); | 1377 EXPECT_TRUE(m.Matches(Tuple2(5L, 5))); |
| 1376 EXPECT_FALSE(m.Matches(Tuple2(5L, 4))); | 1378 EXPECT_FALSE(m.Matches(Tuple2(5L, 4))); |
| 1377 } | 1379 } |
| 1378 | 1380 |
| 1379 // Tests that Le() describes itself properly. | 1381 // Tests that Le() describes itself properly. |
| 1380 TEST(Le2Test, CanDescribeSelf) { | 1382 TEST(Le2Test, CanDescribeSelf) { |
| 1381 Matcher<const Tuple2&> m = Le(); | 1383 Matcher<const Tuple2&> m = Le(); |
| 1382 EXPECT_EQ("argument #0 is less than or equal to argument #1", | 1384 EXPECT_EQ("are a pair (x, y) where x <= y", Describe(m)); |
| 1383 Describe(m)); | |
| 1384 } | 1385 } |
| 1385 | 1386 |
| 1386 // Tests that Lt() matches a 2-tuple where the first field < the | 1387 // Tests that Lt() matches a 2-tuple where the first field < the |
| 1387 // second field. | 1388 // second field. |
| 1388 TEST(Lt2Test, MatchesLessThanArguments) { | 1389 TEST(Lt2Test, MatchesLessThanArguments) { |
| 1389 Matcher<const Tuple2&> m = Lt(); | 1390 Matcher<const Tuple2&> m = Lt(); |
| 1390 EXPECT_TRUE(m.Matches(Tuple2(5L, 6))); | 1391 EXPECT_TRUE(m.Matches(Tuple2(5L, 6))); |
| 1391 EXPECT_FALSE(m.Matches(Tuple2(5L, 5))); | 1392 EXPECT_FALSE(m.Matches(Tuple2(5L, 5))); |
| 1392 EXPECT_FALSE(m.Matches(Tuple2(5L, 4))); | 1393 EXPECT_FALSE(m.Matches(Tuple2(5L, 4))); |
| 1393 } | 1394 } |
| 1394 | 1395 |
| 1395 // Tests that Lt() describes itself properly. | 1396 // Tests that Lt() describes itself properly. |
| 1396 TEST(Lt2Test, CanDescribeSelf) { | 1397 TEST(Lt2Test, CanDescribeSelf) { |
| 1397 Matcher<const Tuple2&> m = Lt(); | 1398 Matcher<const Tuple2&> m = Lt(); |
| 1398 EXPECT_EQ("argument #0 is less than argument #1", Describe(m)); | 1399 EXPECT_EQ("are a pair (x, y) where x < y", Describe(m)); |
| 1399 } | 1400 } |
| 1400 | 1401 |
| 1401 // Tests that Ne() matches a 2-tuple where the first field != the | 1402 // Tests that Ne() matches a 2-tuple where the first field != the |
| 1402 // second field. | 1403 // second field. |
| 1403 TEST(Ne2Test, MatchesUnequalArguments) { | 1404 TEST(Ne2Test, MatchesUnequalArguments) { |
| 1404 Matcher<const Tuple2&> m = Ne(); | 1405 Matcher<const Tuple2&> m = Ne(); |
| 1405 EXPECT_TRUE(m.Matches(Tuple2(5L, 6))); | 1406 EXPECT_TRUE(m.Matches(Tuple2(5L, 6))); |
| 1406 EXPECT_TRUE(m.Matches(Tuple2(5L, 4))); | 1407 EXPECT_TRUE(m.Matches(Tuple2(5L, 4))); |
| 1407 EXPECT_FALSE(m.Matches(Tuple2(5L, 5))); | 1408 EXPECT_FALSE(m.Matches(Tuple2(5L, 5))); |
| 1408 } | 1409 } |
| 1409 | 1410 |
| 1410 // Tests that Ne() describes itself properly. | 1411 // Tests that Ne() describes itself properly. |
| 1411 TEST(Ne2Test, CanDescribeSelf) { | 1412 TEST(Ne2Test, CanDescribeSelf) { |
| 1412 Matcher<const Tuple2&> m = Ne(); | 1413 Matcher<const Tuple2&> m = Ne(); |
| 1413 EXPECT_EQ("argument #0 is not equal to argument #1", Describe(m)); | 1414 EXPECT_EQ("are a pair (x, y) where x != y", Describe(m)); |
| 1414 } | 1415 } |
| 1415 | 1416 |
| 1416 // Tests that Not(m) matches any value that doesn't match m. | 1417 // Tests that Not(m) matches any value that doesn't match m. |
| 1417 TEST(NotTest, NegatesMatcher) { | 1418 TEST(NotTest, NegatesMatcher) { |
| 1418 Matcher<int> m; | 1419 Matcher<int> m; |
| 1419 m = Not(Eq(2)); | 1420 m = Not(Eq(2)); |
| 1420 EXPECT_TRUE(m.Matches(3)); | 1421 EXPECT_TRUE(m.Matches(3)); |
| 1421 EXPECT_FALSE(m.Matches(2)); | 1422 EXPECT_FALSE(m.Matches(2)); |
| 1422 } | 1423 } |
| 1423 | 1424 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 } | 1664 } |
| 1664 | 1665 |
| 1665 // Tests that a Matcher on non-reference type can be used in | 1666 // Tests that a Matcher on non-reference type can be used in |
| 1666 // Matches(). | 1667 // Matches(). |
| 1667 TEST(MatchesTest, WorksWithMatcherOnNonRefType) { | 1668 TEST(MatchesTest, WorksWithMatcherOnNonRefType) { |
| 1668 Matcher<int> eq5 = Eq(5); | 1669 Matcher<int> eq5 = Eq(5); |
| 1669 EXPECT_TRUE(Matches(eq5)(5)); | 1670 EXPECT_TRUE(Matches(eq5)(5)); |
| 1670 EXPECT_FALSE(Matches(eq5)(2)); | 1671 EXPECT_FALSE(Matches(eq5)(2)); |
| 1671 } | 1672 } |
| 1672 | 1673 |
| 1674 // Tests Value(value, matcher). Since Value() is a simple wrapper for |
| 1675 // Matches(), which has been tested already, we don't spend a lot of |
| 1676 // effort on testing Value(). |
| 1677 TEST(ValueTest, WorksWithPolymorphicMatcher) { |
| 1678 EXPECT_TRUE(Value("hi", StartsWith("h"))); |
| 1679 EXPECT_FALSE(Value(5, Gt(10))); |
| 1680 } |
| 1681 |
| 1682 TEST(ValueTest, WorksWithMonomorphicMatcher) { |
| 1683 const Matcher<int> is_zero = Eq(0); |
| 1684 EXPECT_TRUE(Value(0, is_zero)); |
| 1685 EXPECT_FALSE(Value('a', is_zero)); |
| 1686 |
| 1687 int n = 0; |
| 1688 const Matcher<const int&> ref_n = Ref(n); |
| 1689 EXPECT_TRUE(Value(n, ref_n)); |
| 1690 EXPECT_FALSE(Value(1, ref_n)); |
| 1691 } |
| 1692 |
| 1693 TEST(AllArgsTest, WorksForTuple) { |
| 1694 EXPECT_THAT(make_tuple(1, 2L), AllArgs(Lt())); |
| 1695 EXPECT_THAT(make_tuple(2L, 1), Not(AllArgs(Lt()))); |
| 1696 } |
| 1697 |
| 1698 TEST(AllArgsTest, WorksForNonTuple) { |
| 1699 EXPECT_THAT(42, AllArgs(Gt(0))); |
| 1700 EXPECT_THAT('a', Not(AllArgs(Eq('b')))); |
| 1701 } |
| 1702 |
| 1703 class AllArgsHelper { |
| 1704 public: |
| 1705 MOCK_METHOD2(Helper, int(char x, int y)); |
| 1706 }; |
| 1707 |
| 1708 TEST(AllArgsTest, WorksInWithClause) { |
| 1709 AllArgsHelper helper; |
| 1710 ON_CALL(helper, Helper(_, _)) |
| 1711 .With(AllArgs(Lt())) |
| 1712 .WillByDefault(Return(1)); |
| 1713 EXPECT_CALL(helper, Helper(_, _)); |
| 1714 EXPECT_CALL(helper, Helper(_, _)) |
| 1715 .With(AllArgs(Gt())) |
| 1716 .WillOnce(Return(2)); |
| 1717 |
| 1718 EXPECT_EQ(1, helper.Helper('\1', 2)); |
| 1719 EXPECT_EQ(2, helper.Helper('a', 1)); |
| 1720 } |
| 1721 |
| 1673 // Tests that ASSERT_THAT() and EXPECT_THAT() work when the value | 1722 // Tests that ASSERT_THAT() and EXPECT_THAT() work when the value |
| 1674 // matches the matcher. | 1723 // matches the matcher. |
| 1675 TEST(MatcherAssertionTest, WorksWhenMatcherIsSatisfied) { | 1724 TEST(MatcherAssertionTest, WorksWhenMatcherIsSatisfied) { |
| 1676 ASSERT_THAT(5, Ge(2)) << "This should succeed."; | 1725 ASSERT_THAT(5, Ge(2)) << "This should succeed."; |
| 1677 ASSERT_THAT("Foo", EndsWith("oo")); | 1726 ASSERT_THAT("Foo", EndsWith("oo")); |
| 1678 EXPECT_THAT(2, AllOf(Le(7), Ge(0))) << "This should succeed too."; | 1727 EXPECT_THAT(2, AllOf(Le(7), Ge(0))) << "This should succeed too."; |
| 1679 EXPECT_THAT("Hello", StartsWith("Hell")); | 1728 EXPECT_THAT("Hello", StartsWith("Hell")); |
| 1680 } | 1729 } |
| 1681 | 1730 |
| 1682 // Tests that ASSERT_THAT() and EXPECT_THAT() work when the value | 1731 // Tests that ASSERT_THAT() and EXPECT_THAT() work when the value |
| (...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2758 | 2807 |
| 2759 NotCopyable n1(1), n2(2); | 2808 NotCopyable n1(1), n2(2); |
| 2760 EXPECT_FALSE(m.Matches(n1)); | 2809 EXPECT_FALSE(m.Matches(n1)); |
| 2761 EXPECT_TRUE(m.Matches(n2)); | 2810 EXPECT_TRUE(m.Matches(n2)); |
| 2762 } | 2811 } |
| 2763 | 2812 |
| 2764 // Tests ContainerEq with different container types, and | 2813 // Tests ContainerEq with different container types, and |
| 2765 // different element types. | 2814 // different element types. |
| 2766 | 2815 |
| 2767 template <typename T> | 2816 template <typename T> |
| 2768 class ContainerEqTest : public testing::Test { | 2817 class ContainerEqTest : public testing::Test {}; |
| 2769 public: | |
| 2770 }; | |
| 2771 | 2818 |
| 2772 typedef testing::Types< | 2819 typedef testing::Types< |
| 2773 std::set<int>, | 2820 std::set<int>, |
| 2774 std::vector<size_t>, | 2821 std::vector<size_t>, |
| 2775 std::multiset<size_t>, | 2822 std::multiset<size_t>, |
| 2776 std::list<int> > | 2823 std::list<int> > |
| 2777 ContainerEqTestTypes; | 2824 ContainerEqTestTypes; |
| 2778 | 2825 |
| 2779 TYPED_TEST_CASE(ContainerEqTest, ContainerEqTestTypes); | 2826 TYPED_TEST_CASE(ContainerEqTest, ContainerEqTestTypes); |
| 2780 | 2827 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2894 test_map[1] = "b"; | 2941 test_map[1] = "b"; |
| 2895 | 2942 |
| 2896 const Matcher<const std::map<int, std::string>&> m = ContainerEq(my_map); | 2943 const Matcher<const std::map<int, std::string>&> m = ContainerEq(my_map); |
| 2897 EXPECT_TRUE(m.Matches(my_map)); | 2944 EXPECT_TRUE(m.Matches(my_map)); |
| 2898 EXPECT_FALSE(m.Matches(test_map)); | 2945 EXPECT_FALSE(m.Matches(test_map)); |
| 2899 | 2946 |
| 2900 EXPECT_EQ("Only in actual: (0, \"aa\"); not in actual: (0, \"a\")", | 2947 EXPECT_EQ("Only in actual: (0, \"aa\"); not in actual: (0, \"a\")", |
| 2901 Explain(m, test_map)); | 2948 Explain(m, test_map)); |
| 2902 } | 2949 } |
| 2903 | 2950 |
| 2951 TEST(ContainerEqExtraTest, WorksForNativeArray) { |
| 2952 int a1[] = { 1, 2, 3 }; |
| 2953 int a2[] = { 1, 2, 3 }; |
| 2954 int b[] = { 1, 2, 4 }; |
| 2955 |
| 2956 EXPECT_THAT(a1, ContainerEq(a2)); |
| 2957 EXPECT_THAT(a1, Not(ContainerEq(b))); |
| 2958 } |
| 2959 |
| 2960 TEST(ContainerEqExtraTest, WorksForTwoDimensionalNativeArray) { |
| 2961 const char a1[][3] = { "hi", "lo" }; |
| 2962 const char a2[][3] = { "hi", "lo" }; |
| 2963 const char b[][3] = { "lo", "hi" }; |
| 2964 |
| 2965 // Tests using ContainerEq() in the first dimension. |
| 2966 EXPECT_THAT(a1, ContainerEq(a2)); |
| 2967 EXPECT_THAT(a1, Not(ContainerEq(b))); |
| 2968 |
| 2969 // Tests using ContainerEq() in the second dimension. |
| 2970 EXPECT_THAT(a1, ElementsAre(ContainerEq(a2[0]), ContainerEq(a2[1]))); |
| 2971 EXPECT_THAT(a1, ElementsAre(Not(ContainerEq(b[0])), ContainerEq(a2[1]))); |
| 2972 } |
| 2973 |
| 2974 TEST(ContainerEqExtraTest, WorksForNativeArrayAsTuple) { |
| 2975 const int a1[] = { 1, 2, 3 }; |
| 2976 const int a2[] = { 1, 2, 3 }; |
| 2977 const int b[] = { 1, 2, 3, 4 }; |
| 2978 |
| 2979 const int* const p1 = a1; |
| 2980 EXPECT_THAT(make_tuple(p1, 3), ContainerEq(a2)); |
| 2981 EXPECT_THAT(make_tuple(p1, 3), Not(ContainerEq(b))); |
| 2982 |
| 2983 const int c[] = { 1, 3, 2 }; |
| 2984 EXPECT_THAT(make_tuple(p1, 3), Not(ContainerEq(c))); |
| 2985 } |
| 2986 |
| 2987 TEST(ContainerEqExtraTest, CopiesNativeArrayParameter) { |
| 2988 std::string a1[][3] = { |
| 2989 { "hi", "hello", "ciao" }, |
| 2990 { "bye", "see you", "ciao" } |
| 2991 }; |
| 2992 |
| 2993 std::string a2[][3] = { |
| 2994 { "hi", "hello", "ciao" }, |
| 2995 { "bye", "see you", "ciao" } |
| 2996 }; |
| 2997 |
| 2998 const Matcher<const std::string(&)[2][3]> m = ContainerEq(a2); |
| 2999 EXPECT_THAT(a1, m); |
| 3000 |
| 3001 a2[0][0] = "ha"; |
| 3002 EXPECT_THAT(a1, m); |
| 3003 } |
| 3004 |
| 2904 // Tests GetParamIndex(). | 3005 // Tests GetParamIndex(). |
| 2905 | 3006 |
| 2906 TEST(GetParamIndexTest, WorksForEmptyParamList) { | 3007 TEST(GetParamIndexTest, WorksForEmptyParamList) { |
| 2907 const char* params[] = { NULL }; | 3008 const char* params[] = { NULL }; |
| 2908 EXPECT_EQ(kTupleInterpolation, GetParamIndex(params, "*")); | 3009 EXPECT_EQ(kTupleInterpolation, GetParamIndex(params, "*")); |
| 2909 EXPECT_EQ(kInvalidInterpolation, GetParamIndex(params, "a")); | 3010 EXPECT_EQ(kInvalidInterpolation, GetParamIndex(params, "a")); |
| 2910 } | 3011 } |
| 2911 | 3012 |
| 2912 TEST(GetParamIndexTest, RecognizesStar) { | 3013 TEST(GetParamIndexTest, RecognizesStar) { |
| 2913 const char* params[] = { "a", "b", NULL }; | 3014 const char* params[] = { "a", "b", NULL }; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3190 const char* const desc = "> %(x)s %(x)"; | 3291 const char* const desc = "> %(x)s %(x)"; |
| 3191 const Interpolation interp[] = { Interpolation(desc + 2, desc + 7, 0) }; | 3292 const Interpolation interp[] = { Interpolation(desc + 2, desc + 7, 0) }; |
| 3192 EXPECT_EQ("> 9 %(x)", | 3293 EXPECT_EQ("> 9 %(x)", |
| 3193 FormatMatcherDescription("Foo", desc, | 3294 FormatMatcherDescription("Foo", desc, |
| 3194 Interpolations(interp, interp + 1), | 3295 Interpolations(interp, interp + 1), |
| 3195 Strings(params, params + 1))); | 3296 Strings(params, params + 1))); |
| 3196 } | 3297 } |
| 3197 | 3298 |
| 3198 } // namespace gmock_matchers_test | 3299 } // namespace gmock_matchers_test |
| 3199 } // namespace testing | 3300 } // namespace testing |
| OLD | NEW |