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

Side by Side Diff: dart/tests/utils/src/Utf8Test.dart

Issue 9190042: Add test case for utils/utf8/utf8.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Moved test to utils 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
« no previous file with comments | « no previous file | dart/tests/utils/utils.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // TODO(ahe): This test should be moved to a different location, it is
kasperl 2012/04/20 09:22:55 Remove comment?
ahe 2012/04/20 09:26:45 Done.
6 // not testing the core library.
7
8 #import('dart:utf');
9
10 String decode(List<int> bytes) => decodeUtf8(bytes);
11
12 bool isRunningOnJavaScript() => 1 === 1.0;
13
14 main() {
15 // Google favorite: "Îñţérñåţîöñåļîžåţîờñ".
16 String string = decode([0xc3, 0x8e, 0xc3, 0xb1, 0xc5, 0xa3, 0xc3, 0xa9, 0x72,
17 0xc3, 0xb1, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xc3,
18 0xb6, 0xc3, 0xb1, 0xc3, 0xa5, 0xc4, 0xbc, 0xc3, 0xae,
19 0xc5, 0xbe, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xe1,
20 0xbb, 0x9d, 0xc3, 0xb1]);
21 Expect.stringEquals("Îñţérñåţîöñåļîžåţîờñ", string);
22
23 // Blueberry porridge in Danish: "blåbærgrød".
24 string = decode([0x62, 0x6c, 0xc3, 0xa5, 0x62, 0xc3, 0xa6, 0x72, 0x67, 0x72,
25 0xc3, 0xb8, 0x64]);
26 Expect.stringEquals("blåbærgrød", string);
27
28 // "சிவா அணாமாைல", that is "Siva Annamalai" in Tamil.
29 string = decode([0xe0, 0xae, 0x9a, 0xe0, 0xae, 0xbf, 0xe0, 0xae, 0xb5, 0xe0,
30 0xae, 0xbe, 0x20, 0xe0, 0xae, 0x85, 0xe0, 0xae, 0xa3, 0xe0,
31 0xae, 0xbe, 0xe0, 0xae, 0xae, 0xe0, 0xae, 0xbe, 0xe0, 0xaf,
32 0x88, 0xe0, 0xae, 0xb2]);
33 Expect.stringEquals("சிவா அணாமாைல", string);
34
35 // "िसवा अणामालै", that is "Siva Annamalai" in Devanagari.
36 string = decode([0xe0, 0xa4, 0xbf, 0xe0, 0xa4, 0xb8, 0xe0, 0xa4, 0xb5, 0xe0,
37 0xa4, 0xbe, 0x20, 0xe0, 0xa4, 0x85, 0xe0, 0xa4, 0xa3, 0xe0,
38 0xa4, 0xbe, 0xe0, 0xa4, 0xae, 0xe0, 0xa4, 0xbe, 0xe0, 0xa4,
39 0xb2, 0xe0, 0xa5, 0x88]);
40 Expect.stringEquals("िसवा अणामालै", string);
41
42 if (!isRunningOnJavaScript()) {
43 // DESERET CAPITAL LETTER BEE, unicode 0x10412(0xD801+0xDC12)
44 // UTF-8: F0 90 90 92
45 string = decode([0xf0, 0x90, 0x90, 0x92]);
46 Expect.stringEquals("𐐒", string);
47 } else {
48 print('Skipping non-BMP character test');
49 }
50
51 // TODO(ahe): Add tests of bad input.
52 }
OLDNEW
« no previous file with comments | « no previous file | dart/tests/utils/utils.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698