OLD | NEW |
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium 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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "core/fxcrt/include/fx_memory.h" | 7 #include "core/fxcrt/fx_memory.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 | 11 |
12 const size_t kMaxByteAlloc = std::numeric_limits<size_t>::max(); | 12 const size_t kMaxByteAlloc = std::numeric_limits<size_t>::max(); |
13 const size_t kMaxIntAlloc = kMaxByteAlloc / sizeof(int); | 13 const size_t kMaxIntAlloc = kMaxByteAlloc / sizeof(int); |
14 const size_t kOverflowIntAlloc = kMaxIntAlloc + 100; | 14 const size_t kOverflowIntAlloc = kMaxIntAlloc + 100; |
15 const size_t kWidth = 640; | 15 const size_t kWidth = 640; |
16 const size_t kOverflowIntAlloc2D = kMaxIntAlloc / kWidth + 10; | 16 const size_t kOverflowIntAlloc2D = kMaxIntAlloc / kWidth + 10; |
17 | 17 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 | 72 |
73 TEST(fxcrt, DISABLED_FXMEM_DefaultOOM) { | 73 TEST(fxcrt, DISABLED_FXMEM_DefaultOOM) { |
74 EXPECT_FALSE(FXMEM_DefaultAlloc(kMaxByteAlloc, 0)); | 74 EXPECT_FALSE(FXMEM_DefaultAlloc(kMaxByteAlloc, 0)); |
75 | 75 |
76 void* ptr = FXMEM_DefaultAlloc(1, 0); | 76 void* ptr = FXMEM_DefaultAlloc(1, 0); |
77 EXPECT_TRUE(ptr); | 77 EXPECT_TRUE(ptr); |
78 EXPECT_FALSE(FXMEM_DefaultRealloc(ptr, kMaxByteAlloc, 0)); | 78 EXPECT_FALSE(FXMEM_DefaultRealloc(ptr, kMaxByteAlloc, 0)); |
79 FXMEM_DefaultFree(ptr, 0); | 79 FXMEM_DefaultFree(ptr, 0); |
80 } | 80 } |
OLD | NEW |