From bff55335d5e96ba1df2d81709b3f6d2520a6f178 Mon Sep 17 00:00:00 2001 From: erestor Date: Fri, 17 May 2024 11:35:34 +0300 Subject: [PATCH 1/2] add test for NotCopyable type. Because submission https://admin.contest.yandex.ru/submissions/114107819 passes --- tasks/tests/deque_test.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tasks/tests/deque_test.cpp b/tasks/tests/deque_test.cpp index 04860e2..c6909f8 100644 --- a/tasks/tests/deque_test.cpp +++ b/tasks/tests/deque_test.cpp @@ -212,7 +212,16 @@ struct NotDefaultConstructible { int x = 0; }; +struct NotCopyable { + NotCopyable() = default; + NotCopyable(const NotCopyable&) = delete; +}; + void test6() { + { + Deque deq(10); + } + Deque d; NotDefaultConstructible ndc = VerySpecialType(-1); From 5dc208489d90e33bd50594ed88641f174db79864 Mon Sep 17 00:00:00 2001 From: erestor Date: Sun, 19 May 2024 13:15:27 +0300 Subject: [PATCH 2/2] add tests for nullptr checking and move ctors --- tasks/tests/smartpointers_test.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tasks/tests/smartpointers_test.cpp b/tasks/tests/smartpointers_test.cpp index ca57b6b..67b9701 100644 --- a/tasks/tests/smartpointers_test.cpp +++ b/tasks/tests/smartpointers_test.cpp @@ -36,6 +36,22 @@ struct Derived: public Base {}; void test_shared_ptr() { + { + auto empty = SharedPtr(); + SharedPtr ptr = empty; + auto empty2 = SharedPtr(); + auto ptr2 = empty2; + std::ignore = ptr2; + } + + { + auto ptr = makeShared(1); + auto ptr2 = std::move(ptr); + // test nullptr checking presence + assert(ptr.use_count() == 0); + auto wptr = WeakPtr(ptr); + assert(wptr.expired()); + } using std::vector;