forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrake_copyable_test.cc
41 lines (34 loc) · 1.06 KB
/
drake_copyable_test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "drake/common/drake_copyable.h"
#include <gtest/gtest.h>
namespace drake {
namespace {
// When a class has a user-defined destructor, the implicit generation of the
// copy constructor and copy-assignment operator is deprecated as of C++11.
//
// Under Drake's Clang configuration, relying on the deprecated operator
// produces an error under -Werror=deprecated.
//
// Therefore, if DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN failed to default those
// operations, then this unit test would no longer compile (under Clang).
class Example {
public:
DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Example);
Example() = default;
~Example() {}
};
GTEST_TEST(DrakeCopyableTest, CopyConstruct) {
Example foo;
Example bar(foo);
}
GTEST_TEST(DrakeCopyableTest, CopyAssign) {
Example foo, bar;
bar = foo;
}
// Confirm that private (and by association, protected) access for this macro
// is permitted. If not, this class would fail to compile.
class ExamplePrivate {
private:
DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(ExamplePrivate);
};
} // namespace
} // namespace drake