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

Side by Side Diff: tests/lib_strong/convert/chunked_conversion_utf86_test.dart

Issue 2989993002: fix unsound cast failures in tests (Closed)
Patch Set: fix Created 3 years, 4 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
OLDNEW
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 7
8 String decode(List<int> bytes) { 8 String decode(List<int> bytes) {
9 StringBuffer buffer = new StringBuffer(); 9 StringBuffer buffer = new StringBuffer();
10 var stringSink = new StringConversionSink.fromStringSink(buffer); 10 var stringSink = new StringConversionSink.fromStringSink(buffer);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 ] 201 ]
202 ]; 202 ];
203 203
204 main() { 204 main() {
205 var allTests = TESTS.expand((test) { 205 var allTests = TESTS.expand((test) {
206 // Pairs of test and expected string output when malformed strings are 206 // Pairs of test and expected string output when malformed strings are
207 // allowed. Replacement character: U+FFFD 207 // allowed. Replacement character: U+FFFD
208 return [ 208 return [
209 [test, "\u{FFFD}"], 209 [test, "\u{FFFD}"],
210 [ 210 [
211 new List.from([0x61])..addAll(test), 211 new List<int>.from([0x61])..addAll(test),
212 "a\u{FFFD}" 212 "a\u{FFFD}"
213 ], 213 ],
214 [ 214 [
215 new List.from([0x61]) 215 new List<int>.from([0x61])
216 ..addAll(test) 216 ..addAll(test)
217 ..add(0x61), 217 ..add(0x61),
218 "a\u{FFFD}a" 218 "a\u{FFFD}a"
219 ], 219 ],
220 [new List.from(test)..add(0x61), "\u{FFFD}a"], 220 [new List<int>.from(test)..add(0x61), "\u{FFFD}a"],
221 [new List.from(test)..addAll(test), "\u{FFFD}\u{FFFD}"], 221 [new List<int>.from(test)..addAll(test), "\u{FFFD}\u{FFFD}"],
222 [ 222 [
223 new List.from(test) 223 new List<int>.from(test)
224 ..add(0x61) 224 ..add(0x61)
225 ..addAll(test), 225 ..addAll(test),
226 "\u{FFFD}a\u{FFFD}" 226 "\u{FFFD}a\u{FFFD}"
227 ], 227 ],
228 [ 228 [
229 new List.from([0xc3, 0xa5])..addAll(test), 229 new List<int>.from([0xc3, 0xa5])..addAll(test),
230 "å\u{FFFD}" 230 "å\u{FFFD}"
231 ], 231 ],
232 [ 232 [
233 new List.from([0xc3, 0xa5])..addAll(test)..addAll([0xc3, 0xa5]), 233 new List<int>.from([0xc3, 0xa5])..addAll(test)..addAll([0xc3, 0xa5]),
234 "å\u{FFFD}å" 234 "å\u{FFFD}å"
235 ], 235 ],
236 [ 236 [
237 new List.from(test)..addAll([0xc3, 0xa5]), 237 new List<int>.from(test)..addAll([0xc3, 0xa5]),
238 "\u{FFFD}å" 238 "\u{FFFD}å"
239 ], 239 ],
240 [ 240 [
241 new List.from(test)..addAll([0xc3, 0xa5])..addAll(test), 241 new List<int>.from(test)..addAll([0xc3, 0xa5])..addAll(test),
242 "\u{FFFD}å\u{FFFD}" 242 "\u{FFFD}å\u{FFFD}"
243 ] 243 ]
244 ]; 244 ];
245 }); 245 });
246 246
247 var allTests2 = TESTS2.map((test) { 247 var allTests2 = TESTS2.map((test) {
248 // Pairs of test and expected string output when malformed strings are 248 // Pairs of test and expected string output when malformed strings are
249 // allowed. Replacement character: U+FFFD 249 // allowed. Replacement character: U+FFFD
250 String expected = (test[1] as String).replaceAll("X", "\u{FFFD}"); 250 String expected = (test[1] as String).replaceAll("X", "\u{FFFD}");
251 return [test[0], expected]; 251 return [test[0], expected];
252 }); 252 });
253 253
254 for (var test in []..addAll(allTests)..addAll(allTests2)) { 254 for (var test in []..addAll(allTests)..addAll(allTests2)) {
255 List<int> bytes = test[0]; 255 List<int> bytes = test[0];
256 Expect.throws(() => decode(bytes), (e) => e is FormatException); 256 Expect.throws(() => decode(bytes), (e) => e is FormatException);
257 257
258 String expected = test[1]; 258 String expected = test[1];
259 Expect.equals(expected, decodeAllowMalformed(bytes)); 259 Expect.equals(expected, decodeAllowMalformed(bytes));
260 } 260 }
261 } 261 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698