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

Side by Side Diff: runtime/vm/bit_vector_test.cc

Issue 587873003: Pass isolate to BitVector constructor. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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
« no previous file with comments | « runtime/vm/bit_vector.h ('k') | runtime/vm/flow_graph.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/bit_vector.h" 6 #include "vm/bit_vector.h"
7 #include "vm/unit_test.h" 7 #include "vm/unit_test.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
11 #define I Isolate::Current()
12
11 TEST_CASE(BitVector) { 13 TEST_CASE(BitVector) {
12 { BitVector* v = new BitVector(15); 14 { BitVector* v = new BitVector(I, 15);
13 v->Add(1); 15 v->Add(1);
14 EXPECT_EQ(true, v->Contains(1)); 16 EXPECT_EQ(true, v->Contains(1));
15 EXPECT_EQ(false, v->Contains(0)); 17 EXPECT_EQ(false, v->Contains(0));
16 { BitVector::Iterator iter(v); 18 { BitVector::Iterator iter(v);
17 EXPECT_EQ(1, iter.Current()); 19 EXPECT_EQ(1, iter.Current());
18 iter.Advance(); 20 iter.Advance();
19 EXPECT(iter.Done()); 21 EXPECT(iter.Done());
20 } 22 }
21 v->Add(0); 23 v->Add(0);
22 v->Add(1); 24 v->Add(1);
23 EXPECT_EQ(true, v->Contains(0)); 25 EXPECT_EQ(true, v->Contains(0));
24 EXPECT_EQ(true, v->Contains(1)); 26 EXPECT_EQ(true, v->Contains(1));
25 { BitVector::Iterator iter(v); 27 { BitVector::Iterator iter(v);
26 EXPECT_EQ(0, iter.Current()); 28 EXPECT_EQ(0, iter.Current());
27 iter.Advance(); 29 iter.Advance();
28 EXPECT_EQ(1, iter.Current()); 30 EXPECT_EQ(1, iter.Current());
29 iter.Advance(); 31 iter.Advance();
30 EXPECT(iter.Done()); 32 EXPECT(iter.Done());
31 } 33 }
32 } 34 }
33 35
34 { BitVector* v = new BitVector(128); 36 { BitVector* v = new BitVector(I, 128);
35 v->Add(49); 37 v->Add(49);
36 v->Add(62); 38 v->Add(62);
37 v->Add(63); 39 v->Add(63);
38 v->Add(65); 40 v->Add(65);
39 EXPECT_EQ(true, v->Contains(49)); 41 EXPECT_EQ(true, v->Contains(49));
40 EXPECT_EQ(true, v->Contains(62)); 42 EXPECT_EQ(true, v->Contains(62));
41 EXPECT_EQ(true, v->Contains(63)); 43 EXPECT_EQ(true, v->Contains(63));
42 EXPECT_EQ(true, v->Contains(65)); 44 EXPECT_EQ(true, v->Contains(65));
43 EXPECT_EQ(false, v->Contains(64)); 45 EXPECT_EQ(false, v->Contains(64));
44 BitVector::Iterator iter(v); 46 BitVector::Iterator iter(v);
45 EXPECT_EQ(49, iter.Current()); 47 EXPECT_EQ(49, iter.Current());
46 iter.Advance(); 48 iter.Advance();
47 EXPECT_EQ(62, iter.Current()); 49 EXPECT_EQ(62, iter.Current());
48 iter.Advance(); 50 iter.Advance();
49 EXPECT_EQ(63, iter.Current()); 51 EXPECT_EQ(63, iter.Current());
50 iter.Advance(); 52 iter.Advance();
51 EXPECT_EQ(65, iter.Current()); 53 EXPECT_EQ(65, iter.Current());
52 iter.Advance(); 54 iter.Advance();
53 EXPECT(iter.Done()); 55 EXPECT(iter.Done());
54 } 56 }
55 57
56 { BitVector* a = new BitVector(128); 58 { BitVector* a = new BitVector(I, 128);
57 BitVector* b = new BitVector(128); 59 BitVector* b = new BitVector(I, 128);
58 BitVector* c = new BitVector(128); 60 BitVector* c = new BitVector(I, 128);
59 b->Add(0); 61 b->Add(0);
60 b->Add(32); 62 b->Add(32);
61 b->Add(64); 63 b->Add(64);
62 a->AddAll(b); 64 a->AddAll(b);
63 EXPECT_EQ(true, a->Contains(0)); 65 EXPECT_EQ(true, a->Contains(0));
64 EXPECT_EQ(true, a->Contains(32)); 66 EXPECT_EQ(true, a->Contains(32));
65 EXPECT_EQ(true, a->Contains(64)); 67 EXPECT_EQ(true, a->Contains(64));
66 EXPECT_EQ(false, a->Contains(96)); 68 EXPECT_EQ(false, a->Contains(96));
67 EXPECT_EQ(false, a->Contains(127)); 69 EXPECT_EQ(false, a->Contains(127));
68 b->Add(96); 70 b->Add(96);
69 b->Add(127); 71 b->Add(127);
70 c->Add(127); 72 c->Add(127);
71 a->KillAndAdd(c, b); 73 a->KillAndAdd(c, b);
72 EXPECT_EQ(true, a->Contains(0)); 74 EXPECT_EQ(true, a->Contains(0));
73 EXPECT_EQ(true, a->Contains(32)); 75 EXPECT_EQ(true, a->Contains(32));
74 EXPECT_EQ(true, a->Contains(64)); 76 EXPECT_EQ(true, a->Contains(64));
75 EXPECT_EQ(true, a->Contains(96)); 77 EXPECT_EQ(true, a->Contains(96));
76 EXPECT_EQ(false, a->Contains(127)); 78 EXPECT_EQ(false, a->Contains(127));
77 a->Remove(0); 79 a->Remove(0);
78 a->Remove(32); 80 a->Remove(32);
79 a->Remove(64); 81 a->Remove(64);
80 a->Remove(96); 82 a->Remove(96);
81 EXPECT_EQ(false, a->Contains(0)); 83 EXPECT_EQ(false, a->Contains(0));
82 EXPECT_EQ(false, a->Contains(32)); 84 EXPECT_EQ(false, a->Contains(32));
83 EXPECT_EQ(false, a->Contains(64)); 85 EXPECT_EQ(false, a->Contains(64));
84 EXPECT_EQ(false, a->Contains(96)); 86 EXPECT_EQ(false, a->Contains(96));
85 } 87 }
86 88
87 { BitVector* a = new BitVector(34); 89 { BitVector* a = new BitVector(I, 34);
88 BitVector* b = new BitVector(34); 90 BitVector* b = new BitVector(I, 34);
89 a->SetAll(); 91 a->SetAll();
90 b->Add(0); 92 b->Add(0);
91 b->Add(1); 93 b->Add(1);
92 b->Add(31); 94 b->Add(31);
93 b->Add(32); 95 b->Add(32);
94 a->Intersect(b); 96 a->Intersect(b);
95 EXPECT_EQ(true, a->Equals(*b)); 97 EXPECT_EQ(true, a->Equals(*b));
96 } 98 }
97 99
98 { BitVector* a = new BitVector(2); 100 { BitVector* a = new BitVector(I, 2);
99 BitVector* b = new BitVector(2); 101 BitVector* b = new BitVector(I, 2);
100 a->SetAll(); 102 a->SetAll();
101 a->Remove(0); 103 a->Remove(0);
102 a->Remove(1); 104 a->Remove(1);
103 EXPECT_EQ(true, a->Equals(*b)); 105 EXPECT_EQ(true, a->Equals(*b));
104 } 106 }
105 107
106 { BitVector* a = new BitVector(128); 108 { BitVector* a = new BitVector(I, 128);
107 BitVector* b = new BitVector(128); 109 BitVector* b = new BitVector(I, 128);
108 b->Add(0); 110 b->Add(0);
109 b->Add(32); 111 b->Add(32);
110 b->Add(64); 112 b->Add(64);
111 a->Add(0); 113 a->Add(0);
112 a->Add(64); 114 a->Add(64);
113 b->RemoveAll(a); 115 b->RemoveAll(a);
114 EXPECT_EQ(false, b->Contains(0)); 116 EXPECT_EQ(false, b->Contains(0));
115 EXPECT_EQ(true, b->Contains(32)); 117 EXPECT_EQ(true, b->Contains(32));
116 EXPECT_EQ(false, b->Contains(64)); 118 EXPECT_EQ(false, b->Contains(64));
117 } 119 }
118 } 120 }
119 121
120 } // namespace dart 122 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/bit_vector.h ('k') | runtime/vm/flow_graph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698