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

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

Issue 10244009: test rename overhaul: step 7 - corelib tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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
(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 // Dart test for Splaytrees.
6 #library("SplayTreeTest.dart");
7 #import("dart:coreimpl");
8
9
10 class SplayTreeMapTest {
11
12 static testMain() {
13 SplayTreeMap tree = new SplayTreeMap();
14 tree[1] = "first";
15 tree[3] = "third";
16 tree[5] = "fifth";
17 tree[2] = "second";
18 tree[4] = "fourth";
19
20 var correctSolution = ["first", "second", "third", "fourth", "fifth"];
21
22 tree.forEach((key, value) {
23 Expect.equals(true, key >= 1);
24 Expect.equals(true, key <= 5);
25 Expect.equals(value, correctSolution[key - 1]);
26 });
27
28 for (var v in ["first", "second", "third", "fourth", "fifth"]) {
29 Expect.isTrue(tree.containsValue(v));
30 };
31 Expect.isFalse(tree.containsValue("sixth"));
32
33 tree[7] = "seventh";
34
35 Expect.equals(1, tree.firstKey());
36 Expect.equals(7, tree.lastKey());
37
38 Expect.equals(2, tree.lastKeyBefore(3));
39 Expect.equals(4, tree.firstKeyAfter(3));
40
41 Expect.equals(null, tree.lastKeyBefore(1));
42 Expect.equals(2, tree.firstKeyAfter(1));
43
44 Expect.equals(4, tree.lastKeyBefore(5));
45 Expect.equals(7, tree.firstKeyAfter(5));
46
47 Expect.equals(5, tree.lastKeyBefore(7));
48 Expect.equals(null, tree.firstKeyAfter(7));
49
50 Expect.equals(5, tree.lastKeyBefore(6));
51 Expect.equals(7, tree.firstKeyAfter(6));
52 }
53 }
54
55 main() {
56 SplayTreeMapTest.testMain();
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698