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

Unified Diff: tests/corelib/set_test.dart

Issue 15263004: Adding isNotEmpty property to collection and string. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix template generation Created 7 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
« no previous file with comments | « tests/corelib/queue_test.dart ('k') | tests/corelib/string_buffer_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/set_test.dart
diff --git a/tests/corelib/set_test.dart b/tests/corelib/set_test.dart
index 5acb8a5f1a56ef68ab4b1facf70f73f296230384..f08583554288900e82cf9ffcfa4f0a2c947554ca 100644
--- a/tests/corelib/set_test.dart
+++ b/tests/corelib/set_test.dart
@@ -10,29 +10,29 @@ import "dart:collection";
void testMain(Set create()) {
Set set = create();
- Expect.equals(0, set.length);
+ testLength(0, set);
set.add(1);
- Expect.equals(1, set.length);
+ testLength(1, set);
Expect.isTrue(set.contains(1));
set.add(1);
- Expect.equals(1, set.length);
+ testLength(1, set);
Expect.isTrue(set.contains(1));
set.remove(1);
- Expect.equals(0, set.length);
+ testLength(0, set);
Expect.isFalse(set.contains(1));
for (int i = 0; i < 10; i++) {
set.add(i);
}
- Expect.equals(10, set.length);
+ testLength(10, set);
for (int i = 0; i < 10; i++) {
Expect.isTrue(set.contains(i));
}
- Expect.equals(10, set.length);
+ testLength(10, set);
for (int i = 10; i < 20; i++) {
Expect.isFalse(set.contains(i));
@@ -160,14 +160,14 @@ void testMain(Set create()) {
list[i] = i + 10;
}
set.addAll(list);
- Expect.equals(20, set.length);
+ testLength(20, set);
for (int i = 0; i < 20; i++) {
Expect.isTrue(set.contains(i));
}
// Test Set.removeAll
set.removeAll(list);
- Expect.equals(10, set.length);
+ testLength(10, set);
for (int i = 0; i < 10; i++) {
Expect.isTrue(set.contains(i));
}
@@ -177,9 +177,15 @@ void testMain(Set create()) {
// Test Set.clear.
set.clear();
- Expect.equals(0, set.length);
+ testLength(0, set);
set.add(11);
- Expect.equals(1, set.length);
+ testLength(1, set);
+}
+
+void testLength(int length, Set set) {
+ Expect.equals(length, set.length);
+ (length == 0 ? Expect.isTrue : Expect.isFalse)(set.isEmpty);
+ (length != 0 ? Expect.isTrue : Expect.isFalse)(set.isNotEmpty);
}
main() {
« no previous file with comments | « tests/corelib/queue_test.dart ('k') | tests/corelib/string_buffer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698