diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-07-22 17:08:36 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-07-22 17:08:36 +0100 |
commit | fd044f4cf02a5cad4d023af5df375d1f124e31bd (patch) | |
tree | c4c978b8f72407dfdfc08598a45a8d86273b98ab /test | |
parent | 0fdc9465534a3a146a7a880798a0002ff5a86861 (diff) | |
download | rspamd-fd044f4cf02a5cad4d023af5df375d1f124e31bd.tar.gz rspamd-fd044f4cf02a5cad4d023af5df375d1f124e31bd.zip |
[Minor] Enable make_shared like behaviour
Diffstat (limited to 'test')
-rw-r--r-- | test/rspamd_cxx_unit_utils.hxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/rspamd_cxx_unit_utils.hxx b/test/rspamd_cxx_unit_utils.hxx index a6cbc3a32..be5d193f4 100644 --- a/test/rspamd_cxx_unit_utils.hxx +++ b/test/rspamd_cxx_unit_utils.hxx @@ -206,6 +206,36 @@ TEST_CASE("shared_ptr dtor") { CHECK(t == true); } +TEST_CASE("make_shared dtor") { + bool t; + + { + auto pi = rspamd::local_make_shared<deleter_test>(t); + + CHECK((!pi ? false : true)); + CHECK(!!pi); + CHECK(pi.get() != nullptr); + CHECK(pi.use_count() == 1); + CHECK(pi.unique()); + CHECK(t == false); + + rspamd::local_shared_ptr<deleter_test> pi2(pi); + CHECK(pi2 == pi); + CHECK(pi.use_count() == 2); + pi.reset(); + CHECK(!(pi2 == pi)); + CHECK(pi2.use_count() == 1); + CHECK(t == false); + + pi = pi2; + CHECK(pi2 == pi); + CHECK(pi.use_count() == 2); + CHECK(t == false); + } + + CHECK(t == true); +} + } #endif |