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

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: Add more tests. 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";
50
51 const SMALLEST_2_UTF8_UNIT_BYTES = const [ 0xC2, 0x80 ];
52 const SMALLEST_2_UTF8_UNIT_STRING = "\u{80}";
53
54 const BIGGEST_2_UTF8_UNIT_BYTES = const [ 0xDF, 0xBF ];
55 const BIGGEST_2_UTF8_UNIT_STRING = "\u{7FF}";
56
57 const SMALLEST_3_UTF8_UNIT_BYTES = const [ 0xE0, 0xA0, 0x80 ];
58 const SMALLEST_3_UTF8_UNIT_STRING = "\u{800}";
59
60 const BIGGEST_3_UTF8_UNIT_BYTES = const [ 0xEF, 0xBF, 0xBF ];
61 const BIGGEST_3_UTF8_UNIT_STRING = "\u{FFFF}";
62
63 const SMALLEST_4_UTF8_UNIT_BYTES = const [ 0xF0, 0x90, 0x80, 0x80 ];
64 const SMALLEST_4_UTF8_UNIT_STRING = "\u{10000}";
65
48 const _TEST_PAIRS = const [ 66 const _TEST_PAIRS = const [
49 const [ const [], "" ], 67 const [ const [], "" ],
50 const [ INTER_BYTES, INTER_STRING ], 68 const [ INTER_BYTES, INTER_STRING ],
51 const [ BLUEBERRY_BYTES, BLUEBERRY_STRING ], 69 const [ BLUEBERRY_BYTES, BLUEBERRY_STRING ],
52 const [ SIVA_BYTES1, SIVA_STRING1 ], 70 const [ SIVA_BYTES1, SIVA_STRING1 ],
53 const [ SIVA_BYTES2, SIVA_STRING2 ], 71 const [ SIVA_BYTES2, SIVA_STRING2 ],
54 const [ BEE_BYTES, BEE_STRING ], 72 const [ BEE_BYTES, BEE_STRING ],
55 const [ DIGIT_BYTES, DIGIT_STRING ], 73 const [ DIGIT_BYTES, DIGIT_STRING ],
56 const [ ASCII_BYTES, ASCII_STRING ]]; 74 const [ ASCII_BYTES, ASCII_STRING ],
75 const [ BIGGEST_ASCII_BYTES, BIGGEST_ASCII_STRING ],
76 const [ SMALLEST_2_UTF8_UNIT_BYTES, SMALLEST_2_UTF8_UNIT_STRING ],
77 const [ BIGGEST_2_UTF8_UNIT_BYTES, BIGGEST_2_UTF8_UNIT_STRING ],
78 const [ SMALLEST_3_UTF8_UNIT_BYTES, SMALLEST_3_UTF8_UNIT_STRING ],
79 const [ BIGGEST_3_UTF8_UNIT_BYTES, BIGGEST_3_UTF8_UNIT_STRING ],
80 const [ SMALLEST_4_UTF8_UNIT_BYTES, SMALLEST_4_UTF8_UNIT_STRING ],
81 ];
57 82
58 List<List> _expandTestPairs() { 83 List<List> _expandTestPairs() {
59 assert(2 == BEE_STRING.length); 84 assert(2 == BEE_STRING.length);
60 var tests = []; 85 var tests = [];
61 tests.addAll(_TEST_PAIRS); 86 tests.addAll(_TEST_PAIRS);
62 tests.addAll(_TEST_PAIRS.expand((test) { 87 tests.addAll(_TEST_PAIRS.expand((test) {
63 var bytes = test[0]; 88 var bytes = test[0];
64 var string = test[1]; 89 var string = test[1];
65 var longBytes = []; 90 var longBytes = [];
66 var longString = ""; 91 var longString = "";
67 for (int i = 0; i < 100; i++) { 92 for (int i = 0; i < 100; i++) {
68 longBytes.addAll(bytes); 93 longBytes.addAll(bytes);
69 longString += string; 94 longString += string;
70 } 95 }
71 return [test, [longBytes, longString]]; 96 return [test, [longBytes, longString]];
72 })); 97 }));
73 return tests; 98 return tests;
74 } 99 }
75 100
76 final List UNICODE_TESTS = _expandTestPairs(); 101 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