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

Unified Diff: base/memory/aligned_memory_unittest.cc

Issue 10796020: Upgrade AlignedMemory to support dynamic allocations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change AlignedMemory back to POD. Retry now that NaCl fixed. Created 8 years, 5 months 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 | « base/memory/aligned_memory.cc ('k') | chrome/browser/history/android/android_urls_sql_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/aligned_memory_unittest.cc
diff --git a/base/memory/aligned_memory_unittest.cc b/base/memory/aligned_memory_unittest.cc
index 8c1eb61b67b29501173d02dec70f58c7287998e0..c337751630cce87de322bb9c96de3afa0d2bbe15 100644
--- a/base/memory/aligned_memory_unittest.cc
+++ b/base/memory/aligned_memory_unittest.cc
@@ -51,4 +51,33 @@ TEST(AlignedMemoryTest, StackAlignment) {
#endif // !(defined(OS_IOS) && defined(ARCH_CPU_ARM_FAMILY))
}
+TEST(AlignedMemoryTest, DynamicAllocation) {
+ void* p = base::AlignedAlloc(8, 8);
+ EXPECT_TRUE(p);
+ EXPECT_ALIGNED(p, 8);
+ base::AlignedFree(p);
+
+ p = base::AlignedAlloc(8, 16);
+ EXPECT_TRUE(p);
+ EXPECT_ALIGNED(p, 16);
+ base::AlignedFree(p);
+
+ p = base::AlignedAlloc(8, 256);
+ EXPECT_TRUE(p);
+ EXPECT_ALIGNED(p, 256);
+ base::AlignedFree(p);
+
+ p = base::AlignedAlloc(8, 4096);
+ EXPECT_TRUE(p);
+ EXPECT_ALIGNED(p, 4096);
+ base::AlignedFree(p);
+}
+
+TEST(AlignedMemoryTest, ScopedDynamicAllocation) {
+ scoped_ptr_malloc<float, base::ScopedPtrAlignedFree> p(
+ static_cast<float*>(base::AlignedAlloc(8, 8)));
+ EXPECT_TRUE(p.get());
+ EXPECT_ALIGNED(p.get(), 8);
+}
+
} // namespace
« no previous file with comments | « base/memory/aligned_memory.cc ('k') | chrome/browser/history/android/android_urls_sql_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698