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

Side by Side Diff: tests/lib/convert/unicode_tests.dart

Issue 22854028: Fix off-by-one error in UTF-8 encoding. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/convert/utf.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 unicode_tests; 5 library unicode_tests;
6 6
7 // Google favorite: "Îñţérñåţîöñåļîžåţîờñ". 7 // Google favorite: "Îñţérñåţîöñåļîžåţîờñ".
8 const INTER_BYTES = const [0xc3, 0x8e, 0xc3, 0xb1, 0xc5, 0xa3, 0xc3, 0xa9, 0x72, 8 const INTER_BYTES = const [0xc3, 0x8e, 0xc3, 0xb1, 0xc5, 0xa3, 0xc3, 0xa9, 0x72,
9 0xc3, 0xb1, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xc3, 9 0xc3, 0xb1, 0xc3, 0xa5, 0xc5, 0xa3, 0xc3, 0xae, 0xc3,
10 0xb6, 0xc3, 0xb1, 0xc3, 0xa5, 0xc4, 0xbc, 0xc3, 0xae, 10 0xb6, 0xc3, 0xb1, 0xc3, 0xa5, 0xc4, 0xbc, 0xc3, 0xae,
(...skipping 27 matching lines...) Expand all
38 38
39 const DIGIT_BYTES = const [ 0x35 ]; 39 const DIGIT_BYTES = const [ 0x35 ];
40 const DIGIT_STRING = "5"; 40 const DIGIT_STRING = "5";
41 41
42 const ASCII_BYTES = const [ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 42 const ASCII_BYTES = const [ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
43 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 43 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,
44 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 44 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
45 0x79, 0x7A ]; 45 0x79, 0x7A ];
46 const ASCII_STRING = "abcdefghijklmnopqrstuvwxyz"; 46 const ASCII_STRING = "abcdefghijklmnopqrstuvwxyz";
47 47
48 const BIGGEST_ASCII_BYTES = const [ 0x7F ];
49 const BIGGEST_ASCII_STRING = "\x7F";
Lasse Reichstein Nielsen 2013/08/20 13:56:49 Consider adding - "\x80" [ 0xc2, 0x80 ] - "\u{400
floitsch 2013/08/20 14:03:22 Done.
50
51 const BIGGEST_2_UTF8_UNIT_BYTES = const [ 0xCF, 0xBF ];
52 const BIGGEST_2_UTF8_UNIT_STRING = "\u{3FF}";
53
54 const BIGGEST_3_UTF8_UNIT_BYTES = const [ 0xEF, 0xBF, 0xBF ];
55 const BIGGEST_3_UTF8_UNIT_STRING = "\u{FFFF}";
56
48 const _TEST_PAIRS = const [ 57 const _TEST_PAIRS = const [
49 const [ const [], "" ], 58 const [ const [], "" ],
50 const [ INTER_BYTES, INTER_STRING ], 59 const [ INTER_BYTES, INTER_STRING ],
51 const [ BLUEBERRY_BYTES, BLUEBERRY_STRING ], 60 const [ BLUEBERRY_BYTES, BLUEBERRY_STRING ],
52 const [ SIVA_BYTES1, SIVA_STRING1 ], 61 const [ SIVA_BYTES1, SIVA_STRING1 ],
53 const [ SIVA_BYTES2, SIVA_STRING2 ], 62 const [ SIVA_BYTES2, SIVA_STRING2 ],
54 const [ BEE_BYTES, BEE_STRING ], 63 const [ BEE_BYTES, BEE_STRING ],
55 const [ DIGIT_BYTES, DIGIT_STRING ], 64 const [ DIGIT_BYTES, DIGIT_STRING ],
56 const [ ASCII_BYTES, ASCII_STRING ]]; 65 const [ ASCII_BYTES, ASCII_STRING ],
66 const [ BIGGEST_ASCII_BYTES, BIGGEST_ASCII_STRING ],
67 const [ BIGGEST_2_UTF8_UNIT_BYTES, BIGGEST_2_UTF8_UNIT_STRING ],
68 const [ BIGGEST_3_UTF8_UNIT_BYTES, BIGGEST_3_UTF8_UNIT_STRING ],
69 ];
57 70
58 List<List> _expandTestPairs() { 71 List<List> _expandTestPairs() {
59 assert(2 == BEE_STRING.length); 72 assert(2 == BEE_STRING.length);
60 var tests = []; 73 var tests = [];
61 tests.addAll(_TEST_PAIRS); 74 tests.addAll(_TEST_PAIRS);
62 tests.addAll(_TEST_PAIRS.expand((test) { 75 tests.addAll(_TEST_PAIRS.expand((test) {
63 var bytes = test[0]; 76 var bytes = test[0];
64 var string = test[1]; 77 var string = test[1];
65 var longBytes = []; 78 var longBytes = [];
66 var longString = ""; 79 var longString = "";
67 for (int i = 0; i < 100; i++) { 80 for (int i = 0; i < 100; i++) {
68 longBytes.addAll(bytes); 81 longBytes.addAll(bytes);
69 longString += string; 82 longString += string;
70 } 83 }
71 return [test, [longBytes, longString]]; 84 return [test, [longBytes, longString]];
72 })); 85 }));
73 return tests; 86 return tests;
74 } 87 }
75 88
76 final List UNICODE_TESTS = _expandTestPairs(); 89 final List UNICODE_TESTS = _expandTestPairs();
OLDNEW
« no previous file with comments | « sdk/lib/convert/utf.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698