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

Unified Diff: tests/lib/collection/linked_list_test.dart

Issue 2015513006: Make linked-list non-circular. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« sdk/lib/collection/linked_list.dart ('K') | « sdk/lib/collection/linked_list.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/collection/linked_list_test.dart
diff --git a/tests/lib/collection/linked_list_test.dart b/tests/lib/collection/linked_list_test.dart
index 3ed06b75cde1057dd0243aedaea8a5bb1bbd9adc..785ebe7dd44ca5a5757227bd0d1b3a892889c160 100644
--- a/tests/lib/collection/linked_list_test.dart
+++ b/tests/lib/collection/linked_list_test.dart
@@ -14,6 +14,55 @@ class MyEntry extends LinkedListEntry<MyEntry> {
}
+testPreviousNext() {
+ var list = new LinkedList<MyEntry>();
+ Expect.throws(() => list.first);
+ Expect.throws(() => list.last);
+ Expect.equals(0, list.length);
+
+ for (int i = 0; i < 3; i++) {
+ list.add(new MyEntry(i));
+ }
+ Expect.equals(3, list.length);
+
+ var entry = list.first;
+ Expect.isNull(entry.previous);
+ Expect.equals(0, entry.value);
+ entry = entry.next;
+ Expect.equals(1, entry.value);
+ entry = entry.next;
+ Expect.equals(2, entry.value);
+ Expect.isNull(entry.next);
+ entry = entry.previous;
+ Expect.equals(1, entry.value);
+ entry = entry.previous;
+ Expect.equals(0, entry.value);
+ Expect.isNull(entry.previous);
+}
+
+testUnlinked() {
+ var unlinked = new MyEntry(0);
+ Expect.isNull(unlinked.previous);
+ Expect.isNull(unlinked.next);
+ var list = new LinkedList<MyEntry>();
+ list.add(unlinked);
+ Expect.isNull(unlinked.previous);
+ Expect.isNull(unlinked.next);
+ list.remove(unlinked);
+ Expect.isNull(unlinked.previous);
+ Expect.isNull(unlinked.next);
+ list.add(unlinked);
+ list.add(new MyEntry(1));
+ Expect.isNull(unlinked.previous);
+ Expect.equals(1, unlinked.next.value);
+ list.remove(unlinked);
+ Expect.isNull(unlinked.previous);
+ Expect.isNull(unlinked.next);
+ list.add(unlinked);
+ Expect.isNull(unlinked.next);
+ Expect.equals(1, unlinked.previous.value);
+}
+
testInsert() {
// Insert last.
var list = new LinkedList<MyEntry>();
@@ -168,6 +217,8 @@ testConcurrentModificationError() {
}
main() {
+ testPreviousNext();
+ testUnlinked();
testInsert();
testRemove();
testBadAdd();
« sdk/lib/collection/linked_list.dart ('K') | « sdk/lib/collection/linked_list.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698