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 "core/include/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 { |
(...skipping 24 matching lines...) Expand all Loading... | |
35 EXPECT_TRUE(ptr); | 35 EXPECT_TRUE(ptr); |
36 EXPECT_DEATH_IF_SUPPORTED((void)FX_Realloc(int, ptr, kOverflowIntAlloc), ""); | 36 EXPECT_DEATH_IF_SUPPORTED((void)FX_Realloc(int, ptr, kOverflowIntAlloc), ""); |
37 FX_Free(ptr); | 37 FX_Free(ptr); |
38 } | 38 } |
39 | 39 |
40 TEST(fxcrt, FX_AllocOverflow2D) { | 40 TEST(fxcrt, FX_AllocOverflow2D) { |
41 EXPECT_DEATH_IF_SUPPORTED((void)FX_Alloc2D(int, kWidth, kOverflowIntAlloc2D), | 41 EXPECT_DEATH_IF_SUPPORTED((void)FX_Alloc2D(int, kWidth, kOverflowIntAlloc2D), |
42 ""); | 42 ""); |
43 } | 43 } |
44 | 44 |
45 TEST(fxcrt, DISABLED_FX_TryAllocOOM) { | |
Tom Sepez
2016/03/02 20:28:07
And keep these.
dsinclair
2016/03/02 20:55:36
Done.
| |
46 EXPECT_FALSE(FX_TryAlloc(int, kMaxIntAlloc)); | |
47 | |
48 int* ptr = FX_Alloc(int, 1); | |
49 EXPECT_TRUE(ptr); | |
50 EXPECT_FALSE(FX_TryRealloc(int, ptr, kMaxIntAlloc)); | |
51 FX_Free(ptr); | |
52 } | |
53 | |
54 TEST(fxcrt, FX_TryAllocOverflow) { | |
55 EXPECT_FALSE(FX_TryAlloc(int, kOverflowIntAlloc)); | |
56 | |
57 int* ptr = FX_Alloc(int, 1); | |
58 EXPECT_TRUE(ptr); | |
59 EXPECT_FALSE(FX_TryRealloc(int, ptr, kOverflowIntAlloc)); | |
60 FX_Free(ptr); | |
61 } | |
62 | |
63 TEST(fxcrt, DISABLED_FXMEM_DefaultOOM) { | 45 TEST(fxcrt, DISABLED_FXMEM_DefaultOOM) { |
64 EXPECT_FALSE(FXMEM_DefaultAlloc(kMaxByteAlloc, 0)); | 46 EXPECT_FALSE(FXMEM_DefaultAlloc(kMaxByteAlloc, 0)); |
65 | 47 |
66 void* ptr = FXMEM_DefaultAlloc(1, 0); | 48 void* ptr = FXMEM_DefaultAlloc(1, 0); |
67 EXPECT_TRUE(ptr); | 49 EXPECT_TRUE(ptr); |
68 EXPECT_FALSE(FXMEM_DefaultRealloc(ptr, kMaxByteAlloc, 0)); | 50 EXPECT_FALSE(FXMEM_DefaultRealloc(ptr, kMaxByteAlloc, 0)); |
69 FXMEM_DefaultFree(ptr, 0); | 51 FXMEM_DefaultFree(ptr, 0); |
70 } | 52 } |
OLD | NEW |