diff options
author | Gennadiy Civil <misterg@google.com> | 2019-10-22 13:38:21 (GMT) |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2019-10-22 13:38:21 (GMT) |
commit | de1128355464aea0427dbc15053fbfe0269683a4 (patch) | |
tree | 001b97bd22e9e950e209a004373420522098ffb7 /googlemock/test/gmock-matchers_test.cc | |
parent | 611a321a6e641846497f75375f9cbe7825ff3f23 (diff) | |
parent | e0d16aa33662857a5b3f47359f46910d4d18ab5b (diff) | |
download | googletest-de1128355464aea0427dbc15053fbfe0269683a4.zip googletest-de1128355464aea0427dbc15053fbfe0269683a4.tar.gz googletest-de1128355464aea0427dbc15053fbfe0269683a4.tar.bz2 |
Merge pull request #2444 from kuzkry:remove-GTEST_ARRAY_SIZE_
PiperOrigin-RevId: 275842505
Diffstat (limited to 'googlemock/test/gmock-matchers_test.cc')
-rw-r--r-- | googlemock/test/gmock-matchers_test.cc | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index b9eb894..bc49cb6 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -41,10 +41,11 @@ #endif #include "gmock/gmock-matchers.h" -#include "gmock/gmock-more-matchers.h" #include <string.h> #include <time.h> + +#include <array> #include <deque> #include <forward_list> #include <functional> @@ -60,9 +61,11 @@ #include <type_traits> #include <utility> #include <vector> + +#include "gmock/gmock-more-matchers.h" #include "gmock/gmock.h" -#include "gtest/gtest.h" #include "gtest/gtest-spi.h" +#include "gtest/gtest.h" namespace testing { namespace gmock_matchers_test { @@ -5201,14 +5204,14 @@ TEST(WhenSortedTest, WorksForStreamlike) { // Streamlike 'container' provides only minimal iterator support. // Its iterators are tagged with input_iterator_tag. const int a[5] = {2, 1, 4, 5, 3}; - Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a)); + Streamlike<int> s(std::begin(a), std::end(a)); EXPECT_THAT(s, WhenSorted(ElementsAre(1, 2, 3, 4, 5))); EXPECT_THAT(s, Not(WhenSorted(ElementsAre(2, 1, 4, 5, 3)))); } TEST(WhenSortedTest, WorksForVectorConstRefMatcherOnStreamlike) { const int a[] = {2, 1, 4, 5, 3}; - Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a)); + Streamlike<int> s(std::begin(a), std::end(a)); Matcher<const std::vector<int>&> vector_match = ElementsAre(1, 2, 3, 4, 5); EXPECT_THAT(s, WhenSorted(vector_match)); EXPECT_THAT(s, Not(WhenSorted(ElementsAre(2, 1, 4, 5, 3)))); @@ -5253,7 +5256,7 @@ TEST(IsSupersetOfTest, WorksForEmpty) { TEST(IsSupersetOfTest, WorksForStreamlike) { const int a[5] = {1, 2, 3, 4, 5}; - Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a)); + Streamlike<int> s(std::begin(a), std::end(a)); vector<int> expected; expected.push_back(1); @@ -5381,7 +5384,7 @@ TEST(IsSubsetOfTest, WorksForEmpty) { TEST(IsSubsetOfTest, WorksForStreamlike) { const int a[5] = {1, 2}; - Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a)); + Streamlike<int> s(std::begin(a), std::end(a)); vector<int> expected; expected.push_back(1); @@ -5475,14 +5478,14 @@ TEST(IsSubsetOfTest, WorksWithMoveOnly) { TEST(ElemensAreStreamTest, WorksForStreamlike) { const int a[5] = {1, 2, 3, 4, 5}; - Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a)); + Streamlike<int> s(std::begin(a), std::end(a)); EXPECT_THAT(s, ElementsAre(1, 2, 3, 4, 5)); EXPECT_THAT(s, Not(ElementsAre(2, 1, 4, 5, 3))); } TEST(ElemensAreArrayStreamTest, WorksForStreamlike) { const int a[5] = {1, 2, 3, 4, 5}; - Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a)); + Streamlike<int> s(std::begin(a), std::end(a)); vector<int> expected; expected.push_back(1); @@ -5529,7 +5532,7 @@ TEST(ElementsAreTest, TakesStlContainer) { TEST(UnorderedElementsAreArrayTest, SucceedsWhenExpected) { const int a[] = {0, 1, 2, 3, 4}; - std::vector<int> s(a, a + GTEST_ARRAY_SIZE_(a)); + std::vector<int> s(std::begin(a), std::end(a)); do { StringMatchResultListener listener; EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(a), @@ -5540,8 +5543,8 @@ TEST(UnorderedElementsAreArrayTest, SucceedsWhenExpected) { TEST(UnorderedElementsAreArrayTest, VectorBool) { const bool a[] = {0, 1, 0, 1, 1}; const bool b[] = {1, 0, 1, 1, 0}; - std::vector<bool> expected(a, a + GTEST_ARRAY_SIZE_(a)); - std::vector<bool> actual(b, b + GTEST_ARRAY_SIZE_(b)); + std::vector<bool> expected(std::begin(a), std::end(a)); + std::vector<bool> actual(std::begin(b), std::end(b)); StringMatchResultListener listener; EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(expected), actual, &listener)) << listener.str(); @@ -5552,7 +5555,7 @@ TEST(UnorderedElementsAreArrayTest, WorksForStreamlike) { // Its iterators are tagged with input_iterator_tag, and it has no // size() or empty() methods. const int a[5] = {2, 1, 4, 5, 3}; - Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a)); + Streamlike<int> s(std::begin(a), std::end(a)); ::std::vector<int> expected; expected.push_back(1); @@ -5635,7 +5638,7 @@ TEST_F(UnorderedElementsAreTest, WorksWithUncopyable) { TEST_F(UnorderedElementsAreTest, SucceedsWhenExpected) { const int a[] = {1, 2, 3}; - std::vector<int> s(a, a + GTEST_ARRAY_SIZE_(a)); + std::vector<int> s(std::begin(a), std::end(a)); do { StringMatchResultListener listener; EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAre(1, 2, 3), @@ -5645,7 +5648,7 @@ TEST_F(UnorderedElementsAreTest, SucceedsWhenExpected) { TEST_F(UnorderedElementsAreTest, FailsWhenAnElementMatchesNoMatcher) { const int a[] = {1, 2, 3}; - std::vector<int> s(a, a + GTEST_ARRAY_SIZE_(a)); + std::vector<int> s(std::begin(a), std::end(a)); std::vector<Matcher<int> > mv; mv.push_back(1); mv.push_back(2); @@ -5661,7 +5664,7 @@ TEST_F(UnorderedElementsAreTest, WorksForStreamlike) { // Its iterators are tagged with input_iterator_tag, and it has no // size() or empty() methods. const int a[5] = {2, 1, 4, 5, 3}; - Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a)); + Streamlike<int> s(std::begin(a), std::end(a)); EXPECT_THAT(s, UnorderedElementsAre(1, 2, 3, 4, 5)); EXPECT_THAT(s, Not(UnorderedElementsAre(2, 2, 3, 4, 5))); @@ -5977,8 +5980,9 @@ TEST_F(BipartiteNonSquareTest, SimpleBacktracking) { // :.......: // 0 1 2 MatchMatrix g(4, 3); - static const size_t kEdges[][2] = {{0, 2}, {1, 1}, {2, 1}, {3, 0}}; - for (size_t i = 0; i < GTEST_ARRAY_SIZE_(kEdges); ++i) { + constexpr std::array<std::array<size_t, 2>, 4> kEdges = { + {{{0, 2}}, {{1, 1}}, {{2, 1}}, {{3, 0}}}}; + for (size_t i = 0; i < kEdges.size(); ++i) { g.SetEdge(kEdges[i][0], kEdges[i][1], true); } EXPECT_THAT(FindBacktrackingMaxBPM(g), |