diff options
author | Gennadiy Civil <gennadiycivil@users.noreply.github.com> | 2018-02-13 12:26:47 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-13 12:26:47 -0500 |
commit | ffc5f5ad3cc1e98b76923d63a930921bc91a4c41 (patch) | |
tree | e6dae109779162f5eef69e1cde1a252f93d5868b | |
parent | 9d1a80c0fbc03d8c824e0263d27d419b38b61bf4 (diff) | |
parent | 30d276da03468d08bcde1820b6b9ed17e9fffbe6 (diff) | |
download | googletest-ffc5f5ad3cc1e98b76923d63a930921bc91a4c41.tar.gz googletest-ffc5f5ad3cc1e98b76923d63a930921bc91a4c41.tar.bz2 googletest-ffc5f5ad3cc1e98b76923d63a930921bc91a4c41.zip |
Merge pull request #1454 from gennadiycivil/master
merges
-rw-r--r-- | googletest/test/gtest-param-test_test.cc | 60 |
1 files changed, 53 insertions, 7 deletions
diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index b0aa4f9b..fb2e44b0 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -41,8 +41,8 @@ # include <sstream> # include <string> # include <vector> -# include "src/gtest-internal-inl.h" // for UnitTestOptions +# include "src/gtest-internal-inl.h" // for UnitTestOptions # include "test/gtest-param-test_test.h" using ::std::vector; @@ -536,6 +536,51 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) { VerifyGenerator(gen, expected_values); } +#if GTEST_LANG_CXX11 + +class NonDefaultConstructAssignString { + public: + NonDefaultConstructAssignString(const std::string& s) : str_(s) {} + + const std::string& str() const { return str_; } + + private: + std::string str_; + + // Not default constructible + NonDefaultConstructAssignString(); + // Not assignable + void operator=(const NonDefaultConstructAssignString&); +}; + +TEST(CombineTest, NonDefaultConstructAssign) { + const ParamGenerator<tuple<int, NonDefaultConstructAssignString> > gen = + Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"), + NonDefaultConstructAssignString("B"))); + + ParamGenerator<tuple<int, NonDefaultConstructAssignString> >::iterator it = + gen.begin(); + + EXPECT_EQ(0, std::get<0>(*it)); + EXPECT_EQ("A", std::get<1>(*it).str()); + ++it; + + EXPECT_EQ(0, std::get<0>(*it)); + EXPECT_EQ("B", std::get<1>(*it).str()); + ++it; + + EXPECT_EQ(1, std::get<0>(*it)); + EXPECT_EQ("A", std::get<1>(*it).str()); + ++it; + + EXPECT_EQ(1, std::get<0>(*it)); + EXPECT_EQ("B", std::get<1>(*it).str()); + ++it; + + EXPECT_TRUE(it == gen.end()); +} + +#endif // GTEST_LANG_CXX11 # endif // GTEST_HAS_COMBINE // Tests that an generator produces correct sequence after being @@ -811,8 +856,8 @@ class CustomFunctorNamingTest : public TestWithParam<std::string> {}; TEST_P(CustomFunctorNamingTest, CustomTestNames) {} struct CustomParamNameFunctor { - std::string operator()(const ::testing::TestParamInfo<std::string>& info) { - return info.param; + std::string operator()(const ::testing::TestParamInfo<std::string>& inf) { + return inf.param; } }; @@ -829,8 +874,8 @@ INSTANTIATE_TEST_CASE_P(AllAllowedCharacters, CustomParamNameFunctor()); inline std::string CustomParamNameFunction( - const ::testing::TestParamInfo<std::string>& info) { - return info.param; + const ::testing::TestParamInfo<std::string>& inf) { + return inf.param; } class CustomFunctionNamingTest : public TestWithParam<std::string> {}; @@ -851,8 +896,8 @@ TEST_P(CustomLambdaNamingTest, CustomTestNames) {} INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, CustomLambdaNamingTest, Values(std::string("LambdaName")), - [](const ::testing::TestParamInfo<std::string>& tpinfo) { - return tpinfo.param; + [](const ::testing::TestParamInfo<std::string>& inf) { + return inf.param; }); #endif // GTEST_LANG_CXX11 @@ -1019,6 +1064,7 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) { INSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5)); + int main(int argc, char **argv) { // Used in TestGenerationTest test case. AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance()); |