Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 import "package:expect/expect.dart"; | |
| 6 import 'dart:collection'; | |
| 7 | |
| 8 main() { | |
| 9 positiveTest(); | |
| 10 emptyMapTest(); | |
| 11 fewerKeysIterableTest(); | |
| 12 fewerValuesIterableTest(); | |
| 13 identicalElementsTest(); | |
| 14 } | |
| 15 | |
| 16 void positiveTest() { | |
| 17 var map = new Map.fromIterables([1, 2, 3], ["one", "two", "three"]); | |
|
floitsch
2013/06/27 11:45:04
write at least one test with generic types.
zarah
2013/06/27 13:02:43
Done.
| |
| 18 Expect.isTrue(map is Map); | |
| 19 Expect.isTrue(map is HashMap); | |
| 20 | |
| 21 Expect.equals(3, map.length); | |
| 22 Expect.equals(3, map.keys.length); | |
| 23 Expect.equals(3, map.values.length); | |
| 24 | |
| 25 Expect.equals("one", map[1]); | |
| 26 Expect.equals("two", map[2]); | |
| 27 Expect.equals("three", map[3]); | |
| 28 } | |
| 29 | |
| 30 void emptyMapTest() { | |
| 31 var map = new Map.fromIterables([], []); | |
| 32 Expect.isTrue(map is Map); | |
| 33 Expect.isTrue(map is HashMap); | |
| 34 | |
| 35 Expect.equals(0, map.length); | |
| 36 Expect.equals(0, map.keys.length); | |
| 37 Expect.equals(0, map.values.length); | |
| 38 } | |
| 39 | |
| 40 void fewerValuesIterableTest() { | |
| 41 Expect.throws(() => new Map.fromIterables([1,2], [0])); | |
| 42 } | |
| 43 | |
| 44 void fewerKeysIterableTest() { | |
| 45 Expect.throws(() => new Map.fromIterables([1], [0,2])); | |
| 46 } | |
| 47 | |
| 48 void identicalElementsTest() { | |
|
floitsch
2013/06/27 11:45:04
equalElementsTest (although they are identical her
zarah
2013/06/27 13:02:43
Done.
| |
| 49 var map = new Map.fromIterables([1, 2, 2], ["one", "two", "three"]); | |
| 50 Expect.isTrue(map is Map); | |
| 51 Expect.isTrue(map is HashMap); | |
| 52 | |
| 53 Expect.equals(2, map.length); | |
| 54 Expect.equals(2, map.keys.length); | |
| 55 Expect.equals(2, map.values.length); | |
| 56 | |
| 57 Expect.equals("one", map[1]); | |
| 58 Expect.equals("three", map[2]); | |
| 59 } | |
| OLD | NEW |