| 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 '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() => 1 === 1.0; | 10 bool isRunningOnJavaScript() => identical(1, 1.0); |
| 11 | 11 |
| 12 main() { | 12 main() { |
| 13 // Google favorite: "Îñţérñåţîöñåļîžåţîờñ". | 13 // Google favorite: "Îñţérñåţîöñåļîžåţîờñ". |
| 14 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, |
| 15 0xc3, 0xb1, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xc3, | 15 0xc3, 0xb1, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xc3, |
| 16 0xb6, 0xc3, 0xb1, 0xc3, 0xa5, 0xc4, 0xbc, 0xc3, 0xae, | 16 0xb6, 0xc3, 0xb1, 0xc3, 0xa5, 0xc4, 0xbc, 0xc3, 0xae, |
| 17 0xc5, 0xbe, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xe1, | 17 0xc5, 0xbe, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xe1, |
| 18 0xbb, 0x9d, 0xc3, 0xb1]); | 18 0xbb, 0x9d, 0xc3, 0xb1]); |
| 19 Expect.stringEquals("Îñţérñåţîöñåļîžåţîờñ", string); | 19 Expect.stringEquals("Îñţérñåţîöñåļîžåţîờñ", string); |
| 20 | 20 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 41 // DESERET CAPITAL LETTER BEE, unicode 0x10412(0xD801+0xDC12) | 41 // DESERET CAPITAL LETTER BEE, unicode 0x10412(0xD801+0xDC12) |
| 42 // UTF-8: F0 90 90 92 | 42 // UTF-8: F0 90 90 92 |
| 43 string = decode([0xf0, 0x90, 0x90, 0x92]); | 43 string = decode([0xf0, 0x90, 0x90, 0x92]); |
| 44 Expect.stringEquals("𐐒", string); | 44 Expect.stringEquals("𐐒", string); |
| 45 } else { | 45 } else { |
| 46 print('Skipping non-BMP character test'); | 46 print('Skipping non-BMP character test'); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // TODO(ahe): Add tests of bad input. | 49 // TODO(ahe): Add tests of bad input. |
| 50 } | 50 } |
| OLD | NEW |