| 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 "package:expect/expect.dart"; |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 import 'dart:codec'; | |
| 9 | 8 |
| 10 String decode(List<int> bytes) => new Utf8Decoder().convert(bytes); | 9 String decode(List<int> bytes) => new Utf8Decoder().convert(bytes); |
| 11 String decodeAllowMalformed(List<int> bytes) { | 10 String decodeAllowMalformed(List<int> bytes) { |
| 12 return new Utf8Decoder(allowMalformed: true).convert(bytes); | 11 return new Utf8Decoder(allowMalformed: true).convert(bytes); |
| 13 } | 12 } |
| 14 | 13 |
| 15 String decode2(List<int> bytes) => UTF8.decode(bytes); | 14 String decode2(List<int> bytes) => UTF8.decode(bytes); |
| 16 String decodeAllowMalformed2(List<int> bytes) { | 15 String decodeAllowMalformed2(List<int> bytes) { |
| 17 return UTF8.decode(bytes, allowMalformed: true); | 16 return UTF8.decode(bytes, allowMalformed: true); |
| 18 } | 17 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 Expect.throws(() => decode3(bytes), (e) => e is FormatException); | 125 Expect.throws(() => decode3(bytes), (e) => e is FormatException); |
| 127 Expect.throws(() => decode4(bytes), (e) => e is FormatException); | 126 Expect.throws(() => decode4(bytes), (e) => e is FormatException); |
| 128 | 127 |
| 129 String expected = test[1]; | 128 String expected = test[1]; |
| 130 Expect.equals(expected, decodeAllowMalformed(bytes)); | 129 Expect.equals(expected, decodeAllowMalformed(bytes)); |
| 131 Expect.equals(expected, decodeAllowMalformed2(bytes)); | 130 Expect.equals(expected, decodeAllowMalformed2(bytes)); |
| 132 Expect.equals(expected, decodeAllowMalformed3(bytes)); | 131 Expect.equals(expected, decodeAllowMalformed3(bytes)); |
| 133 Expect.equals(expected, decodeAllowMalformed4(bytes)); | 132 Expect.equals(expected, decodeAllowMalformed4(bytes)); |
| 134 } | 133 } |
| 135 } | 134 } |
| OLD | NEW |