Commit 13fe006d authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

[base] Add NoDestructor test for non-copyable and non-movable type

Change-Id: Ie8e9b9ebd7ada8cce06f6500196ea950efd01201
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2506617
Auto-Submit: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822064}
parent 45f84335
......@@ -31,6 +31,16 @@ TEST(NoDestructorTest, SkipsDestructors) {
NoDestructor<CheckOnDestroy> destructor_should_not_run;
}
struct UncopyableUnmovable {
UncopyableUnmovable() = default;
explicit UncopyableUnmovable(int value) : value(value) {}
UncopyableUnmovable(const UncopyableUnmovable&) = delete;
UncopyableUnmovable& operator=(const UncopyableUnmovable&) = delete;
int value = 1;
};
struct CopyOnly {
CopyOnly() = default;
......@@ -55,6 +65,14 @@ struct ForwardingTestStruct {
ForwardingTestStruct(const CopyOnly&, MoveOnly&&) {}
};
TEST(NoDestructorTest, UncopyableUnmovable) {
static NoDestructor<UncopyableUnmovable> default_constructed;
EXPECT_EQ(1, default_constructed->value);
static NoDestructor<UncopyableUnmovable> constructed_with_arg(-1);
EXPECT_EQ(-1, constructed_with_arg->value);
}
TEST(NoDestructorTest, ForwardsArguments) {
CopyOnly copy_only;
MoveOnly move_only;
......
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