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

Side by Side Diff: chrome/installer/setup/memory_unittest.cc

Issue 1548153002: Switch to standard integer types in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cstddef> 5 #include <stddef.h>
6
6 #include <limits> 7 #include <limits>
7 8
8 #include "base/process/memory.h" 9 #include "base/process/memory.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 #if defined(ALLOCATOR_SHIM) 12 #if defined(ALLOCATOR_SHIM)
12 // Test that the allocator shim is in-place so that base::UncheckedMalloc works. 13 // Test that the allocator shim is in-place so that base::UncheckedMalloc works.
13 TEST(OutOfMemoryHandledTest, UncheckedMalloc) { 14 TEST(OutOfMemoryHandledTest, UncheckedMalloc) {
14 // Enable termination on OOM - just as setup.exe does at early initialization 15 // Enable termination on OOM - just as setup.exe does at early initialization
15 // - and test that UncheckedMalloc properly by-passes this in order to allow 16 // - and test that UncheckedMalloc properly by-passes this in order to allow
16 // the caller to handle OOM. 17 // the caller to handle OOM.
17 base::EnableTerminationOnOutOfMemory(); 18 base::EnableTerminationOnOutOfMemory();
18 19
19 const size_t kSafeMallocSize = 512; 20 const size_t kSafeMallocSize = 512;
20 21
21 void* value = nullptr; 22 void* value = nullptr;
22 EXPECT_TRUE(base::UncheckedMalloc(kSafeMallocSize, &value)); 23 EXPECT_TRUE(base::UncheckedMalloc(kSafeMallocSize, &value));
23 EXPECT_NE(nullptr, value); 24 EXPECT_NE(nullptr, value);
24 free(value); 25 free(value);
25 26
26 // Make test size as large as possible minus a few pages so that alignment or 27 // Make test size as large as possible minus a few pages so that alignment or
27 // other rounding doesn't make it wrap. 28 // other rounding doesn't make it wrap.
28 const size_t kUnsafeMallocSize( 29 const size_t kUnsafeMallocSize(
29 std::numeric_limits<std::size_t>::max() - 12 * 1024); 30 std::numeric_limits<std::size_t>::max() - 12 * 1024);
30 31
31 EXPECT_FALSE(base::UncheckedMalloc(kUnsafeMallocSize, &value)); 32 EXPECT_FALSE(base::UncheckedMalloc(kUnsafeMallocSize, &value));
32 EXPECT_EQ(nullptr, value); 33 EXPECT_EQ(nullptr, value);
33 } 34 }
34 #endif // ALLOCATOR_SHIM 35 #endif // ALLOCATOR_SHIM
OLDNEW
« no previous file with comments | « chrome/installer/setup/installer_crash_reporting.h ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698