diff options
author | Abseil Team <absl-team@google.com> | 2018-10-09 18:50:26 (GMT) |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2018-10-09 20:25:58 (GMT) |
commit | 7d3b73c85a42811309eac26e5cbe054c40b64785 (patch) | |
tree | 589142a210a7bf1ccfd51180586a35c4a6f73b68 /googletest/test/googletest-param-test-test.cc | |
parent | 5434989dbd8a15f14f33cbeb9d94801247031c95 (diff) | |
download | googletest-7d3b73c85a42811309eac26e5cbe054c40b64785.zip googletest-7d3b73c85a42811309eac26e5cbe054c40b64785.tar.gz googletest-7d3b73c85a42811309eac26e5cbe054c40b64785.tar.bz2 |
Unconditionally use std::tuple.
Remove all mention of TR1 tuple and our own implementation of tuple.
PiperOrigin-RevId: 216395043
Diffstat (limited to 'googletest/test/googletest-param-test-test.cc')
-rw-r--r-- | googletest/test/googletest-param-test-test.cc | 108 |
1 files changed, 47 insertions, 61 deletions
diff --git a/googletest/test/googletest-param-test-test.cc b/googletest/test/googletest-param-test-test.cc index be9548e..05e0b23 100644 --- a/googletest/test/googletest-param-test-test.cc +++ b/googletest/test/googletest-param-test-test.cc @@ -49,19 +49,13 @@ using ::std::sort; using ::testing::AddGlobalTestEnvironment; using ::testing::Bool; +using ::testing::Combine; using ::testing::Message; using ::testing::Range; using ::testing::TestWithParam; using ::testing::Values; using ::testing::ValuesIn; -# if GTEST_HAS_COMBINE -using ::testing::Combine; -using ::testing::get; -using ::testing::make_tuple; -using ::testing::tuple; -# endif // GTEST_HAS_COMBINE - using ::testing::internal::ParamGenerator; using ::testing::internal::UnitTestOptions; @@ -78,8 +72,6 @@ template <typename T> return stream.str(); } -# if GTEST_HAS_COMBINE - // These overloads allow printing tuples in our tests. We cannot // define an operator<< for tuples, as that definition needs to be in // the std namespace in order to be picked up by Google Test via @@ -87,35 +79,33 @@ template <typename T> // namespace in non-STL code is undefined behavior. template <typename T1, typename T2> -::std::string PrintValue(const tuple<T1, T2>& value) { +::std::string PrintValue(const std::tuple<T1, T2>& value) { ::std::stringstream stream; - stream << "(" << get<0>(value) << ", " << get<1>(value) << ")"; + stream << "(" << std::get<0>(value) << ", " << std::get<1>(value) << ")"; return stream.str(); } template <typename T1, typename T2, typename T3> -::std::string PrintValue(const tuple<T1, T2, T3>& value) { +::std::string PrintValue(const std::tuple<T1, T2, T3>& value) { ::std::stringstream stream; - stream << "(" << get<0>(value) << ", " << get<1>(value) - << ", "<< get<2>(value) << ")"; + stream << "(" << std::get<0>(value) << ", " << std::get<1>(value) << ", " + << std::get<2>(value) << ")"; return stream.str(); } template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10> ::std::string PrintValue( - const tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& value) { + const std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& value) { ::std::stringstream stream; - stream << "(" << get<0>(value) << ", " << get<1>(value) - << ", "<< get<2>(value) << ", " << get<3>(value) - << ", "<< get<4>(value) << ", " << get<5>(value) - << ", "<< get<6>(value) << ", " << get<7>(value) - << ", "<< get<8>(value) << ", " << get<9>(value) << ")"; + stream << "(" << std::get<0>(value) << ", " << std::get<1>(value) << ", " + << std::get<2>(value) << ", " << std::get<3>(value) << ", " + << std::get<4>(value) << ", " << std::get<5>(value) << ", " + << std::get<6>(value) << ", " << std::get<7>(value) << ", " + << std::get<8>(value) << ", " << std::get<9>(value) << ")"; return stream.str(); } -# endif // GTEST_HAS_COMBINE - // Verifies that a sequence generated by the generator and accessed // via the iterator object matches the expected one using Google Test // assertions. @@ -450,31 +440,28 @@ TEST(BoolTest, BoolWorks) { VerifyGenerator(gen, expected_values); } -# if GTEST_HAS_COMBINE - // Tests that Combine() with two parameters generates the expected sequence. TEST(CombineTest, CombineWithTwoParameters) { const char* foo = "foo"; const char* bar = "bar"; - const ParamGenerator<tuple<const char*, int> > gen = + const ParamGenerator<std::tuple<const char*, int> > gen = Combine(Values(foo, bar), Values(3, 4)); - tuple<const char*, int> expected_values[] = { - make_tuple(foo, 3), make_tuple(foo, 4), - make_tuple(bar, 3), make_tuple(bar, 4)}; + std::tuple<const char*, int> expected_values[] = { + std::make_tuple(foo, 3), std::make_tuple(foo, 4), std::make_tuple(bar, 3), + std::make_tuple(bar, 4)}; VerifyGenerator(gen, expected_values); } // Tests that Combine() with three parameters generates the expected sequence. TEST(CombineTest, CombineWithThreeParameters) { - const ParamGenerator<tuple<int, int, int> > gen = Combine(Values(0, 1), - Values(3, 4), - Values(5, 6)); - tuple<int, int, int> expected_values[] = { - make_tuple(0, 3, 5), make_tuple(0, 3, 6), - make_tuple(0, 4, 5), make_tuple(0, 4, 6), - make_tuple(1, 3, 5), make_tuple(1, 3, 6), - make_tuple(1, 4, 5), make_tuple(1, 4, 6)}; + const ParamGenerator<std::tuple<int, int, int> > gen = + Combine(Values(0, 1), Values(3, 4), Values(5, 6)); + std::tuple<int, int, int> expected_values[] = { + std::make_tuple(0, 3, 5), std::make_tuple(0, 3, 6), + std::make_tuple(0, 4, 5), std::make_tuple(0, 4, 6), + std::make_tuple(1, 3, 5), std::make_tuple(1, 3, 6), + std::make_tuple(1, 4, 5), std::make_tuple(1, 4, 6)}; VerifyGenerator(gen, expected_values); } @@ -482,10 +469,11 @@ TEST(CombineTest, CombineWithThreeParameters) { // sequence generates a sequence with the number of elements equal to the // number of elements in the sequence generated by the second parameter. TEST(CombineTest, CombineWithFirstParameterSingleValue) { - const ParamGenerator<tuple<int, int> > gen = Combine(Values(42), - Values(0, 1)); + const ParamGenerator<std::tuple<int, int> > gen = + Combine(Values(42), Values(0, 1)); - tuple<int, int> expected_values[] = {make_tuple(42, 0), make_tuple(42, 1)}; + std::tuple<int, int> expected_values[] = {std::make_tuple(42, 0), + std::make_tuple(42, 1)}; VerifyGenerator(gen, expected_values); } @@ -493,26 +481,27 @@ TEST(CombineTest, CombineWithFirstParameterSingleValue) { // sequence generates a sequence with the number of elements equal to the // number of elements in the sequence generated by the first parameter. TEST(CombineTest, CombineWithSecondParameterSingleValue) { - const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1), - Values(42)); + const ParamGenerator<std::tuple<int, int> > gen = + Combine(Values(0, 1), Values(42)); - tuple<int, int> expected_values[] = {make_tuple(0, 42), make_tuple(1, 42)}; + std::tuple<int, int> expected_values[] = {std::make_tuple(0, 42), + std::make_tuple(1, 42)}; VerifyGenerator(gen, expected_values); } // Tests that when the first parameter produces an empty sequence, // Combine() produces an empty sequence, too. TEST(CombineTest, CombineWithFirstParameterEmptyRange) { - const ParamGenerator<tuple<int, int> > gen = Combine(Range(0, 0), - Values(0, 1)); + const ParamGenerator<std::tuple<int, int> > gen = + Combine(Range(0, 0), Values(0, 1)); VerifyGeneratorIsEmpty(gen); } // Tests that when the second parameter produces an empty sequence, // Combine() produces an empty sequence, too. TEST(CombineTest, CombineWithSecondParameterEmptyRange) { - const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1), - Range(1, 1)); + const ParamGenerator<std::tuple<int, int> > gen = + Combine(Values(0, 1), Range(1, 1)); VerifyGeneratorIsEmpty(gen); } @@ -521,17 +510,15 @@ TEST(CombineTest, CombineWithSecondParameterEmptyRange) { TEST(CombineTest, CombineWithMaxNumberOfParameters) { const char* foo = "foo"; const char* bar = "bar"; - const ParamGenerator<tuple<const char*, int, int, int, int, int, int, int, - int, int> > gen = Combine(Values(foo, bar), - Values(1), Values(2), - Values(3), Values(4), - Values(5), Values(6), - Values(7), Values(8), - Values(9)); - - tuple<const char*, int, int, int, int, int, int, int, int, int> - expected_values[] = {make_tuple(foo, 1, 2, 3, 4, 5, 6, 7, 8, 9), - make_tuple(bar, 1, 2, 3, 4, 5, 6, 7, 8, 9)}; + const ParamGenerator< + std::tuple<const char*, int, int, int, int, int, int, int, int, int> > + gen = + Combine(Values(foo, bar), Values(1), Values(2), Values(3), Values(4), + Values(5), Values(6), Values(7), Values(8), Values(9)); + + std::tuple<const char*, int, int, int, int, int, int, int, int, int> + expected_values[] = {std::make_tuple(foo, 1, 2, 3, 4, 5, 6, 7, 8, 9), + std::make_tuple(bar, 1, 2, 3, 4, 5, 6, 7, 8, 9)}; VerifyGenerator(gen, expected_values); } @@ -551,12 +538,12 @@ class NonDefaultConstructAssignString { }; TEST(CombineTest, NonDefaultConstructAssign) { - const ParamGenerator<tuple<int, NonDefaultConstructAssignString> > gen = + const ParamGenerator<std::tuple<int, NonDefaultConstructAssignString> > gen = Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"), NonDefaultConstructAssignString("B"))); - ParamGenerator<tuple<int, NonDefaultConstructAssignString> >::iterator it = - gen.begin(); + ParamGenerator<std::tuple<int, NonDefaultConstructAssignString> >::iterator + it = gen.begin(); EXPECT_EQ(0, std::get<0>(*it)); EXPECT_EQ("A", std::get<1>(*it).str()); @@ -577,7 +564,6 @@ TEST(CombineTest, NonDefaultConstructAssign) { EXPECT_TRUE(it == gen.end()); } -# endif // GTEST_HAS_COMBINE // Tests that an generator produces correct sequence after being // assigned from another generator. |