summaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/ref_counted/ref_counted_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'vespalib/src/tests/ref_counted/ref_counted_test.cpp')
-rw-r--r--vespalib/src/tests/ref_counted/ref_counted_test.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/vespalib/src/tests/ref_counted/ref_counted_test.cpp b/vespalib/src/tests/ref_counted/ref_counted_test.cpp
index 751d5b7c506..046823a9ebc 100644
--- a/vespalib/src/tests/ref_counted/ref_counted_test.cpp
+++ b/vespalib/src/tests/ref_counted/ref_counted_test.cpp
@@ -183,12 +183,24 @@ TEST(RefCountedTest, copy_ref_counted) {
}
}
+struct Other : enable_ref_counted {};
+
TEST(RefCountedTest, compile_errors_when_uncommented) {
struct Foo {};
[[maybe_unused]] Foo foo;
+ [[maybe_unused]] ref_counted<Other> other = make_ref_counted<Other>();
// ref_counted<Foo> empty;
// auto ref1 = make_ref_counted<Foo>();
// auto ref2 = ref_counted_from(foo);
+ // ref_counted<Base> base = other;
+}
+
+TEST(RefCountedTest, self_assign) {
+ ref_counted<Leaf> ref = make_ref_counted<Leaf>(10);
+ ref = ref;
+ ref = std::move(ref);
+ EXPECT_EQ(ref->count_refs(), 1);
+ EXPECT_EQ(ref->val, 10);
}
TEST(RefCountedTest, with_threads) {