Chromium Code Reviews| 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'dart:convert'; | 6 import 'dart:convert'; |
| 7 import 'unicode_tests.dart'; | 7 import 'unicode_tests.dart'; |
| 8 | 8 |
| 9 String decode(List<int> bytes) => new Utf8Decoder().convert(bytes); | 9 String decode(List<int> bytes) => new Utf8Decoder().convert(bytes); |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 void testDecodeSlice() { | 21 void testDecodeSlice() { |
| 22 var decoder = UTF8.decoder; // Doesn't allow malformed. | 22 var decoder = UTF8.decoder; // Doesn't allow malformed. |
| 23 var ascii = [0x41, 0x42, 0x43, 0x44, 0x45]; | 23 var ascii = [0x41, 0x42, 0x43, 0x44, 0x45]; |
| 24 Expect.equals("ABCDE", decoder.convert(ascii)); | 24 Expect.equals("ABCDE", decoder.convert(ascii)); |
| 25 Expect.equals("ABCDE", decoder.convert(ascii, 0)); | 25 Expect.equals("ABCDE", decoder.convert(ascii, 0)); |
| 26 Expect.equals("ABCDE", decoder.convert(ascii, 0, ascii.length)); | 26 Expect.equals("ABCDE", decoder.convert(ascii, 0, ascii.length)); |
| 27 Expect.equals("CDE", decoder.convert(ascii, 2)); | 27 Expect.equals("CDE", decoder.convert(ascii, 2)); |
| 28 Expect.equals("BCD", decoder.convert(ascii, 1, 4)); | 28 Expect.equals("BCD", decoder.convert(ascii, 1, 4)); |
| 29 Expect.equals("ABCD", decoder.convert(ascii, 0, 4)); | 29 Expect.equals("ABCD", decoder.convert(ascii, 0, 4)); |
| 30 | 30 |
| 31 Expect.throws(() => decoder.convert(ascii, -1)); // start < 0. | 31 Expect.throws(() => decoder.convert(ascii, -1)); // start < 0. |
| 32 Expect.throws(() => decoder.convert(ascii, 6)); // start > length | 32 Expect.throws(() => decoder.convert(ascii, 6)); // start > length |
| 33 Expect.throws(() => decoder.convert(ascii, 0, -1)); // end < 0 | 33 Expect.throws(() => decoder.convert(ascii, 0, -1)); // end < 0 |
| 34 Expect.throws(() => decoder.convert(ascii, 0, 6)); // end > length | 34 Expect.throws(() => decoder.convert(ascii, 0, 6)); // end > length |
|
sra1
2017/03/21 03:01:09
sp sp // -> sp // sp
| |
| 35 Expect.throws(() => decoder.convert(ascii, 3, 2)); // end < start | 35 Expect.throws(() => decoder.convert(ascii, 3, 2)); // end < start |
| 36 | 36 |
| 37 var utf8 = [0xc2, 0x81, 0xc2, 0x82, 0xe1, 0x81, 0x81]; | 37 var utf8 = [0xc2, 0x81, 0xc2, 0x82, 0xe1, 0x81, 0x81]; |
| 38 Expect.equals("\u0081\u0082\u1041", decoder.convert(utf8)); | 38 Expect.equals("\u0081\u0082\u1041", decoder.convert(utf8)); |
| 39 Expect.equals("\u0082\u1041", decoder.convert(utf8, 2)); | 39 Expect.equals("\u0082\u1041", decoder.convert(utf8, 2)); |
| 40 Expect.equals("\u0081\u0082", decoder.convert(utf8, 0, 4)); | 40 Expect.equals("\u0081\u0082", decoder.convert(utf8, 0, 4)); |
| 41 Expect.equals("\u0082", decoder.convert(utf8, 2, 4)); | 41 Expect.equals("\u0082", decoder.convert(utf8, 2, 4)); |
| 42 Expect.throws(() => decoder.convert(utf8, 1)); | 42 Expect.throws(() => decoder.convert(utf8, 1)); |
| 43 Expect.throws(() => decoder.convert(utf8, 0, 1)); | 43 Expect.throws(() => decoder.convert(utf8, 0, 1)); |
| 44 Expect.throws(() => decoder.convert(utf8, 2, 5)); | 44 Expect.throws(() => decoder.convert(utf8, 2, 5)); |
| 45 } | 45 } |
| OLD | NEW |