| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "base/allocator/malloc_zone_functions_mac.h" | 5 #include "base/allocator/malloc_zone_functions_mac.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 namespace base { | 8 namespace base { |
| 9 namespace allocator { | 9 namespace allocator { |
| 10 | 10 |
| 11 class MallocZoneFunctionsTest : public testing::Test { | 11 class MallocZoneFunctionsTest : public testing::Test { |
| 12 protected: | 12 protected: |
| 13 void SetUp() override { ClearAllMallocZonesForTesting(); } | 13 void TearDown() override { ClearAllMallocZonesForTesting(); } |
| 14 }; | 14 }; |
| 15 | 15 |
| 16 TEST_F(MallocZoneFunctionsTest, TestDefaultZoneMallocFree) { | 16 TEST_F(MallocZoneFunctionsTest, TestDefaultZoneMallocFree) { |
| 17 ChromeMallocZone* malloc_zone = | 17 ChromeMallocZone* malloc_zone = |
| 18 reinterpret_cast<ChromeMallocZone*>(malloc_default_zone()); | 18 reinterpret_cast<ChromeMallocZone*>(malloc_default_zone()); |
| 19 StoreMallocZone(malloc_zone); | 19 StoreMallocZone(malloc_zone); |
| 20 int* test = reinterpret_cast<int*>( | 20 int* test = reinterpret_cast<int*>( |
| 21 g_malloc_zones[0].malloc(malloc_default_zone(), 33)); | 21 g_malloc_zones[0].malloc(malloc_default_zone(), 33)); |
| 22 test[0] = 1; | 22 test[0] = 1; |
| 23 test[1] = 2; | 23 test[1] = 2; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 48 memcpy(&zone, malloc_default_zone(), sizeof(ChromeMallocZone)); | 48 memcpy(&zone, malloc_default_zone(), sizeof(ChromeMallocZone)); |
| 49 StoreMallocZone(&zone); | 49 StoreMallocZone(&zone); |
| 50 } | 50 } |
| 51 | 51 |
| 52 int max_zone_count = kMaxZoneCount; | 52 int max_zone_count = kMaxZoneCount; |
| 53 EXPECT_EQ(max_zone_count, GetMallocZoneCountForTesting()); | 53 EXPECT_EQ(max_zone_count, GetMallocZoneCountForTesting()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 } // namespace allocator | 56 } // namespace allocator |
| 57 } // namespace base | 57 } // namespace base |
| OLD | NEW |