OLD | NEW |
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 "package:expect/expect.dart"; |
6 import 'dart:utf'; | 7 import 'dart:utf'; |
7 | 8 |
8 String decode(List<int> bytes) => decodeUtf8(bytes); | 9 String decode(List<int> bytes) => decodeUtf8(bytes); |
9 | 10 |
10 main() { | 11 main() { |
11 // Google favorite: "Îñţérñåţîöñåļîžåţîờñ". | 12 // Google favorite: "Îñţérñåţîöñåļîžåţîờñ". |
12 String string = decode([0xc3, 0x8e, 0xc3, 0xb1, 0xc5, 0xa3, 0xc3, 0xa9, 0x72, | 13 String string = decode([0xc3, 0x8e, 0xc3, 0xb1, 0xc5, 0xa3, 0xc3, 0xa9, 0x72, |
13 0xc3, 0xb1, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xc3, | 14 0xc3, 0xb1, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xc3, |
14 0xb6, 0xc3, 0xb1, 0xc3, 0xa5, 0xc4, 0xbc, 0xc3, 0xae, | 15 0xb6, 0xc3, 0xb1, 0xc3, 0xa5, 0xc4, 0xbc, 0xc3, 0xae, |
15 0xc5, 0xbe, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xe1, | 16 0xc5, 0xbe, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xe1, |
(...skipping 21 matching lines...) Expand all Loading... |
37 | 38 |
38 // DESERET CAPITAL LETTER BEE, unicode 0x10412(0xD801+0xDC12) | 39 // DESERET CAPITAL LETTER BEE, unicode 0x10412(0xD801+0xDC12) |
39 // UTF-8: F0 90 90 92 | 40 // UTF-8: F0 90 90 92 |
40 string = decode([0xf0, 0x90, 0x90, 0x92]); | 41 string = decode([0xf0, 0x90, 0x90, 0x92]); |
41 Expect.equals(string.length, 2); | 42 Expect.equals(string.length, 2); |
42 Expect.equals("𐐒".length, 2); | 43 Expect.equals("𐐒".length, 2); |
43 Expect.stringEquals("𐐒", string); | 44 Expect.stringEquals("𐐒", string); |
44 | 45 |
45 // TODO(ahe): Add tests of bad input. | 46 // TODO(ahe): Add tests of bad input. |
46 } | 47 } |
OLD | NEW |