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

Side by Side Diff: runtime/bin/set_test.cc

Issue 11365262: Remove unused files. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/set.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
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.
4
5 #include "bin/set.h"
6
7 #include "vm/unit_test.h"
8
9 UNIT_TEST_CASE(SetOperations) {
10 Set<int> set;
11 EXPECT(set.IsEmpty());
12 EXPECT(!set.Contains(1));
13 EXPECT(set.Add(1));
14 EXPECT(set.Contains(1));
15 EXPECT(!set.IsEmpty());
16 EXPECT(!set.Remove(2));
17 EXPECT(!set.IsEmpty());
18 EXPECT(set.Remove(1));
19 EXPECT(set.IsEmpty());
20 EXPECT(set.Add(3));
21 EXPECT(set.Contains(3));
22 EXPECT(!set.IsEmpty());
23 EXPECT(set.Add(4));
24 EXPECT(set.Contains(4));
25 EXPECT(!set.IsEmpty());
26 EXPECT(set.Add(5));
27 EXPECT(set.Contains(5));
28 EXPECT(set.Remove(5));
29 EXPECT(set.Remove(4));
30 EXPECT(set.Remove(3));
31 EXPECT(set.IsEmpty());
32 EXPECT(set.Add(1));
33 EXPECT(set.Contains(1));
34 EXPECT(set.Add(2));
35 EXPECT(set.Contains(2));
36 EXPECT(set.Add(3));
37 EXPECT(set.Contains(3));
38 EXPECT(!set.IsEmpty());
39 EXPECT(set.Size() == 3);
40 EXPECT(set.Remove(2));
41 EXPECT(set.Remove(1));
42 EXPECT(set.Remove(3));
43 EXPECT(set.IsEmpty());
44 EXPECT(set.Size() == 0);
45 EXPECT(set.Add(1));
46 EXPECT(set.Contains(1));
47 EXPECT(set.Add(2));
48 EXPECT(set.Contains(2));
49 EXPECT(set.Add(3));
50 EXPECT(set.Contains(3));
51 EXPECT(!set.IsEmpty());
52 EXPECT(set.Remove(2));
53 EXPECT(set.Remove(3));
54 EXPECT(set.Remove(1));
55 EXPECT(set.IsEmpty());
56 EXPECT(set.Add(1));
57 EXPECT(set.Contains(1));
58 EXPECT(set.Add(2));
59 EXPECT(set.Contains(2));
60 EXPECT(!set.IsEmpty());
61 EXPECT(set.Remove(2));
62 EXPECT(!set.IsEmpty());
63 EXPECT(set.Add(3));
64 EXPECT(set.Contains(3));
65 EXPECT(set.Add(4));
66 EXPECT(set.Contains(4));
67 EXPECT(!set.Contains(2));
68 EXPECT(!set.IsEmpty());
69 EXPECT(set.Remove(3));
70 EXPECT(!set.IsEmpty());
71 EXPECT(set.Remove(4));
72 EXPECT(set.Remove(1));
73 EXPECT(set.IsEmpty());
74 EXPECT(!set.Contains(4));
75 EXPECT(set.Add(1));
76 EXPECT(set.Contains(1));
77 EXPECT(!set.IsEmpty());
78 EXPECT(!set.Add(1));
79 EXPECT(set.Size() == 1);
80 EXPECT(set.Contains(1));
81 EXPECT(!set.IsEmpty());
82 EXPECT(set.Add(2));
83 EXPECT(set.Contains(2));
84 EXPECT(!set.IsEmpty());
85 EXPECT(!set.Add(2));
86 EXPECT(set.Contains(2));
87 EXPECT(!set.IsEmpty());
88 EXPECT(set.Size() == 2);
89 EXPECT(set.Remove(1));
90 EXPECT(set.Remove(2));
91 EXPECT(set.IsEmpty());
92 EXPECT(set.Size() == 0);
93 }
94
95
96 UNIT_TEST_CASE(SetIterator) {
97 Set<int> set;
98 int i;
99 for (i = 1; i <= 10; i++) {
100 set.Add(i);
101 }
102
103 Set<int>::Iterator iterator(&set);
104 int value;
105 i = 0;
106
107 while (iterator.HasNext()) {
108 iterator.GetNext(&value);
109 i++;
110 }
111 EXPECT(i == 10);
112 EXPECT(!set.IsEmpty());
113
114 Set<int> emptyset;
115 Set<int>::Iterator emptyiterator(&emptyset);
116
117 i = 0;
118 while (emptyiterator.HasNext()) {
119 emptyiterator.GetNext(&value);
120 i++;
121 }
122 EXPECT(i == 0);
123 EXPECT(emptyset.IsEmpty());
124 }
125
OLDNEW
« no previous file with comments | « runtime/bin/set.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698