Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Unified Diff: gpu/command_buffer/common/id_allocator_test.cc

Issue 7077006: Speed up IdAllocator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Clarified description. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/common/id_allocator_test.cc
===================================================================
--- gpu/command_buffer/common/id_allocator_test.cc (revision 86796)
+++ gpu/command_buffer/common/id_allocator_test.cc (working copy)
@@ -49,6 +49,9 @@
TEST_F(IdAllocatorTest, TestAdvanced) {
IdAllocator *allocator = id_allocator();
+ // Allocate the highest possible ID, to make life awkward.
+ allocator->AllocateIDAtOrAbove(-1);
+
// Allocate a significant number of resources.
const unsigned int kNumResources = 100;
ResourceId ids[kNumResources];
@@ -95,4 +98,16 @@
EXPECT_GT(id3, kOffset);
}
+// Checks that AllocateIdAtOrAbove wraps around at the maximum 32-bit value.
+TEST_F(IdAllocatorTest, AllocateIdAtOrAboveWrapsAround) {
+ const ResourceId kMaxPossibleOffset = -1;
+ IdAllocator* allocator = id_allocator();
+ ResourceId id1 = allocator->AllocateIDAtOrAbove(kMaxPossibleOffset);
+ EXPECT_EQ(kMaxPossibleOffset, id1);
+ ResourceId id2 = allocator->AllocateIDAtOrAbove(kMaxPossibleOffset);
+ EXPECT_EQ(1u, id2);
+ ResourceId id3 = allocator->AllocateIDAtOrAbove(kMaxPossibleOffset);
+ EXPECT_EQ(2u, id3);
+}
+
} // namespace gpu
« gpu/command_buffer/common/id_allocator.h ('K') | « gpu/command_buffer/common/id_allocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698