summaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/ref_counted
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@yahooinc.com>2023-03-03 12:10:21 +0000
committerHåvard Pettersen <havardpe@yahooinc.com>2023-03-03 12:10:21 +0000
commita738e084e5826ca3a4c420b1790330d94ce7147f (patch)
tree836339ade5160a86a6d8547cee0c52918e24d789 /vespalib/src/tests/ref_counted
parent33ef2342e8369f471305c5cc63c61599d05b9705 (diff)
fixup after review
Diffstat (limited to 'vespalib/src/tests/ref_counted')
-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) {