Skip to content

Commit

Permalink
Add new make shared test
Browse files Browse the repository at this point in the history
  • Loading branch information
flarembo committed Sep 17, 2024
1 parent 335149e commit 5a308f6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/shared-ptr-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,3 +509,25 @@ TEST_F(shared_ptr_test, equivalence_nullptr) {
EXPECT_TRUE(nullptr == p);
EXPECT_FALSE(nullptr != p);
}

TEST_F(shared_ptr_test, efficient_make_shared) {
struct not_movable_and_copyable_class {
public:
not_movable_and_copyable_class(int a, bool b, double d)
: a(a)
, b(b)
, d(d) {}

not_movable_and_copyable_class(const not_movable_and_copyable_class& other) = delete;
not_movable_and_copyable_class(not_movable_and_copyable_class&& other) = delete;
not_movable_and_copyable_class& operator=(const not_movable_and_copyable_class& other) = delete;
not_movable_and_copyable_class& operator=(not_movable_and_copyable_class&& other) = delete;

private:
int a;
bool b;
double d;
};

[[maybe_unused]] auto p = make_shared<not_movable_and_copyable_class>(2, true, 0.0);
}

0 comments on commit 5a308f6

Please sign in to comment.