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

Side by Side Diff: vm/bitmap_test.cc

Issue 10030001: Resubmit change 6302 after fixing the compiler warning on older GCC compiler versions: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/bitmap.h" 6 #include "vm/bitmap.h"
7 #include "vm/object.h" 7 #include "vm/object.h"
8 #include "vm/unit_test.h" 8 #include "vm/unit_test.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 19 matching lines...) Expand all
30 for (int32_t i = 0; i < 1024; i++) { 30 for (int32_t i = 0; i < 1024; i++) {
31 bmap1_builder->Set(i, value); 31 bmap1_builder->Set(i, value);
32 value = !value; 32 value = !value;
33 } 33 }
34 value = true; 34 value = true;
35 for (int32_t i = 0; i < 1024; i++) { 35 for (int32_t i = 0; i < 1024; i++) {
36 EXPECT_EQ(value, bmap1_builder->Get(i)); 36 EXPECT_EQ(value, bmap1_builder->Get(i));
37 value = !value; 37 value = !value;
38 } 38 }
39 // Create a Bitmap object from the builder and verify it's contents. 39 // Create a Bitmap object from the builder and verify it's contents.
40 const Stackmap& bmap1 = Stackmap::Handle( 40 const Stackmap& bmap1 = Stackmap::Handle(Stackmap::New(0, bmap1_builder));
41 Stackmap::New(0, Code::Handle(), bmap1_builder));
42 EXPECT_EQ(1022, bmap1_builder->Maximum()); 41 EXPECT_EQ(1022, bmap1_builder->Maximum());
43 EXPECT_EQ(0, bmap1_builder->Minimum()); 42 EXPECT_EQ(0, bmap1_builder->Minimum());
44 OS::Print("%s\n", bmap1.ToCString()); 43 OS::Print("%s\n", bmap1.ToCString());
45 value = true; 44 value = true;
46 for (int32_t i = 0; i < 1024; i++) { 45 for (int32_t i = 0; i < 1024; i++) {
47 EXPECT_EQ(value, bmap1.IsObject(i)); 46 EXPECT_EQ(value, bmap1.IsObject(i));
48 value = !value; 47 value = !value;
49 } 48 }
50 EXPECT(!bmap1.IsObject(2056)); // Out of range so returns false. 49 EXPECT(!bmap1.IsObject(2056)); // Out of range so returns false.
51 50
52 // Test the SetRange function in the builder. 51 // Test the SetRange function in the builder.
53 bmap1_builder->SetRange(0, 256, false); 52 bmap1_builder->SetRange(0, 256, false);
54 bmap1_builder->SetRange(257, 1024, true); 53 bmap1_builder->SetRange(257, 1024, true);
55 bmap1_builder->SetRange(1025, 2048, false); 54 bmap1_builder->SetRange(1025, 2048, false);
56 for (int32_t i = 0; i <= 256; i++) { 55 for (int32_t i = 0; i <= 256; i++) {
57 EXPECT(!bmap1_builder->Get(i)); 56 EXPECT(!bmap1_builder->Get(i));
58 } 57 }
59 for (int32_t i = 257; i <= 1024; i++) { 58 for (int32_t i = 257; i <= 1024; i++) {
60 EXPECT(bmap1_builder->Get(i)); 59 EXPECT(bmap1_builder->Get(i));
61 } 60 }
62 for (int32_t i = 1025; i <= 2048; i++) { 61 for (int32_t i = 1025; i <= 2048; i++) {
63 EXPECT(!bmap1_builder->Get(i)); 62 EXPECT(!bmap1_builder->Get(i));
64 } 63 }
65 const Stackmap& bmap2 = Stackmap::Handle( 64 const Stackmap& bmap2 = Stackmap::Handle(Stackmap::New(0, bmap1_builder));
66 Stackmap::New(0, Code::Handle(), bmap1_builder));
67 EXPECT_EQ(1024, bmap1_builder->Maximum()); 65 EXPECT_EQ(1024, bmap1_builder->Maximum());
68 EXPECT_EQ(257, bmap1_builder->Minimum()); 66 EXPECT_EQ(257, bmap1_builder->Minimum());
69 for (int32_t i = 0; i <= 256; i++) { 67 for (int32_t i = 0; i <= 256; i++) {
70 EXPECT(!bmap2.IsObject(i)); 68 EXPECT(!bmap2.IsObject(i));
71 } 69 }
72 for (int32_t i = 257; i <= 1024; i++) { 70 for (int32_t i = 257; i <= 1024; i++) {
73 EXPECT(bmap2.IsObject(i)); 71 EXPECT(bmap2.IsObject(i));
74 } 72 }
75 for (int32_t i = 1025; i <= 2048; i++) { 73 for (int32_t i = 1025; i <= 2048; i++) {
76 EXPECT(!bmap2.IsObject(i)); 74 EXPECT(!bmap2.IsObject(i));
(...skipping 19 matching lines...) Expand all
96 } 94 }
97 for (int32_t i = 257; i <= 1024; i++) { 95 for (int32_t i = 257; i <= 1024; i++) {
98 EXPECT(bmap3_builder->Get(i)); 96 EXPECT(bmap3_builder->Get(i));
99 } 97 }
100 for (int32_t i = 1025; i <= 2048; i++) { 98 for (int32_t i = 1025; i <= 2048; i++) {
101 EXPECT(!bmap3_builder->Get(i)); 99 EXPECT(!bmap3_builder->Get(i));
102 } 100 }
103 } 101 }
104 102
105 } // namespace dart 103 } // namespace dart
OLDNEW
« no previous file with comments | « vm/bitmap.cc ('k') | vm/code_descriptors.h » ('j') | vm/stack_frame.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698