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

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

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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
« no previous file with comments | « runtime/vm/bit_vector.h ('k') | runtime/vm/bitfield.h » ('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 Z (thread->zone()) 11 #define Z (thread->zone())
12 12
13 TEST_CASE(BitVector) { 13 TEST_CASE(BitVector) {
14 { BitVector* v = new BitVector(Z, 15); 14 {
15 BitVector* v = new BitVector(Z, 15);
15 v->Add(1); 16 v->Add(1);
16 EXPECT_EQ(true, v->Contains(1)); 17 EXPECT_EQ(true, v->Contains(1));
17 EXPECT_EQ(false, v->Contains(0)); 18 EXPECT_EQ(false, v->Contains(0));
18 { BitVector::Iterator iter(v); 19 {
20 BitVector::Iterator iter(v);
19 EXPECT_EQ(1, iter.Current()); 21 EXPECT_EQ(1, iter.Current());
20 iter.Advance(); 22 iter.Advance();
21 EXPECT(iter.Done()); 23 EXPECT(iter.Done());
22 } 24 }
23 v->Add(0); 25 v->Add(0);
24 v->Add(1); 26 v->Add(1);
25 EXPECT_EQ(true, v->Contains(0)); 27 EXPECT_EQ(true, v->Contains(0));
26 EXPECT_EQ(true, v->Contains(1)); 28 EXPECT_EQ(true, v->Contains(1));
27 { BitVector::Iterator iter(v); 29 {
30 BitVector::Iterator iter(v);
28 EXPECT_EQ(0, iter.Current()); 31 EXPECT_EQ(0, iter.Current());
29 iter.Advance(); 32 iter.Advance();
30 EXPECT_EQ(1, iter.Current()); 33 EXPECT_EQ(1, iter.Current());
31 iter.Advance(); 34 iter.Advance();
32 EXPECT(iter.Done()); 35 EXPECT(iter.Done());
33 } 36 }
34 } 37 }
35 38
36 { BitVector* v = new BitVector(Z, 128); 39 {
40 BitVector* v = new BitVector(Z, 128);
37 v->Add(49); 41 v->Add(49);
38 v->Add(62); 42 v->Add(62);
39 v->Add(63); 43 v->Add(63);
40 v->Add(65); 44 v->Add(65);
41 EXPECT_EQ(true, v->Contains(49)); 45 EXPECT_EQ(true, v->Contains(49));
42 EXPECT_EQ(true, v->Contains(62)); 46 EXPECT_EQ(true, v->Contains(62));
43 EXPECT_EQ(true, v->Contains(63)); 47 EXPECT_EQ(true, v->Contains(63));
44 EXPECT_EQ(true, v->Contains(65)); 48 EXPECT_EQ(true, v->Contains(65));
45 EXPECT_EQ(false, v->Contains(64)); 49 EXPECT_EQ(false, v->Contains(64));
46 BitVector::Iterator iter(v); 50 BitVector::Iterator iter(v);
47 EXPECT_EQ(49, iter.Current()); 51 EXPECT_EQ(49, iter.Current());
48 iter.Advance(); 52 iter.Advance();
49 EXPECT_EQ(62, iter.Current()); 53 EXPECT_EQ(62, iter.Current());
50 iter.Advance(); 54 iter.Advance();
51 EXPECT_EQ(63, iter.Current()); 55 EXPECT_EQ(63, iter.Current());
52 iter.Advance(); 56 iter.Advance();
53 EXPECT_EQ(65, iter.Current()); 57 EXPECT_EQ(65, iter.Current());
54 iter.Advance(); 58 iter.Advance();
55 EXPECT(iter.Done()); 59 EXPECT(iter.Done());
56 } 60 }
57 61
58 { BitVector* a = new BitVector(Z, 128); 62 {
63 BitVector* a = new BitVector(Z, 128);
59 BitVector* b = new BitVector(Z, 128); 64 BitVector* b = new BitVector(Z, 128);
60 BitVector* c = new BitVector(Z, 128); 65 BitVector* c = new BitVector(Z, 128);
61 b->Add(0); 66 b->Add(0);
62 b->Add(32); 67 b->Add(32);
63 b->Add(64); 68 b->Add(64);
64 a->AddAll(b); 69 a->AddAll(b);
65 EXPECT_EQ(true, a->Contains(0)); 70 EXPECT_EQ(true, a->Contains(0));
66 EXPECT_EQ(true, a->Contains(32)); 71 EXPECT_EQ(true, a->Contains(32));
67 EXPECT_EQ(true, a->Contains(64)); 72 EXPECT_EQ(true, a->Contains(64));
68 EXPECT_EQ(false, a->Contains(96)); 73 EXPECT_EQ(false, a->Contains(96));
(...skipping 10 matching lines...) Expand all
79 a->Remove(0); 84 a->Remove(0);
80 a->Remove(32); 85 a->Remove(32);
81 a->Remove(64); 86 a->Remove(64);
82 a->Remove(96); 87 a->Remove(96);
83 EXPECT_EQ(false, a->Contains(0)); 88 EXPECT_EQ(false, a->Contains(0));
84 EXPECT_EQ(false, a->Contains(32)); 89 EXPECT_EQ(false, a->Contains(32));
85 EXPECT_EQ(false, a->Contains(64)); 90 EXPECT_EQ(false, a->Contains(64));
86 EXPECT_EQ(false, a->Contains(96)); 91 EXPECT_EQ(false, a->Contains(96));
87 } 92 }
88 93
89 { BitVector* a = new BitVector(Z, 34); 94 {
95 BitVector* a = new BitVector(Z, 34);
90 BitVector* b = new BitVector(Z, 34); 96 BitVector* b = new BitVector(Z, 34);
91 a->SetAll(); 97 a->SetAll();
92 b->Add(0); 98 b->Add(0);
93 b->Add(1); 99 b->Add(1);
94 b->Add(31); 100 b->Add(31);
95 b->Add(32); 101 b->Add(32);
96 a->Intersect(b); 102 a->Intersect(b);
97 EXPECT_EQ(true, a->Equals(*b)); 103 EXPECT_EQ(true, a->Equals(*b));
98 } 104 }
99 105
100 { BitVector* a = new BitVector(Z, 2); 106 {
107 BitVector* a = new BitVector(Z, 2);
101 BitVector* b = new BitVector(Z, 2); 108 BitVector* b = new BitVector(Z, 2);
102 a->SetAll(); 109 a->SetAll();
103 a->Remove(0); 110 a->Remove(0);
104 a->Remove(1); 111 a->Remove(1);
105 EXPECT_EQ(true, a->Equals(*b)); 112 EXPECT_EQ(true, a->Equals(*b));
106 } 113 }
107 114
108 { BitVector* a = new BitVector(Z, 128); 115 {
116 BitVector* a = new BitVector(Z, 128);
109 BitVector* b = new BitVector(Z, 128); 117 BitVector* b = new BitVector(Z, 128);
110 b->Add(0); 118 b->Add(0);
111 b->Add(32); 119 b->Add(32);
112 b->Add(64); 120 b->Add(64);
113 a->Add(0); 121 a->Add(0);
114 a->Add(64); 122 a->Add(64);
115 b->RemoveAll(a); 123 b->RemoveAll(a);
116 EXPECT_EQ(false, b->Contains(0)); 124 EXPECT_EQ(false, b->Contains(0));
117 EXPECT_EQ(true, b->Contains(32)); 125 EXPECT_EQ(true, b->Contains(32));
118 EXPECT_EQ(false, b->Contains(64)); 126 EXPECT_EQ(false, b->Contains(64));
119 } 127 }
120 } 128 }
121 129
122 } // namespace dart 130 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/bit_vector.h ('k') | runtime/vm/bitfield.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698