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

Unified Diff: tests/corelib/string_fromcharcodes_test.dart

Issue 864463002: Create string efficiently from Uint16List/View. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« runtime/lib/string_patch.dart ('K') | « sdk/lib/core/errors.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/string_fromcharcodes_test.dart
diff --git a/tests/corelib/string_fromcharcodes_test.dart b/tests/corelib/string_fromcharcodes_test.dart
index 99c4643cac257b42b871191566b6ba90fbe64419..86c0eb44f60e97b281042804be5c34d37c1e6143 100644
--- a/tests/corelib/string_fromcharcodes_test.dart
+++ b/tests/corelib/string_fromcharcodes_test.dart
@@ -10,7 +10,8 @@ main() {
? new Iterable.generate(count, (x) => values[x])
: new Iterable.generate(count, (x) => values);
test(expect, iter, [start = 0, end]) {
- Expect.equals(expect, new String.fromCharCodes(iter, start, end));
+ var actual = new String.fromCharCodes(iter, start, end);
+ Expect.equals(expect, actual);
}
testThrows(iterable, [start = 0, end]) {
Expect.throws(() { new String.fromCharCodes(iterable, start, end); });
@@ -193,4 +194,51 @@ main() {
testSubstring("\x00" * 357);
// length > 128 and non-ASCII.
testSubstring("\uFFFD\uFFFE\u{10000}\u{10ffff}c\x00" * 37);
+
+ const cLatin1 = const [0x00, 0xff];
+ const cUtf16 = const [0x00, 0xffff, 0xdfff, 0xdbff, 0xdfff, 0xdbff];
+ const cCodepoints = const [0x00, 0xffff, 0xdfff, 0x10ffff, 0xdbff];
+ List gLatin1 = cLatin1.toList(growable: true);
+ List gUtf16 = cUtf16.toList(growable: true);
+ List gCodepoints = cCodepoints.toList(growable: true);
+ List fLatin1 = cLatin1.toList(growable: false);
+ List fUtf16 = cUtf16.toList(growable: false);
+ List fCodepoints = cCodepoints.toList(growable: false);
+ Uint8List bLatin1 = new Uint8List(2)..setRange(0, 2, cLatin1);
+ Uint16List wLatin1 = new Uint16List(2)..setRange(0, 2, cLatin1);
+ Uint16List wUtf16 = new Uint16List(6)..setRange(0, 6, cUtf16);
+ Uint32List lLatin1 = new Uint32List(2)..setRange(0, 2, cLatin1);
+ Uint32List lUtf16 = new Uint32List(6)..setRange(0, 6, cUtf16);
+ Uint32List lCodepoints = new Uint32List(5)..setRange(0, 5, cCodepoints);
+ String sLatin1 = "\x00\xff";
+ String sUnicode =
+ "\x00\uffff$tailSurrogate$leadSurrogate$tailSurrogate$leadSurrogate";
+ for (int i = 0; i < 2; i++) {
+ for (int j = i + 1; j < 2; j++) {
+ test(sLatin1.substring(i, j), cLatin1, i, j);
+ test(sLatin1.substring(i, j), gLatin1, i, j);
+ test(sLatin1.substring(i, j), fLatin1, i, j);
+ test(sLatin1.substring(i, j), bLatin1, i, j);
+ test(sLatin1.substring(i, j), wLatin1, i, j);
+ test(sLatin1.substring(i, j), lLatin1, i, j);
+ }
+ }
+ for (int i = 0; i < 6; i++) {
+ for (int j = i + 1; j < 6; j++) {
+ test(sUnicode.substring(i, j), cUtf16, i, j);
+ test(sUnicode.substring(i, j), gUtf16, i, j);
+ test(sUnicode.substring(i, j), fUtf16, i, j);
+ test(sUnicode.substring(i, j), wUtf16, i, j);
+ test(sUnicode.substring(i, j), lUtf16, i, j);
+ }
+ }
+ for (int i = 0; i < 5; i++) {
+ for (int j = i + 1; j < 5; j++) {
+ int stringEnd = j < 4 ? j : j + 1;
+ test(sUnicode.substring(i, stringEnd), cCodepoints, i, j);
+ test(sUnicode.substring(i, stringEnd), gCodepoints, i, j);
+ test(sUnicode.substring(i, stringEnd), fCodepoints, i, j);
+ test(sUnicode.substring(i, stringEnd), lCodepoints, i, j);
+ }
+ }
siva 2015/01/20 23:50:26 Does this also test the ExternalTypedData and Uint
Lasse Reichstein Nielsen 2015/01/22 07:16:33 No. I'll add Uint16ListViev. Is there a way to cre
siva 2015/01/23 01:06:33 You would have to create it in native code and pas
}
« runtime/lib/string_patch.dart ('K') | « sdk/lib/core/errors.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698