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

Side by Side Diff: tests/utils/utf8_test.dart

Issue 11411092: Revert "Add some support for the code-point code-unit distinction." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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/standalone/io/string_stream_test.dart ('k') | tests/utils/utf_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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library utf8_test; 5 library utf8_test;
6 import 'dart:utf'; 6 import 'dart:utf';
7 7
8 String decode(List<int> bytes) => decodeUtf8(bytes); 8 String decode(List<int> bytes) => decodeUtf8(bytes);
9 9
10 bool isRunningOnJavaScript() => identical(1, 1.0);
11
10 main() { 12 main() {
11 // Google favorite: "Îñţérñåţîöñåļîžåţîờñ". 13 // Google favorite: "Îñţérñåţîöñåļîžåţîờñ".
12 String string = decode([0xc3, 0x8e, 0xc3, 0xb1, 0xc5, 0xa3, 0xc3, 0xa9, 0x72, 14 String string = decode([0xc3, 0x8e, 0xc3, 0xb1, 0xc5, 0xa3, 0xc3, 0xa9, 0x72,
13 0xc3, 0xb1, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xc3, 15 0xc3, 0xb1, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xc3,
14 0xb6, 0xc3, 0xb1, 0xc3, 0xa5, 0xc4, 0xbc, 0xc3, 0xae, 16 0xb6, 0xc3, 0xb1, 0xc3, 0xa5, 0xc4, 0xbc, 0xc3, 0xae,
15 0xc5, 0xbe, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xe1, 17 0xc5, 0xbe, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xe1,
16 0xbb, 0x9d, 0xc3, 0xb1]); 18 0xbb, 0x9d, 0xc3, 0xb1]);
17 Expect.stringEquals("Îñţérñåţîöñåļîžåţîờñ", string); 19 Expect.stringEquals("Îñţérñåţîöñåļîžåţîờñ", string);
18 20
19 // Blueberry porridge in Danish: "blåbærgrød". 21 // Blueberry porridge in Danish: "blåbærgrød".
20 string = decode([0x62, 0x6c, 0xc3, 0xa5, 0x62, 0xc3, 0xa6, 0x72, 0x67, 0x72, 22 string = decode([0x62, 0x6c, 0xc3, 0xa5, 0x62, 0xc3, 0xa6, 0x72, 0x67, 0x72,
21 0xc3, 0xb8, 0x64]); 23 0xc3, 0xb8, 0x64]);
22 Expect.stringEquals("blåbærgrød", string); 24 Expect.stringEquals("blåbærgrød", string);
23 25
24 // "சிவா அணாமாைல", that is "Siva Annamalai" in Tamil. 26 // "சிவா அணாமாைல", that is "Siva Annamalai" in Tamil.
25 string = decode([0xe0, 0xae, 0x9a, 0xe0, 0xae, 0xbf, 0xe0, 0xae, 0xb5, 0xe0, 27 string = decode([0xe0, 0xae, 0x9a, 0xe0, 0xae, 0xbf, 0xe0, 0xae, 0xb5, 0xe0,
26 0xae, 0xbe, 0x20, 0xe0, 0xae, 0x85, 0xe0, 0xae, 0xa3, 0xe0, 28 0xae, 0xbe, 0x20, 0xe0, 0xae, 0x85, 0xe0, 0xae, 0xa3, 0xe0,
27 0xae, 0xbe, 0xe0, 0xae, 0xae, 0xe0, 0xae, 0xbe, 0xe0, 0xaf, 29 0xae, 0xbe, 0xe0, 0xae, 0xae, 0xe0, 0xae, 0xbe, 0xe0, 0xaf,
28 0x88, 0xe0, 0xae, 0xb2]); 30 0x88, 0xe0, 0xae, 0xb2]);
29 Expect.stringEquals("சிவா அணாமாைல", string); 31 Expect.stringEquals("சிவா அணாமாைல", string);
30 32
31 // "िसवा अणामालै", that is "Siva Annamalai" in Devanagari. 33 // "िसवा अणामालै", that is "Siva Annamalai" in Devanagari.
32 string = decode([0xe0, 0xa4, 0xbf, 0xe0, 0xa4, 0xb8, 0xe0, 0xa4, 0xb5, 0xe0, 34 string = decode([0xe0, 0xa4, 0xbf, 0xe0, 0xa4, 0xb8, 0xe0, 0xa4, 0xb5, 0xe0,
33 0xa4, 0xbe, 0x20, 0xe0, 0xa4, 0x85, 0xe0, 0xa4, 0xa3, 0xe0, 35 0xa4, 0xbe, 0x20, 0xe0, 0xa4, 0x85, 0xe0, 0xa4, 0xa3, 0xe0,
34 0xa4, 0xbe, 0xe0, 0xa4, 0xae, 0xe0, 0xa4, 0xbe, 0xe0, 0xa4, 36 0xa4, 0xbe, 0xe0, 0xa4, 0xae, 0xe0, 0xa4, 0xbe, 0xe0, 0xa4,
35 0xb2, 0xe0, 0xa5, 0x88]); 37 0xb2, 0xe0, 0xa5, 0x88]);
36 Expect.stringEquals("िसवा अणामालै", string); 38 Expect.stringEquals("िसवा अणामालै", string);
37 39
38 // DESERET CAPITAL LETTER BEE, unicode 0x10412(0xD801+0xDC12) 40 if (!isRunningOnJavaScript()) {
39 // UTF-8: F0 90 90 92 41 // DESERET CAPITAL LETTER BEE, unicode 0x10412(0xD801+0xDC12)
40 string = decode([0xf0, 0x90, 0x90, 0x92]); 42 // UTF-8: F0 90 90 92
41 Expect.equals(string.length, 2); 43 string = decode([0xf0, 0x90, 0x90, 0x92]);
42 Expect.equals("𐐒".length, 2); 44 Expect.stringEquals("𐐒", string);
43 Expect.stringEquals("𐐒", string); 45 } else {
46 print('Skipping non-BMP character test');
47 }
44 48
45 // TODO(ahe): Add tests of bad input. 49 // TODO(ahe): Add tests of bad input.
46 } 50 }
OLDNEW
« no previous file with comments | « tests/standalone/io/string_stream_test.dart ('k') | tests/utils/utf_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698