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

Unified Diff: tests/standalone/io/zlib_test.dart

Issue 1393013002: Ensure ZILB encoder handles all typed data lists correctly (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Addressed review comments Created 5 years, 2 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
« no previous file with comments | « sdk/lib/io/data_transformer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/zlib_test.dart
diff --git a/tests/standalone/io/zlib_test.dart b/tests/standalone/io/zlib_test.dart
index 3392ffdec286b35ba3726eff9cf1d301d9ac7041..acb6e86d93b0d554c3bfd3d60e7244882d8f5367 100644
--- a/tests/standalone/io/zlib_test.dart
+++ b/tests/standalone/io/zlib_test.dart
@@ -4,6 +4,7 @@
import 'dart:async';
import 'dart:io';
+import 'dart:typed_data';
import "package:async_helper/async_helper.dart";
import "package:expect/expect.dart";
@@ -39,9 +40,8 @@ void testZLibDeflateEmptyGzip() {
controller.close();
}
-void testZLibDeflate() {
+void testZLibDeflate(List<int> data) {
asyncStart();
- var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
var controller = new StreamController(sync: true);
controller.stream.transform(new ZLibEncoder(gzip: false, level: 6))
.fold([], (buffer, data) {
@@ -59,9 +59,8 @@ void testZLibDeflate() {
controller.close();
}
-void testZLibDeflateGZip() {
+void testZLibDeflateGZip(List<int> data) {
asyncStart();
- var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
var controller = new StreamController(sync: true);
controller.stream.transform(new ZLibEncoder(gzip: true))
.fold([], (buffer, data) {
@@ -80,9 +79,8 @@ void testZLibDeflateGZip() {
controller.close();
}
-void testZLibDeflateRaw() {
+void testZLibDeflateRaw(List<int> data) {
asyncStart();
- var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
var controller = new StreamController(sync: true);
controller.stream.transform(new ZLibEncoder(raw: true, level: 6))
.fold([], (buffer, data) {
@@ -112,9 +110,7 @@ void testZLibDeflateInvalidLevel() {
};
}
-void testZLibInflate() {
- var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
-
+void testZLibInflate(List<int> data) {
[true, false].forEach((gzip) {
[ZLibOption.STRATEGY_FILTERED, ZLibOption.STRATEGY_HUFFMAN_ONLY,
ZLibOption.STRATEGY_RLE, ZLibOption.STRATEGY_FIXED,
@@ -141,9 +137,7 @@ void testZLibInflate() {
});
}
-void testZLibInflateRaw() {
- var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
-
+void testZLibInflateRaw(List<int> data) {
[3, 6, 9].forEach((level) {
asyncStart();
var controller = new StreamController(sync: true);
@@ -163,9 +157,7 @@ void testZLibInflateRaw() {
});
}
-void testZLibInflateSync() {
- var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
-
+void testZLibInflateSync(List<int> data) {
[true, false].forEach((gzip) {
[3, 6, 9].forEach((level) {
var encoded = new ZLibEncoder(gzip: gzip, level: level).convert(data);
@@ -219,19 +211,48 @@ void testZlibWithDictionary() {
});
}
+var generateListTypes = [
+ (list) => list,
+ (list) => new Uint8List.fromList(list),
+ (list) => new Int8List.fromList(list),
+ (list) => new Uint16List.fromList(list),
+ (list) => new Int16List.fromList(list),
+ (list) => new Uint32List.fromList(list),
+ (list) => new Int32List.fromList(list),
+];
+
+var generateViewTypes = [
+ (list) => new Uint8List.view((new Uint8List.fromList(list)).buffer, 1, 8),
+ (list) => new Int8List.view((new Int8List.fromList(list)).buffer, 1, 8),
+ (list) => new Uint16List.view((new Uint16List.fromList(list)).buffer, 2, 6),
+ (list) => new Int16List.view((new Int16List.fromList(list)).buffer, 2, 6),
+ (list) => new Uint32List.view((new Uint32List.fromList(list)).buffer, 4, 4),
+ (list) => new Int32List.view((new Int32List.fromList(list)).buffer, 4, 4),
+];
+
+
void main() {
asyncStart();
- testZLibDeflate();
testZLibDeflateEmpty();
testZLibDeflateEmptyGzip();
- testZLibDeflateGZip();
testZLibDeflateInvalidLevel();
- testZLibInflate();
- testZLibInflateSync();
+ generateListTypes.forEach((f) {
+ var data = f([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+ testZLibDeflate(data);
+ testZLibDeflateGZip(data);
+ testZLibDeflateRaw(data);
+ testZLibInflate(data);
+ testZLibInflateSync(data);
+ testZLibInflateRaw(data);
+ });
+ generateViewTypes.forEach((f) {
+ var data = f([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+ testZLibInflate(data);
+ testZLibInflateSync(data);
+ testZLibInflateRaw(data);
+ });
testZlibInflateThrowsWithSmallerWindow();
testZlibInflateWithLargerWindow();
- testZLibDeflateRaw();
- testZLibInflateRaw();
testZlibWithDictionary();
asyncEnd();
}
« no previous file with comments | « sdk/lib/io/data_transformer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698