Commit 1b3eb6ef by Abseil Team Committed by Gennadiy Rozental

Googletest export

Explicitly define copy constructors used in googletest tests As of C++11, providing a user-declared copy assignment operator should suppress the availability of an implicit default copy constructor. Classes that provide (or delete) a copy assignment operator must provide their own copy constructor if one is desired. This may be an explicit default copy constructor if appropriate. As googletest is a C++11 codebase, this change should be made without qualification. This addresses the -Wdeprecated-copy warnings issued by trunk clang: While compiling googletest/test/googletest-death-test-test.cc: In file included from .../googletest/test/googletest-death-test-test.cc:33: .../googletest/include/gtest/gtest-death-test.h:196:8: error: definition of implicit copy constructor for 'ExitedWithCode' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy] void operator=(const ExitedWithCode& other); ^ .../googletest/test/googletest-death-test-test.cc:279:16: note: in implicit copy constructor for 'testing::ExitedWithCode' first required here EXPECT_PRED1(pred0, status0); ^ While compiling googletest/test/googletest-param-test-test.cc: .../googletest/test/googletest-param-test-test.cc:502:8: error: definition of implicit copy constructor for 'NonDefaultConstructAssignString' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy] void operator=(const NonDefaultConstructAssignString&); ^ .../googletest/test/googletest-param-test-test.cc:507:36: note: in implicit copy constructor for 'NonDefaultConstructAssignString' first required here Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"), This matches other changes made elsewhere in the googletest codebase, such as 306f3754. Perhaps those previous changes did not consider test code. PiperOrigin-RevId: 307495126
parent fb5d9b66
...@@ -190,11 +190,10 @@ GTEST_API_ bool InDeathTestChild(); ...@@ -190,11 +190,10 @@ GTEST_API_ bool InDeathTestChild();
class GTEST_API_ ExitedWithCode { class GTEST_API_ ExitedWithCode {
public: public:
explicit ExitedWithCode(int exit_code); explicit ExitedWithCode(int exit_code);
ExitedWithCode(const ExitedWithCode&) = default;
void operator=(const ExitedWithCode& other) = delete;
bool operator()(int exit_status) const; bool operator()(int exit_status) const;
private: private:
// No implementation - assignment is unsupported.
void operator=(const ExitedWithCode& other);
const int exit_code_; const int exit_code_;
}; };
......
...@@ -490,16 +490,16 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) { ...@@ -490,16 +490,16 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) {
class NonDefaultConstructAssignString { class NonDefaultConstructAssignString {
public: public:
NonDefaultConstructAssignString(const std::string& s) : str_(s) {} NonDefaultConstructAssignString(const std::string& s) : str_(s) {}
NonDefaultConstructAssignString(const NonDefaultConstructAssignString&) =
default;
NonDefaultConstructAssignString() = delete;
void operator=(const NonDefaultConstructAssignString&) = delete;
const std::string& str() const { return str_; } const std::string& str() const { return str_; }
private: private:
std::string str_; std::string str_;
// Not default constructible
NonDefaultConstructAssignString();
// Not assignable
void operator=(const NonDefaultConstructAssignString&);
}; };
TEST(CombineTest, NonDefaultConstructAssign) { TEST(CombineTest, NonDefaultConstructAssign) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment