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

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

Issue 12282038: Remove deprecated string features. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head Created 7 years, 10 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
« no previous file with comments | « tests/corelib/string_character_test.dart ('k') | tests/corelib/string_fromcharcode_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 main() { 5 main() {
6 test(String s) { 6 test(String s) {
7 Iterable<int> units = s.codeUnits; 7 Iterable<int> units = s.codeUnits;
8 List<int> expectedUnits = <int>[]; 8 List<int> expectedUnits = <int>[];
9 for (int i = 0; i < s.length; i++) { 9 for (int i = 0; i < s.length; i++) {
10 expectedUnits.add(s.codeUnitAt(i)); 10 expectedUnits.add(s.codeUnitAt(i));
(...skipping 13 matching lines...) Expand all
24 24
25 // .map 25 // .map
26 Expect.listEquals(expectedUnits.map((x) => x.toRadixString(16)).toList(), 26 Expect.listEquals(expectedUnits.map((x) => x.toRadixString(16)).toList(),
27 units.map((x) => x.toRadixString(16)).toList()); 27 units.map((x) => x.toRadixString(16)).toList());
28 } 28 }
29 29
30 test("abc"); 30 test("abc");
31 test("\x00\u0000\u{000000}"); 31 test("\x00\u0000\u{000000}");
32 test("\u{ffff}\u{10000}\u{10ffff}"); 32 test("\u{ffff}\u{10000}\u{10ffff}");
33 String string = new String.fromCharCodes( 33 String string = new String.fromCharCodes(
34 [0xdc00, 0xd800, 61, 0xd800, 0xdc00, 62, 0xdc00, 0xd800]); 34 [0xdc00, 0xd800, 61, 0xd9ab, 0xd9ab, 0xddef, 0xddef, 62, 0xdc00, 0xd800]);
35 test(string);
36 string = "\x00\x7f\xff\u0100\ufeff\uffef\uffff"
37 "\u{10000}\u{12345}\u{1d800}\u{1dc00}\u{1ffef}\u{1ffff}";
35 test(string); 38 test(string);
36 39
37 // Setting position in the middle of a surrogate pair is not allowed. 40 // Reading each unit of a surrogate pair works.
38 var r = new CodeUnits("\u{10000}"); 41 var r = "\u{10000}".codeUnits;
39 var it = r.iterator; 42 var it = r.iterator;
40 Expect.isTrue(it.moveNext()); 43 Expect.isTrue(it.moveNext());
41 Expect.equals(0xD800, it.current); 44 Expect.equals(0xD800, it.current);
42 Expect.isTrue(it.moveNext()); 45 Expect.isTrue(it.moveNext());
43 Expect.equals(0xDC00, it.current); 46 Expect.equals(0xDC00, it.current);
44 } 47 }
OLDNEW
« no previous file with comments | « tests/corelib/string_character_test.dart ('k') | tests/corelib/string_fromcharcode_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698