1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "courgette/third_party/paged_array.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 class PagedArrayTest
: public testing::Test
{
11 // Total allocation of 4GB will fail in 32 bit programs if allocations are
13 static const int kIterations
= 20;
14 static const int kSize
= 200 * 1024 * 1024 / sizeof(int); // 200MB
17 TEST_F(PagedArrayTest
, TestManyAllocationsDestructorFree
) {
18 for (int i
= 0; i
< kIterations
; ++i
) {
19 courgette::PagedArray
<int> a
;
20 EXPECT_TRUE(a
.Allocate(kSize
));
24 TEST_F(PagedArrayTest
, TestManyAllocationsManualFree
) {
25 courgette::PagedArray
<int> a
;
26 for (int i
= 0; i
< kIterations
; ++i
) {
27 EXPECT_TRUE(a
.Allocate(kSize
));
32 TEST_F(PagedArrayTest
, TestAccess
) {
33 const int kAccessSize
= 3 * 1024 * 1024;
34 courgette::PagedArray
<int> a
;
35 a
.Allocate(kAccessSize
);
36 for (int i
= 0; i
< kAccessSize
; ++i
) {
39 for (int i
= 0; i
< kAccessSize
; ++i
) {