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

Side by Side Diff: tests/standalone/io/zlib_test.dart

Issue 14962006: Actually end a ZLib stream with a Z_FINISH marker. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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/io/data_transformer.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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:isolate'; 8 import 'dart:isolate';
9 9
10 void testZLibDeflate() { 10 void testZLibDeflate() {
11 test(int level, List<int> expected) { 11 test(int level, List<int> expected) {
12 var port = new ReceivePort(); 12 var port = new ReceivePort();
13 var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; 13 var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
14 var controller = new StreamController(); 14 var controller = new StreamController();
15 controller.stream.transform(new ZLibDeflater(gzip: false, level: level)) 15 controller.stream.transform(new ZLibDeflater(gzip: false, level: level))
16 .fold([], (buffer, data) { 16 .fold([], (buffer, data) {
17 buffer.addAll(data); 17 buffer.addAll(data);
18 return buffer; 18 return buffer;
19 }) 19 })
20 .then((data) { 20 .then((data) {
21 Expect.listEquals(expected, data); 21 Expect.listEquals(expected, data);
22 port.close(); 22 port.close();
23 }); 23 });
24 controller.add(data); 24 controller.add(data);
25 controller.close(); 25 controller.close();
26 } 26 }
27 test(0, [120, 1, 0, 10, 0, 245, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 27 test(6, [120, 156, 99, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 175,
28 255, 255]); 28 0, 46]);
kustermann 2013/05/16 10:10:08 I don't know why your tests didn't catch this issu
Anders Johnsen 2013/06/11 12:15:15 The new test is testing that we actually do get a
29 test(1, [120, 1, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0,
30 255, 255]);
31 test(2, [120, 94, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0,
32 255, 255]);
33 test(3, [120, 94, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0,
34 255, 255]);
35 test(4, [120, 94, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0,
36 255, 255]);
37 test(5, [120, 94, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0,
38 255, 255]);
39 test(6, [120, 156, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0,
40 255, 255]);
41 test(-1, [120, 156, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0,
42 255, 255]);
43 test(7, [120, 218, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0,
44 255, 255]);
45 test(8, [120, 218, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0,
46 255, 255]);
47 test(9, [120, 218, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0,
48 255, 255]);
49 } 29 }
50 30
51 31
52 void testZLibDeflateEmpty() { 32 void testZLibDeflateEmpty() {
53 var port = new ReceivePort(); 33 var port = new ReceivePort();
54 var controller = new StreamController(); 34 var controller = new StreamController();
55 controller.stream.transform(new ZLibDeflater(gzip: false, level: 6)) 35 controller.stream.transform(new ZLibDeflater(gzip: false, level: 6))
56 .fold([], (buffer, data) { 36 .fold([], (buffer, data) {
57 buffer.addAll(data); 37 buffer.addAll(data);
58 return buffer; 38 return buffer;
59 }) 39 })
60 .then((data) { 40 .then((data) {
61 print(data); 41 Expect.listEquals([120, 156, 3, 0, 0, 0, 0, 1], data);
62 Expect.listEquals([120, 156, 2, 0, 0, 0, 255, 255], data);
63 port.close(); 42 port.close();
64 }); 43 });
65 controller.close(); 44 controller.close();
66 } 45 }
67 46
68 47
69 void testZLibDeflateGZip() { 48 void testZLibDeflateGZip() {
70 var port = new ReceivePort(); 49 var port = new ReceivePort();
71 var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; 50 var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
72 var controller = new StreamController(); 51 var controller = new StreamController();
73 controller.stream.transform(new ZLibDeflater()) 52 controller.stream.transform(new ZLibDeflater())
74 .fold([], (buffer, data) { 53 .fold([], (buffer, data) {
75 buffer.addAll(data); 54 buffer.addAll(data);
76 return buffer; 55 return buffer;
77 }) 56 })
78 .then((data) { 57 .then((data) {
79 Expect.equals(26, data.length); 58 Expect.equals(30, data.length);
80 Expect.listEquals([98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 59 Expect.listEquals([99, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0,
81 0, 255, 255], 60 70, 215, 108, 69, 10, 0, 0, 0],
82 // Skip header, as it can change. 61 // Skip header, as it can change.
83 data.sublist(10)); 62 data.sublist(10));
84 port.close(); 63 port.close();
85 }); 64 });
86 controller.add(data); 65 controller.add(data);
87 controller.close(); 66 controller.close();
88 } 67 }
89 68
90 void testZLibDeflateInvalidLevel() { 69 void testZLibDeflateInvalidLevel() {
91 test2(gzip, level) { 70 test2(gzip, level) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 116 }
138 } 117 }
139 118
140 void main() { 119 void main() {
141 testZLibDeflate(); 120 testZLibDeflate();
142 testZLibDeflateEmpty(); 121 testZLibDeflateEmpty();
143 testZLibDeflateGZip(); 122 testZLibDeflateGZip();
144 testZLibDeflateInvalidLevel(); 123 testZLibDeflateInvalidLevel();
145 testZLibInflate(); 124 testZLibInflate();
146 } 125 }
OLDNEW
« 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