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

Side by Side Diff: tests/corelib/src/SplayTreeTest.dart

Issue 9455051: Add getMinimum, getMaximum, getPreceding and getSucceeding to SplayTree. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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 // Dart test for Splaytrees. 5 // Dart test for Splaytrees.
6 #library("SplayTreeTest.dart"); 6 #library("SplayTreeTest.dart");
7 #import("dart:coreimpl"); 7 #import("dart:coreimpl");
8 8
9 9
10 class SplayTreeTest { 10 class SplayTreeTest {
11 11
12 static testMain() { 12 static testMain() {
13 SplayTree tree = new SplayTree(); 13 SplayTree tree = new SplayTree();
14 tree[1] = "first"; 14 tree[1] = "first";
15 tree[3] = "third"; 15 tree[3] = "third";
16 tree[5] = "fifth"; 16 tree[5] = "fifth";
17 tree[2] = "second"; 17 tree[2] = "second";
18 tree[4] = "fourth"; 18 tree[4] = "fourth";
19 19
20 var correctSolution = ["first", "second", "third", "fourth", "fifth"]; 20 var correctSolution = ["first", "second", "third", "fourth", "fifth"];
21 21
22 tree.forEach((key, value) { 22 tree.forEach((key, value) {
23 Expect.equals(true, key >= 1); 23 Expect.equals(true, key >= 1);
24 Expect.equals(true, key <= 5); 24 Expect.equals(true, key <= 5);
25 Expect.equals(value, correctSolution[key - 1]); 25 Expect.equals(value, correctSolution[key - 1]);
26 }); 26 });
27
28 Expect.equals(1, tree.firstKey());
29 Expect.equals(1, tree.firstKey());
30
31 Expect.equals(2, tree.keyBefore(3));
32 Expect.equals(4, tree.keyAfter(3));
33
34 Expect.equals(-10, tree.keyBefore(1, -10));
35 Expect.equals(2, tree.keyAfter(1, -10));
36
37 Expect.equals(4, tree.keyBefore(5, -10));
38 Expect.equals(-10, tree.keyAfter(5, -10));
27 } 39 }
28 } 40 }
29 41
30 main() { 42 main() {
31 SplayTreeTest.testMain(); 43 SplayTreeTest.testMain();
32 } 44 }
OLDNEW
« corelib/src/implementation/splay_tree.dart ('K') | « corelib/src/implementation/splay_tree.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698