Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1153)

Unified Diff: tests/CPlusPlusEleven.cpp

Issue 1482343002: Revert of skstd -> std for unique_ptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkSharedMutex.h ('k') | tools/BUILD.public.expected » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CPlusPlusEleven.cpp
diff --git a/tests/CPlusPlusEleven.cpp b/tests/CPlusPlusEleven.cpp
index f7d194a450e1269fb5bba482f1dd77178e9b9f10..5c2123dc472780b815b771b34c2f44b711d9a5ae 100644
--- a/tests/CPlusPlusEleven.cpp
+++ b/tests/CPlusPlusEleven.cpp
@@ -27,3 +27,72 @@
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<Moveable>) == sizeof(SmallUniquePtr), TOO_BIG);
+ static_assert(sizeof(skstd::unique_ptr<Moveable[]>) == sizeof(SmallUniquePtr), TOO_BIG);
+
+ using proc = void(*)(Moveable*);
+ static_assert(sizeof(skstd::unique_ptr<Moveable, proc>) == sizeof(BigUniquePtr), WEIRD_SIZE);
+ static_assert(sizeof(skstd::unique_ptr<Moveable[], proc>) == sizeof(BigUniquePtr), WEIRD_SIZE);
+
+ {
+ skstd::unique_ptr<Moveable, void(*)(Moveable*)> u(nullptr, deleter<Moveable>);
+ static_assert(sizeof(u) == sizeof(BigUniquePtr), WEIRD_SIZE);
+
+ auto u2 = skstd::move(u);
+ static_assert(sizeof(u2) == sizeof(BigUniquePtr), WEIRD_SIZE);
+ }
+
+ {
+ skstd::unique_ptr<Moveable, void(*)(Moveable*)> 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<Moveable, decltype(d)> 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<Moveable, Deleter<Moveable>> u(nullptr, Deleter<Moveable>());
+ static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG);
+
+ auto u2 = skstd::move(u);
+ static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG);
+ }
+
+ {
+ skstd::unique_ptr<Moveable, Deleter<Moveable>> u(new Moveable(), Deleter<Moveable>());
+ static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG);
+
+ auto u2 = skstd::move(u);
+ static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG);
+ }
+
+ {
+ skstd::unique_ptr<const void, Deleter<const void>> u(new Moveable(), Deleter<const void>());
+ static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG);
+
+ auto u2 = skstd::move(u);
+ static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG);
+ }
+}
« no previous file with comments | « src/core/SkSharedMutex.h ('k') | tools/BUILD.public.expected » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698