| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 struct TestClass2 { | 46 struct TestClass2 { |
| 47 TestClass2() : a(1), b(2), c(3), d(4) {} | 47 TestClass2() : a(1), b(2), c(3), d(4) {} |
| 48 | 48 |
| 49 float a, b, c, d; | 49 float a, b, c, d; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 } // anonymous namespace | 52 } // anonymous namespace |
| 53 | 53 |
| 54 class PODArenaTest : public testing::Test {}; | 54 class PODArenaTest : public ::testing::Test {}; |
| 55 | 55 |
| 56 // Make sure the arena can successfully allocate from more than one | 56 // Make sure the arena can successfully allocate from more than one |
| 57 // region. | 57 // region. |
| 58 TEST_F(PODArenaTest, CanAllocateFromMoreThanOneRegion) { | 58 TEST_F(PODArenaTest, CanAllocateFromMoreThanOneRegion) { |
| 59 RefPtr<TrackedAllocator> allocator = TrackedAllocator::Create(); | 59 RefPtr<TrackedAllocator> allocator = TrackedAllocator::Create(); |
| 60 RefPtr<PODArena> arena = PODArena::Create(allocator); | 60 RefPtr<PODArena> arena = PODArena::Create(allocator); |
| 61 int num_iterations = 10 * PODArena::kDefaultChunkSize / sizeof(TestClass1); | 61 int num_iterations = 10 * PODArena::kDefaultChunkSize / sizeof(TestClass1); |
| 62 for (int i = 0; i < num_iterations; ++i) | 62 for (int i = 0; i < num_iterations; ++i) |
| 63 arena->AllocateObject<TestClass1>(); | 63 arena->AllocateObject<TestClass1>(); |
| 64 EXPECT_GT(allocator->NumRegions(), 1); | 64 EXPECT_GT(allocator->NumRegions(), 1); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 87 EXPECT_EQ(1, tc1->w); | 87 EXPECT_EQ(1, tc1->w); |
| 88 TestClass2* tc2 = arena->AllocateObject<TestClass2>(); | 88 TestClass2* tc2 = arena->AllocateObject<TestClass2>(); |
| 89 EXPECT_EQ(1, tc2->a); | 89 EXPECT_EQ(1, tc2->a); |
| 90 EXPECT_EQ(2, tc2->b); | 90 EXPECT_EQ(2, tc2->b); |
| 91 EXPECT_EQ(3, tc2->c); | 91 EXPECT_EQ(3, tc2->c); |
| 92 EXPECT_EQ(4, tc2->d); | 92 EXPECT_EQ(4, tc2->d); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace blink | 96 } // namespace blink |
| OLD | NEW |