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

Side by Side Diff: test/codegen/lib/convert/latin1_test.dart

Issue 2254883002: roll analyzer (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: update Created 4 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 var latin1Strings = [ 8 var latin1Strings = [
9 "pure ascii", 9 "pure ascii",
10 "blåbærgrød", 10 "blåbærgrød",
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 Expect.equals("\x00\x01\xFF\uFFFD\x00", decoded); 82 Expect.equals("\x00\x01\xFF\uFFFD\x00", decoded);
83 decoded = allowInvalidCodec.decoder.convert(invalidBytes); 83 decoded = allowInvalidCodec.decoder.convert(invalidBytes);
84 Expect.equals("\x00\x01\xFF\uFFFD\x00", decoded); 84 Expect.equals("\x00\x01\xFF\uFFFD\x00", decoded);
85 decoded = LATIN1.decode(invalidBytes, allowInvalid: true); 85 decoded = LATIN1.decode(invalidBytes, allowInvalid: true);
86 Expect.equals("\x00\x01\xFF\uFFFD\x00", decoded); 86 Expect.equals("\x00\x01\xFF\uFFFD\x00", decoded);
87 } 87 }
88 88
89 List<int> encode(String str, int chunkSize, 89 List<int> encode(String str, int chunkSize,
90 Converter<String, List<int>> converter) { 90 Converter<String, List<int>> converter) {
91 List<int> bytes = <int>[]; 91 List<int> bytes = <int>[];
92 ChunkedConversionSink byteSink = 92 var byteSink = new ByteConversionSink.withCallback(bytes.addAll);
93 new ByteConversionSink.withCallback(bytes.addAll);
94 var stringConversionSink = converter.startChunkedConversion(byteSink); 93 var stringConversionSink = converter.startChunkedConversion(byteSink);
95 for (int i = 0; i < str.length; i += chunkSize) { 94 for (int i = 0; i < str.length; i += chunkSize) {
96 if (i + chunkSize <= str.length) { 95 if (i + chunkSize <= str.length) {
97 stringConversionSink.add(str.substring(i, i + chunkSize)); 96 stringConversionSink.add(str.substring(i, i + chunkSize));
98 } else { 97 } else {
99 stringConversionSink.add(str.substring(i)); 98 stringConversionSink.add(str.substring(i));
100 } 99 }
101 } 100 }
102 stringConversionSink.close(); 101 stringConversionSink.close();
103 return bytes; 102 return bytes;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 148 }
150 for (var nonLatin1String in nonLatin1Strings) { 149 for (var nonLatin1String in nonLatin1Strings) {
151 var units = nonLatin1String.codeUnits.toList(); 150 var units = nonLatin1String.codeUnits.toList();
152 Expect.throws(() { 151 Expect.throws(() {
153 decode(units, chunkSize, converter); 152 decode(units, chunkSize, converter);
154 }); 153 });
155 } 154 }
156 } 155 }
157 } 156 }
158 } 157 }
OLDNEW
« no previous file with comments | « test/codegen/lib/convert/chunked_conversion_utf89_test.dart ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698