From 225e6741acfaa38375589dafcc84254a92313dac Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 12 Feb 2018 16:42:12 -0500 Subject: [PATCH 01/10] moving JoinAsTuple to internal --- googlemock/include/gmock/gmock-matchers.h | 4 ---- googlemock/src/gmock-internal-utils.cc | 19 +++++++++++++++ googlemock/src/gmock-matchers.cc | 19 --------------- googlemock/test/gmock-matchers_test.cc | 29 +++-------------------- 4 files changed, 22 insertions(+), 49 deletions(-) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 94c23d38..fc3fe3aa 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -3614,10 +3614,6 @@ BoundSecondMatcher MatcherBindSecond( return BoundSecondMatcher(tm, second); } -// Joins a vector of strings as if they are fields of a tuple; returns -// the joined string. This function is exported for testing. -GTEST_API_ string JoinAsTuple(const Strings& fields); - // Returns the description for a matcher defined using the MATCHER*() // macro where the user-supplied description string is "", if // 'negation' is false; otherwise returns the description of the diff --git a/googlemock/src/gmock-internal-utils.cc b/googlemock/src/gmock-internal-utils.cc index 91bf3fd9..658fa62d 100644 --- a/googlemock/src/gmock-internal-utils.cc +++ b/googlemock/src/gmock-internal-utils.cc @@ -47,6 +47,25 @@ namespace testing { namespace internal { +// Joins a vector of strings as if they are fields of a tuple; returns +// the joined string. +GTEST_API_ std::string JoinAsTuple(const Strings& fields) { + switch (fields.size()) { + case 0: + return ""; + case 1: + return fields[0]; + default: + std::string result = "(" + fields[0]; + for (size_t i = 1; i < fields.size(); i++) { + result += ", "; + result += fields[i]; + } + result += ")"; + return result; + } +} + // Converts an identifier name to a space-separated list of lower-case // words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is // treated as one word. For example, both "FooBar123" and diff --git a/googlemock/src/gmock-matchers.cc b/googlemock/src/gmock-matchers.cc index 6e40e5e8..f37d5c2d 100644 --- a/googlemock/src/gmock-matchers.cc +++ b/googlemock/src/gmock-matchers.cc @@ -100,25 +100,6 @@ Matcher::Matcher(StringPiece s) { namespace internal { -// Joins a vector of strings as if they are fields of a tuple; returns -// the joined string. -GTEST_API_ string JoinAsTuple(const Strings& fields) { - switch (fields.size()) { - case 0: - return ""; - case 1: - return fields[0]; - default: - string result = "(" + fields[0]; - for (size_t i = 1; i < fields.size(); i++) { - result += ", "; - result += fields[i]; - } - result += ")"; - return result; - } -} - // Returns the description for a matcher defined using the MATCHER*() // macro where the user-supplied description string is "", if // 'negation' is false; otherwise returns the description of the diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index 07e5fa63..761c0c22 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -146,7 +146,6 @@ using testing::internal::ExplainMatchFailureTupleTo; using testing::internal::FloatingEqMatcher; using testing::internal::FormatMatcherDescription; using testing::internal::IsReadableTypeName; -using testing::internal::JoinAsTuple; using testing::internal::linked_ptr; using testing::internal::MatchMatrix; using testing::internal::RE; @@ -872,9 +871,9 @@ class Unprintable { char c_; }; -inline bool operator==(const Unprintable& /* lhs */, - const Unprintable& /* rhs */) { - return true; +inline bool operator==(const Unprintable& /* lhs */, + const Unprintable& /* rhs */) { + return true; } TEST(EqTest, CanDescribeSelf) { @@ -5268,28 +5267,6 @@ TEST(IsReadableTypeNameTest, ReturnsFalseForLongFunctionTypeNames) { EXPECT_FALSE(IsReadableTypeName("void (&)(int, bool, char, float)")); } -// Tests JoinAsTuple(). - -TEST(JoinAsTupleTest, JoinsEmptyTuple) { - EXPECT_EQ("", JoinAsTuple(Strings())); -} - -TEST(JoinAsTupleTest, JoinsOneTuple) { - const char* fields[] = {"1"}; - EXPECT_EQ("1", JoinAsTuple(Strings(fields, fields + 1))); -} - -TEST(JoinAsTupleTest, JoinsTwoTuple) { - const char* fields[] = {"1", "a"}; - EXPECT_EQ("(1, a)", JoinAsTuple(Strings(fields, fields + 2))); -} - -TEST(JoinAsTupleTest, JoinsTenTuple) { - const char* fields[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}; - EXPECT_EQ("(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)", - JoinAsTuple(Strings(fields, fields + 10))); -} - // Tests FormatMatcherDescription(). TEST(FormatMatcherDescriptionTest, WorksForEmptyDescription) { From 9e072812e3023f8c45593052965998d6646b5e78 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Tue, 13 Feb 2018 09:45:12 -0500 Subject: [PATCH 02/10] merges --- googletest/test/gtest-param-test_test.cc | 49 ++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index b0aa4f9b..60bdfea0 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -41,8 +41,8 @@ # include # include # include -# 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,48 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) { VerifyGenerator(gen, expected_values); } +class NonDefaultConstructAssignString { + public: + NonDefaultConstructAssignString(const std::string& str) : str_(str) {} + + 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> gen = + Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"), + NonDefaultConstructAssignString("B"))); + + ParamGenerator>::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_HAS_COMBINE // Tests that an generator produces correct sequence after being @@ -851,8 +893,8 @@ TEST_P(CustomLambdaNamingTest, CustomTestNames) {} INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, CustomLambdaNamingTest, Values(std::string("LambdaName")), - [](const ::testing::TestParamInfo& tpinfo) { - return tpinfo.param; + [](const ::testing::TestParamInfo& info) { + return info.param; }); #endif // GTEST_LANG_CXX11 @@ -1019,6 +1061,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()); From e76f4ee9fd1693429146dc62b27f72a1cb38b2ff Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Tue, 13 Feb 2018 10:05:43 -0500 Subject: [PATCH 03/10] clang warning https://travis-ci.org/google/googletest/jobs/340978022 --- googletest/test/gtest-param-test_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index 60bdfea0..11ad853c 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -538,7 +538,7 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) { class NonDefaultConstructAssignString { public: - NonDefaultConstructAssignString(const std::string& str) : str_(str) {} + NonDefaultConstructAssignString(const std::string& s) : str_(s) {} const std::string& str() const { return str_; } From a66d209061ebdcf81ed93c1dd0336944514fd1df Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Tue, 13 Feb 2018 10:23:42 -0500 Subject: [PATCH 04/10] clang warning 'https://travis-ci.org/google/googletest/jobs/340987201' --- googletest/test/gtest-param-test_test.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index 11ad853c..6e62dfa2 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -853,8 +853,8 @@ class CustomFunctorNamingTest : public TestWithParam {}; TEST_P(CustomFunctorNamingTest, CustomTestNames) {} struct CustomParamNameFunctor { - std::string operator()(const ::testing::TestParamInfo& info) { - return info.param; + std::string operator()(const ::testing::TestParamInfo& inf) { + return inf.param; } }; @@ -893,8 +893,8 @@ TEST_P(CustomLambdaNamingTest, CustomTestNames) {} INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, CustomLambdaNamingTest, Values(std::string("LambdaName")), - [](const ::testing::TestParamInfo& info) { - return info.param; + [](const ::testing::TestParamInfo& inf) { + return inf.param; }); #endif // GTEST_LANG_CXX11 From 2a23ca00092bbb9c31d7a7b6fa9519bf2d8c70c7 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Tue, 13 Feb 2018 11:05:01 -0500 Subject: [PATCH 05/10] https://travis-ci.org/google/googletest/jobs/340995238 --- googletest/test/gtest-param-test_test.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index 6e62dfa2..9d970d2e 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -556,7 +556,7 @@ TEST(CombineTest, NonDefaultConstructAssign) { Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"), NonDefaultConstructAssignString("B"))); - ParamGenerator>::iterator it = + ParamGenerator >::iterator it = gen.begin(); EXPECT_EQ(0, std::get<0>(*it)); @@ -871,8 +871,8 @@ INSTANTIATE_TEST_CASE_P(AllAllowedCharacters, CustomParamNameFunctor()); inline std::string CustomParamNameFunction( - const ::testing::TestParamInfo& info) { - return info.param; + const ::testing::TestParamInfo& inf) { + return inf.param; } class CustomFunctionNamingTest : public TestWithParam {}; @@ -893,8 +893,8 @@ TEST_P(CustomLambdaNamingTest, CustomTestNames) {} INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, CustomLambdaNamingTest, Values(std::string("LambdaName")), - [](const ::testing::TestParamInfo& inf) { - return inf.param; + [](const ::testing::TestParamInfo& info) { + return info.param; }); #endif // GTEST_LANG_CXX11 From d7c966c4defea40b5f161999e2a6dab9cca9d540 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Tue, 13 Feb 2018 11:15:03 -0500 Subject: [PATCH 06/10] clang warnings --- googletest/test/gtest-param-test_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index 9d970d2e..5f6d946b 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -893,8 +893,8 @@ TEST_P(CustomLambdaNamingTest, CustomTestNames) {} INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, CustomLambdaNamingTest, Values(std::string("LambdaName")), - [](const ::testing::TestParamInfo& info) { - return info.param; + [](const ::testing::TestParamInfo& inf) { + return inf.param; }); #endif // GTEST_LANG_CXX11 From 3b1fe3ec45276c58aac6522dc009a2e8f193d996 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Tue, 13 Feb 2018 11:24:09 -0500 Subject: [PATCH 07/10] clang warnings --- googletest/test/gtest-param-test_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index 5f6d946b..0236e878 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -552,7 +552,7 @@ class NonDefaultConstructAssignString { }; TEST(CombineTest, NonDefaultConstructAssign) { - const ParamGenerator> gen = + const ParamGenerator > gen = Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"), NonDefaultConstructAssignString("B"))); From 30d276da03468d08bcde1820b6b9ed17e9fffbe6 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Tue, 13 Feb 2018 11:48:32 -0500 Subject: [PATCH 08/10] cxxx11 --- googletest/test/gtest-param-test_test.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index 0236e878..fb2e44b0 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -536,6 +536,8 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) { VerifyGenerator(gen, expected_values); } +#if GTEST_LANG_CXX11 + class NonDefaultConstructAssignString { public: NonDefaultConstructAssignString(const std::string& s) : str_(s) {} @@ -578,6 +580,7 @@ TEST(CombineTest, NonDefaultConstructAssign) { EXPECT_TRUE(it == gen.end()); } +#endif // GTEST_LANG_CXX11 # endif // GTEST_HAS_COMBINE // Tests that an generator produces correct sequence after being From ab186a8c49a2939cd99565da009ae5c6230b3246 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Tue, 13 Feb 2018 13:49:57 -0500 Subject: [PATCH 09/10] merges --- googletest/test/gtest-param-test_test.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index fb2e44b0..b21cb31f 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -893,8 +893,7 @@ INSTANTIATE_TEST_CASE_P(CustomParamNameFunction, class CustomLambdaNamingTest : public TestWithParam {}; TEST_P(CustomLambdaNamingTest, CustomTestNames) {} -INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, - CustomLambdaNamingTest, +INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, CustomLambdaNamingTest, Values(std::string("LambdaName")), [](const ::testing::TestParamInfo& inf) { return inf.param; From 069724197c03e56c0197b80ace8b97187d27c45d Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Tue, 13 Feb 2018 14:13:52 -0500 Subject: [PATCH 10/10] merging, cleaning up --- googletest/test/gtest_all_test.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/googletest/test/gtest_all_test.cc b/googletest/test/gtest_all_test.cc index 955aa628..e16ef539 100644 --- a/googletest/test/gtest_all_test.cc +++ b/googletest/test/gtest_all_test.cc @@ -33,15 +33,15 @@ // // Sometimes it's desirable to build most of Google Test's own tests // by compiling a single file. This file serves this purpose. -#include "test/gtest-filepath_test.cc" -#include "test/gtest-linked_ptr_test.cc" -#include "test/gtest-message_test.cc" -#include "test/gtest-options_test.cc" -#include "test/gtest-port_test.cc" -#include "test/gtest_pred_impl_unittest.cc" -#include "test/gtest_prod_test.cc" -#include "test/gtest-test-part_test.cc" -#include "test/gtest-typed-test_test.cc" -#include "test/gtest-typed-test2_test.cc" -#include "test/gtest_unittest.cc" -#include "test/production.cc" +#include "gtest-filepath_test.cc" +#include "gtest-linked_ptr_test.cc" +#include "gtest-message_test.cc" +#include "gtest-options_test.cc" +#include "gtest-port_test.cc" +#include "gtest_pred_impl_unittest.cc" +#include "gtest_prod_test.cc" +#include "gtest-test-part_test.cc" +#include "gtest-typed-test_test.cc" +#include "gtest-typed-test2_test.cc" +#include "gtest_unittest.cc" +#include "production.cc"