From dfd7d48ced44026aafca71ecb5f0138af8125b94 Mon Sep 17 00:00:00 2001 From: mtklein Date: Mon, 23 Nov 2015 09:19:37 -0800 Subject: Revert of skstd -> std for unique_ptr (patchset #16 id:300001 of https://codereview.chromium.org/1436033003/ ) Reason for revert: Perf-Mac10.9-Clang-MacMini6.2-CPU-AVX-x86_64-Release has not updated yet. Original issue's description: > skstd -> std for unique_ptr > > TBR=reed@google.com > No public API changes. > > BUG=skia:4564 > > Committed: https://skia.googlesource.com/skia/+/755c553c17b82bb5de3d9cc8d3b2a866ff9e9e50 > > CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Mac10.9-Clang-x86_64-Release-CMake-Trybot,Build-Ubuntu-GCC-x86_64-Debug-CrOS_Link-Trybot > > Committed: https://skia.googlesource.com/skia/+/06189155d987db5c7e69015f6ea87c2168d6a065 TBR=bungeman@google.com,mtklein@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:4564 Review URL: https://codereview.chromium.org/1467333002 --- tests/CPlusPlusEleven.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'tests') diff --git a/tests/CPlusPlusEleven.cpp b/tests/CPlusPlusEleven.cpp index f7d194a450..5c2123dc47 100644 --- a/tests/CPlusPlusEleven.cpp +++ b/tests/CPlusPlusEleven.cpp @@ -27,3 +27,72 @@ DEF_TEST(CPlusPlusEleven_RvalueAndMove, r) { Moveable src1; Moveable dst1(skstd::move(src1)); Moveable src2, dst2; dst2 = skstd::move(src2); } + +#define TOO_BIG "The unique_ptr was bigger than expected." +#define WEIRD_SIZE "The unique_ptr was a different size than expected." + +DEF_TEST(CPlusPlusEleven_UniquePtr, r) { + struct SmallUniquePtr { + Moveable* p; + }; + struct BigUniquePtr { + void(*d)(Moveable*); + Moveable* p; + }; + + static_assert(sizeof(skstd::unique_ptr) == sizeof(SmallUniquePtr), TOO_BIG); + static_assert(sizeof(skstd::unique_ptr) == sizeof(SmallUniquePtr), TOO_BIG); + + using proc = void(*)(Moveable*); + static_assert(sizeof(skstd::unique_ptr) == sizeof(BigUniquePtr), WEIRD_SIZE); + static_assert(sizeof(skstd::unique_ptr) == sizeof(BigUniquePtr), WEIRD_SIZE); + + { + skstd::unique_ptr u(nullptr, deleter); + static_assert(sizeof(u) == sizeof(BigUniquePtr), WEIRD_SIZE); + + auto u2 = skstd::move(u); + static_assert(sizeof(u2) == sizeof(BigUniquePtr), WEIRD_SIZE); + } + + { + skstd::unique_ptr u(nullptr, [](Moveable* m){ deleter(m); }); + static_assert(sizeof(u) == sizeof(BigUniquePtr), WEIRD_SIZE); + + auto u2 = skstd::move(u); + static_assert(sizeof(u2) == sizeof(BigUniquePtr), WEIRD_SIZE); + } + + { + auto d = [](Moveable* m){ deleter(m); }; + skstd::unique_ptr u(nullptr, d); + static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG); + + auto u2 = skstd::move(u); + static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG); + } + + { + skstd::unique_ptr> u(nullptr, Deleter()); + static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG); + + auto u2 = skstd::move(u); + static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG); + } + + { + skstd::unique_ptr> u(new Moveable(), Deleter()); + static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG); + + auto u2 = skstd::move(u); + static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG); + } + + { + skstd::unique_ptr> u(new Moveable(), Deleter()); + static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG); + + auto u2 = skstd::move(u); + static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG); + } +} -- cgit v1.2.3