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

Side by Side Diff: tests/corelib/string_from_list_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 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
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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 void main() { 7 void main() {
8 Expect.equals("", new String.fromCharCodes(new List(0))); 8 Expect.equals("", new String.fromCharCodes(new List(0)));
9 Expect.equals("", new String.fromCharCodes([])); 9 Expect.equals("", new String.fromCharCodes([]));
10 Expect.equals("", new String.fromCharCodes(const [])); 10 Expect.equals("", new String.fromCharCodes(const []));
(...skipping 23 matching lines...) Expand all
34 String long = new String.fromCharCodes(list); 34 String long = new String.fromCharCodes(list);
35 // Minimal sanity checking on the string. 35 // Minimal sanity checking on the string.
36 Expect.isTrue(long.startsWith('ABCDE')); 36 Expect.isTrue(long.startsWith('ABCDE'));
37 Expect.isTrue(long.endsWith('987654321')); 37 Expect.isTrue(long.endsWith('987654321'));
38 int middle = len ~/ 2; 38 int middle = len ~/ 2;
39 middle -= middle % 26; 39 middle -= middle % 26;
40 Expect.equals('XYZABC', long.substring(middle - 3, middle + 3)); 40 Expect.equals('XYZABC', long.substring(middle - 3, middle + 3));
41 Expect.equals(len, long.length); 41 Expect.equals(len, long.length);
42 } 42 }
43 43
44
45 // Should work with iterables and non-default-lists (http://dartbug.com/8922) 44 // Should work with iterables and non-default-lists (http://dartbug.com/8922)
46 Expect.equals("CBA", new String.fromCharCodes([65, 66, 67].reversed)); 45 Expect.equals("CBA", new String.fromCharCodes([65, 66, 67].reversed));
47 Expect.equals("BCD", 46 Expect.equals(
48 new String.fromCharCodes([65, 66, 67].map((x) => x + 1))); 47 "BCD", new String.fromCharCodes([65, 66, 67].map((x) => x + 1)));
49 Expect.equals("AC", 48 Expect.equals(
50 new String.fromCharCodes([0x41, 0x42, 0x43].where( 49 "AC", new String.fromCharCodes([0x41, 0x42, 0x43].where((x) => x.isOdd)));
51 (x) => x.isOdd))); 50 Expect.equals(
52 Expect.equals("CE", 51 "CE",
53 new String.fromCharCodes( 52 new String.fromCharCodes(
54 [0x41, 0x42, 0x43].where((x) => x.isOdd) 53 [0x41, 0x42, 0x43].where((x) => x.isOdd).map((x) => x + 2)));
55 .map((x) => x + 2))); 54 Expect.equals(
56 Expect.equals("ABC", new String.fromCharCodes( 55 "ABC", new String.fromCharCodes(new Iterable.generate(3, (x) => 65 + x)));
57 new Iterable.generate(3, (x) => 65 + x)));
58 Expect.equals("ABC", new String.fromCharCodes("ABC".codeUnits)); 56 Expect.equals("ABC", new String.fromCharCodes("ABC".codeUnits));
59 Expect.equals("BCD", 57 Expect.equals(
60 new String.fromCharCodes("ABC".codeUnits.map((x) => x + 1))); 58 "BCD", new String.fromCharCodes("ABC".codeUnits.map((x) => x + 1)));
61 Expect.equals("BCD", 59 Expect.equals("BCD", new String.fromCharCodes("ABC".runes.map((x) => x + 1)));
62 new String.fromCharCodes("ABC".runes.map((x) => x + 1)));
63 60
64 var nonBmpCharCodes = [0, 0xD812, 0xDC34, 0x14834, 0xDC34, 0xD812]; 61 var nonBmpCharCodes = [0, 0xD812, 0xDC34, 0x14834, 0xDC34, 0xD812];
65 var nonBmp = new String.fromCharCodes(nonBmpCharCodes); 62 var nonBmp = new String.fromCharCodes(nonBmpCharCodes);
66 Expect.equals(7, nonBmp.length); 63 Expect.equals(7, nonBmp.length);
67 Expect.equals(0, nonBmp.codeUnitAt(0)); 64 Expect.equals(0, nonBmp.codeUnitAt(0));
68 Expect.equals(0xD812, nonBmp.codeUnitAt(1)); // Separated surrogate pair 65 Expect.equals(0xD812, nonBmp.codeUnitAt(1)); // Separated surrogate pair
69 Expect.equals(0xDC34, nonBmp.codeUnitAt(2)); 66 Expect.equals(0xDC34, nonBmp.codeUnitAt(2));
70 Expect.equals(0xD812, nonBmp.codeUnitAt(3)); // Single non-BMP code point. 67 Expect.equals(0xD812, nonBmp.codeUnitAt(3)); // Single non-BMP code point.
71 Expect.equals(0xDC34, nonBmp.codeUnitAt(4)); 68 Expect.equals(0xDC34, nonBmp.codeUnitAt(4));
72 Expect.equals(0xDC34, nonBmp.codeUnitAt(5)); // Unmatched surrogate. 69 Expect.equals(0xDC34, nonBmp.codeUnitAt(5)); // Unmatched surrogate.
73 Expect.equals(0xD812, nonBmp.codeUnitAt(6)); // Unmatched surrogate. 70 Expect.equals(0xD812, nonBmp.codeUnitAt(6)); // Unmatched surrogate.
74 71
75 var reversedNonBmp = new String.fromCharCodes(nonBmpCharCodes.reversed); 72 var reversedNonBmp = new String.fromCharCodes(nonBmpCharCodes.reversed);
76 Expect.equals(7, reversedNonBmp.length); 73 Expect.equals(7, reversedNonBmp.length);
77 Expect.equals(0, reversedNonBmp.codeUnitAt(6)); 74 Expect.equals(0, reversedNonBmp.codeUnitAt(6));
78 Expect.equals(0xD812, reversedNonBmp.codeUnitAt(5)); 75 Expect.equals(0xD812, reversedNonBmp.codeUnitAt(5));
79 Expect.equals(0xDC34, reversedNonBmp.codeUnitAt(4)); 76 Expect.equals(0xDC34, reversedNonBmp.codeUnitAt(4));
80 Expect.equals(0xDC34, reversedNonBmp.codeUnitAt(3)); 77 Expect.equals(0xDC34, reversedNonBmp.codeUnitAt(3));
81 Expect.equals(0xD812, reversedNonBmp.codeUnitAt(2)); 78 Expect.equals(0xD812, reversedNonBmp.codeUnitAt(2));
82 Expect.equals(0xDC34, reversedNonBmp.codeUnitAt(1)); 79 Expect.equals(0xDC34, reversedNonBmp.codeUnitAt(1));
83 Expect.equals(0xD812, reversedNonBmp.codeUnitAt(0)); 80 Expect.equals(0xD812, reversedNonBmp.codeUnitAt(0));
84 81
85 Expect.equals(nonBmp, new String.fromCharCodes(nonBmp.codeUnits)); 82 Expect.equals(nonBmp, new String.fromCharCodes(nonBmp.codeUnits));
86 Expect.equals(nonBmp, new String.fromCharCodes(nonBmp.runes)); 83 Expect.equals(nonBmp, new String.fromCharCodes(nonBmp.runes));
87 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698