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/include/fxcrt/fx_memory.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "../../include/fxcrt/fx_memory.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 |
18 } // namespace | 18 } // namespace |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 | 62 |
63 TEST(fxcrt, DISABLED_FXMEM_DefaultOOM) { | 63 TEST(fxcrt, DISABLED_FXMEM_DefaultOOM) { |
64 EXPECT_FALSE(FXMEM_DefaultAlloc(kMaxByteAlloc, 0)); | 64 EXPECT_FALSE(FXMEM_DefaultAlloc(kMaxByteAlloc, 0)); |
65 | 65 |
66 void* ptr = FXMEM_DefaultAlloc(1, 0); | 66 void* ptr = FXMEM_DefaultAlloc(1, 0); |
67 EXPECT_TRUE(ptr); | 67 EXPECT_TRUE(ptr); |
68 EXPECT_FALSE(FXMEM_DefaultRealloc(ptr, kMaxByteAlloc, 0)); | 68 EXPECT_FALSE(FXMEM_DefaultRealloc(ptr, kMaxByteAlloc, 0)); |
69 FXMEM_DefaultFree(ptr, 0); | 69 FXMEM_DefaultFree(ptr, 0); |
70 } | 70 } |
OLD | NEW |