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 306f3754a7
. Perhaps those previous changes did not consider
test code.
PiperOrigin-RevId: 307495126
This commit is contained in:
parent
fb5d9b66c5
commit
1b3eb6ef34
@ -190,11 +190,10 @@ GTEST_API_ bool InDeathTestChild();
|
||||
class GTEST_API_ ExitedWithCode {
|
||||
public:
|
||||
explicit ExitedWithCode(int exit_code);
|
||||
ExitedWithCode(const ExitedWithCode&) = default;
|
||||
void operator=(const ExitedWithCode& other) = delete;
|
||||
bool operator()(int exit_status) const;
|
||||
private:
|
||||
// No implementation - assignment is unsupported.
|
||||
void operator=(const ExitedWithCode& other);
|
||||
|
||||
const int exit_code_;
|
||||
};
|
||||
|
||||
|
@ -490,16 +490,16 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) {
|
||||
class NonDefaultConstructAssignString {
|
||||
public:
|
||||
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_; }
|
||||
|
||||
private:
|
||||
std::string str_;
|
||||
|
||||
// Not default constructible
|
||||
NonDefaultConstructAssignString();
|
||||
// Not assignable
|
||||
void operator=(const NonDefaultConstructAssignString&);
|
||||
};
|
||||
|
||||
TEST(CombineTest, NonDefaultConstructAssign) {
|
||||
|
Loading…
Reference in New Issue
Block a user